Skip to content

Commit 3daae5e

Browse files
committed
Auto merge of #157897 - JonathanBrouwer:rollup-dubtF89, r=JonathanBrouwer
Rollup of 2 pull requests Successful merges: - #141000 (rustdoc: Also run lint `unused_doc_comments`) - #157826 (make test succeed on targets lacking a personality)
2 parents c7446f2 + 0c2ef16 commit 3daae5e

7 files changed

Lines changed: 65 additions & 14 deletions

File tree

src/librustdoc/core.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ pub(crate) fn create_config(
235235
// it's unclear whether these should be part of rustdoc directly (#77364)
236236
rustc_lint::builtin::MISSING_DOCS.name.to_string(),
237237
rustc_lint::builtin::INVALID_DOC_ATTRIBUTES.name.to_string(),
238+
rustc_lint::builtin::UNUSED_DOC_COMMENTS.name.to_string(),
238239
// these are definitely not part of rustdoc, but we want to warn on them anyway.
239240
rustc_lint::builtin::RENAMED_AND_REMOVED_LINTS.name.to_string(),
240241
rustc_lint::builtin::UNKNOWN_LINTS.name.to_string(),

tests/rustdoc-ui/check-doc-alias-attr-location.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ pub trait Foo {
44
fn foo() -> Self::X;
55
}
66

7+
// FIXME(#96009): Don't emit `unused_doc_comments` here, we already emit an error anyway.
8+
//~v WARN
79
#[doc(alias = "foo")] //~ ERROR
810
extern "C" {}
911

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1+
warning: unused doc comment
2+
--> $DIR/check-doc-alias-attr-location.rs:9:1
3+
|
4+
LL | #[doc(alias = "foo")]
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
LL | extern "C" {}
7+
| ------------- rustdoc does not generate documentation for extern blocks
8+
|
9+
= help: use `//` for a plain comment
10+
= note: `#[warn(unused_doc_comments)]` (part of `#[warn(unused)]`) on by default
11+
112
error: `#[doc(alias = "...")]` isn't allowed on foreign module
2-
--> $DIR/check-doc-alias-attr-location.rs:7:15
13+
--> $DIR/check-doc-alias-attr-location.rs:9:15
314
|
415
LL | #[doc(alias = "foo")]
516
| ^^^^^
617

718
error: `#[doc(alias = "...")]` isn't allowed on implementation block
8-
--> $DIR/check-doc-alias-attr-location.rs:10:15
19+
--> $DIR/check-doc-alias-attr-location.rs:12:15
920
|
1021
LL | #[doc(alias = "bar")]
1122
| ^^^^^
1223

1324
error: `#[doc(alias = "...")]` isn't allowed on implementation block
14-
--> $DIR/check-doc-alias-attr-location.rs:16:15
25+
--> $DIR/check-doc-alias-attr-location.rs:18:15
1526
|
1627
LL | #[doc(alias = "foobar")]
1728
| ^^^^^^^^
1829

1930
error: `#[doc(alias = "...")]` isn't allowed on type alias in implementation block
20-
--> $DIR/check-doc-alias-attr-location.rs:18:19
31+
--> $DIR/check-doc-alias-attr-location.rs:20:19
2132
|
2233
LL | #[doc(alias = "assoc")]
2334
| ^^^^^^^
2435

25-
error: aborting due to 4 previous errors
36+
error: aborting due to 4 previous errors; 1 warning emitted
2637

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Ensure that lint `unused_doc_comments` also gets emitted by rustdoc, not just by rustc.
2+
//@ check-pass
3+
4+
pub fn f</** */T>() { //~ WARN unused doc comment
5+
/** */ let (); //~ WARN unused doc comment
6+
}
7+
8+
macro_rules! m { () => { pub fn g() {} } }
9+
10+
/** */ m!(); //~ WARN unused doc comment
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
warning: unused doc comment
2+
--> $DIR/unused-doc-comments.rs:10:1
3+
|
4+
LL | /** */ m!();
5+
| ^^^^^^ rustdoc does not generate documentation for macro invocations
6+
|
7+
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
8+
= note: `#[warn(unused_doc_comments)]` (part of `#[warn(unused)]`) on by default
9+
10+
warning: unused doc comment
11+
--> $DIR/unused-doc-comments.rs:4:10
12+
|
13+
LL | pub fn f</** */T>() {
14+
| ^^^^^^- rustdoc does not generate documentation for generic parameters
15+
|
16+
= help: use `/* */` for a plain comment
17+
18+
warning: unused doc comment
19+
--> $DIR/unused-doc-comments.rs:5:5
20+
|
21+
LL | /** */ let ();
22+
| ^^^^^^ ------- rustdoc does not generate documentation for statements
23+
|
24+
= help: use `/* */` for a plain comment
25+
26+
warning: 3 warnings emitted
27+

tests/ui/error-codes/E0152-duplicate-lang-items.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
//!
44
//! Issue: <https://github.com/rust-lang/rust/issues/31788>
55
6-
//@ normalize-stderr: "loaded from .*libstd-.*.rmeta" -> "loaded from SYSROOT/libstd-*.rmeta"
6+
//@ normalize-stderr: "loaded from \$.*libcore-.*.rmeta" -> "loaded from SYSROOT/libcore-*.rmeta"
77
//@ dont-require-annotations: NOTE
88

99
#![feature(lang_items)]
1010

11-
#[lang = "eh_personality"]
12-
fn personality() {
13-
//~^ ERROR: found duplicate lang item `eh_personality`
14-
//~| NOTE first defined in crate `std`
11+
#[lang = "panic_fmt"]
12+
fn panic_fmt() -> ! {
13+
//~^ ERROR: found duplicate lang item `panic_fmt`
14+
//~| NOTE first defined in crate `core`
1515
loop {}
1616
}
1717

tests/ui/error-codes/E0152-duplicate-lang-items.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
error[E0152]: found duplicate lang item `eh_personality`
1+
error[E0152]: found duplicate lang item `panic_fmt`
22
--> $DIR/E0152-duplicate-lang-items.rs:12:1
33
|
4-
LL | / fn personality() {
4+
LL | / fn panic_fmt() -> ! {
55
LL | |
66
LL | |
77
LL | | loop {}
88
LL | | }
99
| |_^
1010
|
11-
= note: the lang item is first defined in crate `std` (which `E0152_duplicate_lang_items` depends on)
12-
= note: first definition in `std` loaded from SYSROOT/libstd-*.rmeta
11+
= note: the lang item is first defined in crate `core` (which `std` depends on)
12+
= note: first definition in `core` loaded from SYSROOT/libcore-*.rmeta
1313
= note: second definition in the local crate (`E0152_duplicate_lang_items`)
1414

1515
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)