Skip to content

Commit 7f396ba

Browse files
authored
Rollup merge of rust-lang#53559 - Dylan-DPC:fix/missing-doc-lint, r=kennytm
add macro check for lint Fixes rust-lang#53537
2 parents 973428d + 747722e commit 7f396ba

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

src/librustc_lint/builtin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode {
295295
declare_lint! {
296296
pub MISSING_DOCS,
297297
Allow,
298-
"detects missing documentation for public members"
298+
"detects missing documentation for public members",
299+
report_in_external_macro: true
299300
}
300301

301302
pub struct MissingDoc {

src/test/ui/lint/lints-in-foreign-macros.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// aux-build:lints-in-foreign-macros.rs
1212
// compile-pass
1313

14-
#![warn(unused_imports)]
14+
#![warn(unused_imports)] //~ missing documentation for crate [missing_docs]
15+
#![warn(missing_docs)]
1516

1617
#[macro_use]
1718
extern crate lints_in_foreign_macros;
@@ -24,5 +25,7 @@ mod a { foo!(); }
2425
mod b { bar!(); }
2526
mod c { baz!(use std::string::ToString;); } //~ WARN: unused import
2627
mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import
28+
baz!(pub fn undocumented() {}); //~ WARN: missing documentation for a function
29+
baz2!(pub fn undocumented2() {}); //~ WARN: missing documentation for a function
2730

2831
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: unused import: `std::string::ToString`
2-
--> $DIR/lints-in-foreign-macros.rs:20:16
2+
--> $DIR/lints-in-foreign-macros.rs:21:16
33
|
44
LL | () => {use std::string::ToString;} //~ WARN: unused import
55
| ^^^^^^^^^^^^^^^^^^^^^
@@ -10,18 +10,48 @@ LL | mod a { foo!(); }
1010
note: lint level defined here
1111
--> $DIR/lints-in-foreign-macros.rs:14:9
1212
|
13-
LL | #![warn(unused_imports)]
13+
LL | #![warn(unused_imports)] //~ missing documentation for crate [missing_docs]
1414
| ^^^^^^^^^^^^^^
1515

1616
warning: unused import: `std::string::ToString`
17-
--> $DIR/lints-in-foreign-macros.rs:25:18
17+
--> $DIR/lints-in-foreign-macros.rs:26:18
1818
|
1919
LL | mod c { baz!(use std::string::ToString;); } //~ WARN: unused import
2020
| ^^^^^^^^^^^^^^^^^^^^^
2121

2222
warning: unused import: `std::string::ToString`
23-
--> $DIR/lints-in-foreign-macros.rs:26:19
23+
--> $DIR/lints-in-foreign-macros.rs:27:19
2424
|
2525
LL | mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import
2626
| ^^^^^^^^^^^^^^^^^^^^^
2727

28+
warning: missing documentation for crate
29+
--> $DIR/lints-in-foreign-macros.rs:14:1
30+
|
31+
LL | / #![warn(unused_imports)] //~ missing documentation for crate [missing_docs]
32+
LL | | #![warn(missing_docs)]
33+
LL | |
34+
LL | | #[macro_use]
35+
... |
36+
LL | |
37+
LL | | fn main() {}
38+
| |____________^
39+
|
40+
note: lint level defined here
41+
--> $DIR/lints-in-foreign-macros.rs:15:9
42+
|
43+
LL | #![warn(missing_docs)]
44+
| ^^^^^^^^^^^^
45+
46+
warning: missing documentation for a function
47+
--> $DIR/lints-in-foreign-macros.rs:28:6
48+
|
49+
LL | baz!(pub fn undocumented() {}); //~ WARN: missing documentation for a function
50+
| ^^^^^^^^^^^^^^^^^^^^^
51+
52+
warning: missing documentation for a function
53+
--> $DIR/lints-in-foreign-macros.rs:29:7
54+
|
55+
LL | baz2!(pub fn undocumented2() {}); //~ WARN: missing documentation for a function
56+
| ^^^^^^^^^^^^^^^^^^^^^^
57+

0 commit comments

Comments
 (0)