Skip to content

Commit bcd7e2b

Browse files
committed
rustc_lint: Move unused_doc_comments from pre-expansion to early lints
1 parent 19288dd commit bcd7e2b

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

src/librustc_lint/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn lint_mod(tcx: TyCtxt<'_>, module_def_id: DefId) {
9494

9595
macro_rules! pre_expansion_lint_passes {
9696
($macro:path, $args:tt) => {
97-
$macro!($args, [KeywordIdents: KeywordIdents, UnusedDocComment: UnusedDocComment,]);
97+
$macro!($args, [KeywordIdents: KeywordIdents,]);
9898
};
9999
}
100100

@@ -114,6 +114,7 @@ macro_rules! early_lint_passes {
114114
NonAsciiIdents: NonAsciiIdents,
115115
IncompleteFeatures: IncompleteFeatures,
116116
RedundantSemicolon: RedundantSemicolon,
117+
UnusedDocComment: UnusedDocComment,
117118
]
118119
);
119120
};

src/test/ui/useless-comment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ macro_rules! mac {
66
() => {}
77
}
88

9-
/// foo //~ ERROR unused doc comment
9+
/// foo //FIXME ERROR unused doc comment
1010
mac!();
1111

1212
fn foo() {
@@ -29,7 +29,7 @@ fn foo() {
2929
#[doc = "bar"] //~ ERROR unused doc comment
3030
3;
3131

32-
/// bar //~ ERROR unused doc comment
32+
/// bar //FIXME ERROR unused doc comment
3333
mac!();
3434

3535
let x = /** comment */ 47; //~ ERROR unused doc comment

src/test/ui/useless-comment.stderr

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
error: unused doc comment
2-
--> $DIR/useless-comment.rs:9:1
2+
--> $DIR/useless-comment.rs:13:5
33
|
4-
LL | /// foo
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
LL | mac!();
7-
| ------- rustdoc does not generate documentation for macro expansions
4+
LL | /// a
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
LL | let x = 12;
7+
| ----------- rustdoc does not generate documentation for statements
88
|
99
note: the lint level is defined here
1010
--> $DIR/useless-comment.rs:3:9
1111
|
1212
LL | #![deny(unused_doc_comments)]
1313
| ^^^^^^^^^^^^^^^^^^^
14-
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
15-
16-
error: unused doc comment
17-
--> $DIR/useless-comment.rs:13:5
18-
|
19-
LL | /// a
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21-
LL | let x = 12;
22-
| ----------- rustdoc does not generate documentation for statements
2314

2415
error: unused doc comment
2516
--> $DIR/useless-comment.rs:16:5
@@ -68,16 +59,6 @@ LL | #[doc = "bar"]
6859
LL | 3;
6960
| - rustdoc does not generate documentation for expressions
7061

71-
error: unused doc comment
72-
--> $DIR/useless-comment.rs:32:5
73-
|
74-
LL | /// bar
75-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76-
LL | mac!();
77-
| ------- rustdoc does not generate documentation for macro expansions
78-
|
79-
= help: to document an item produced by a macro, the macro must produce the documentation as part of its expansion
80-
8162
error: unused doc comment
8263
--> $DIR/useless-comment.rs:35:13
8364
|
@@ -94,5 +75,5 @@ LL | |
9475
LL | | }
9576
| |_____- rustdoc does not generate documentation for expressions
9677

97-
error: aborting due to 10 previous errors
78+
error: aborting due to 8 previous errors
9879

0 commit comments

Comments
 (0)