From 17eb64a8b88849282fb9f8b09452b7f2878ca82d Mon Sep 17 00:00:00 2001 From: dylan_DPC Date: Tue, 21 Aug 2018 16:29:08 +0530 Subject: [PATCH 1/4] add macro check for lint --- src/librustc_lint/builtin.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index e6aa7c0d16c6a..aa010af9758bc 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -283,7 +283,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { declare_lint! { pub MISSING_DOCS, Allow, - "detects missing documentation for public members" + "detects missing documentation for public members", + report_in_external_macro: true } pub struct MissingDoc { From a6201f9a2b5c855a6747a8cecdf2f4830ac63f6e Mon Sep 17 00:00:00 2001 From: dylan_DPC Date: Wed, 22 Aug 2018 01:13:24 +0530 Subject: [PATCH 2/4] add testcase to existing macro testcase --- src/test/ui/lint/lints-in-foreign-macros.rs | 1 + .../ui/lint/lints-in-foreign-macros.stderr | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/test/ui/lint/lints-in-foreign-macros.rs b/src/test/ui/lint/lints-in-foreign-macros.rs index 0f9003877cc06..34c15b15378de 100644 --- a/src/test/ui/lint/lints-in-foreign-macros.rs +++ b/src/test/ui/lint/lints-in-foreign-macros.rs @@ -12,6 +12,7 @@ // compile-pass #![warn(unused_imports)] +#![warn(missing_docs)] //~ WARN: missing documentation for crate [missing_docs] #[macro_use] extern crate lints_in_foreign_macros; diff --git a/src/test/ui/lint/lints-in-foreign-macros.stderr b/src/test/ui/lint/lints-in-foreign-macros.stderr index e9f6d3d381541..e2df883cd4a73 100644 --- a/src/test/ui/lint/lints-in-foreign-macros.stderr +++ b/src/test/ui/lint/lints-in-foreign-macros.stderr @@ -1,5 +1,5 @@ warning: unused import: `std::string::ToString` - --> $DIR/lints-in-foreign-macros.rs:20:16 + --> $DIR/lints-in-foreign-macros.rs:21:16 | LL | () => {use std::string::ToString;} //~ WARN: unused import | ^^^^^^^^^^^^^^^^^^^^^ @@ -14,14 +14,32 @@ LL | #![warn(unused_imports)] | ^^^^^^^^^^^^^^ warning: unused import: `std::string::ToString` - --> $DIR/lints-in-foreign-macros.rs:25:18 + --> $DIR/lints-in-foreign-macros.rs:26:18 | LL | mod c { baz!(use std::string::ToString;); } //~ WARN: unused import | ^^^^^^^^^^^^^^^^^^^^^ warning: unused import: `std::string::ToString` - --> $DIR/lints-in-foreign-macros.rs:26:19 + --> $DIR/lints-in-foreign-macros.rs:27:19 | LL | mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import | ^^^^^^^^^^^^^^^^^^^^^ +warning: missing documentation for crate + --> $DIR/lints-in-foreign-macros.rs:14:1 + | +LL | / #![warn(unused_imports)] +LL | | #![warn(missing_docs)] //~ WARN: missing documentation for crate [missing_docs] +LL | | +LL | | #[macro_use] +... | +LL | | +LL | | fn main() {} + | |____________^ + | +note: lint level defined here + --> $DIR/lints-in-foreign-macros.rs:15:9 + | +LL | #![warn(missing_docs)] //~ WARN: missing documentation for crate [missing_docs] + | ^^^^^^^^^^^^ + From 8fbcb9c53c208f5482959474b44605935d797ccf Mon Sep 17 00:00:00 2001 From: dylan_DPC Date: Thu, 23 Aug 2018 01:56:39 +0530 Subject: [PATCH 3/4] add warning for missing docs --- src/test/ui/lint/lints-in-foreign-macros.rs | 3 ++- src/test/ui/lint/lints-in-foreign-macros.stderr | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/ui/lint/lints-in-foreign-macros.rs b/src/test/ui/lint/lints-in-foreign-macros.rs index 34c15b15378de..2ad1cfe71682c 100644 --- a/src/test/ui/lint/lints-in-foreign-macros.rs +++ b/src/test/ui/lint/lints-in-foreign-macros.rs @@ -12,7 +12,7 @@ // compile-pass #![warn(unused_imports)] -#![warn(missing_docs)] //~ WARN: missing documentation for crate [missing_docs] +#![warn(missing_docs)] #[macro_use] extern crate lints_in_foreign_macros; @@ -25,5 +25,6 @@ mod a { foo!(); } mod b { bar!(); } mod c { baz!(use std::string::ToString;); } //~ WARN: unused import mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import +mod e { baz!(pub fn undocumented() {}); }//~ WARN: missing documentation for a function fn main() {} diff --git a/src/test/ui/lint/lints-in-foreign-macros.stderr b/src/test/ui/lint/lints-in-foreign-macros.stderr index e2df883cd4a73..4a75e1d907dc8 100644 --- a/src/test/ui/lint/lints-in-foreign-macros.stderr +++ b/src/test/ui/lint/lints-in-foreign-macros.stderr @@ -29,17 +29,17 @@ warning: missing documentation for crate --> $DIR/lints-in-foreign-macros.rs:14:1 | LL | / #![warn(unused_imports)] -LL | | #![warn(missing_docs)] //~ WARN: missing documentation for crate [missing_docs] +LL | | #![warn(missing_docs)] LL | | LL | | #[macro_use] ... | LL | | -LL | | fn main() {} +LL | | fn main() {} //~ WARN: missing documentation for crate [missing_docs] | |____________^ | note: lint level defined here --> $DIR/lints-in-foreign-macros.rs:15:9 | -LL | #![warn(missing_docs)] //~ WARN: missing documentation for crate [missing_docs] +LL | #![warn(missing_docs)] | ^^^^^^^^^^^^ From 747722e44445bfb067bfbc84540c434170d538e8 Mon Sep 17 00:00:00 2001 From: dylan_DPC Date: Thu, 23 Aug 2018 23:21:54 +0530 Subject: [PATCH 4/4] fix testcase --- src/test/ui/lint/lints-in-foreign-macros.rs | 5 +++-- .../ui/lint/lints-in-foreign-macros.stderr | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/test/ui/lint/lints-in-foreign-macros.rs b/src/test/ui/lint/lints-in-foreign-macros.rs index 2ad1cfe71682c..3785968df871a 100644 --- a/src/test/ui/lint/lints-in-foreign-macros.rs +++ b/src/test/ui/lint/lints-in-foreign-macros.rs @@ -11,7 +11,7 @@ // aux-build:lints-in-foreign-macros.rs // compile-pass -#![warn(unused_imports)] +#![warn(unused_imports)] //~ missing documentation for crate [missing_docs] #![warn(missing_docs)] #[macro_use] @@ -25,6 +25,7 @@ mod a { foo!(); } mod b { bar!(); } mod c { baz!(use std::string::ToString;); } //~ WARN: unused import mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import -mod e { baz!(pub fn undocumented() {}); }//~ WARN: missing documentation for a function +baz!(pub fn undocumented() {}); //~ WARN: missing documentation for a function +baz2!(pub fn undocumented2() {}); //~ WARN: missing documentation for a function fn main() {} diff --git a/src/test/ui/lint/lints-in-foreign-macros.stderr b/src/test/ui/lint/lints-in-foreign-macros.stderr index 4a75e1d907dc8..2ddca7781231f 100644 --- a/src/test/ui/lint/lints-in-foreign-macros.stderr +++ b/src/test/ui/lint/lints-in-foreign-macros.stderr @@ -10,7 +10,7 @@ LL | mod a { foo!(); } note: lint level defined here --> $DIR/lints-in-foreign-macros.rs:14:9 | -LL | #![warn(unused_imports)] +LL | #![warn(unused_imports)] //~ missing documentation for crate [missing_docs] | ^^^^^^^^^^^^^^ warning: unused import: `std::string::ToString` @@ -28,13 +28,13 @@ LL | mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import warning: missing documentation for crate --> $DIR/lints-in-foreign-macros.rs:14:1 | -LL | / #![warn(unused_imports)] +LL | / #![warn(unused_imports)] //~ missing documentation for crate [missing_docs] LL | | #![warn(missing_docs)] LL | | LL | | #[macro_use] ... | LL | | -LL | | fn main() {} //~ WARN: missing documentation for crate [missing_docs] +LL | | fn main() {} | |____________^ | note: lint level defined here @@ -43,3 +43,15 @@ note: lint level defined here LL | #![warn(missing_docs)] | ^^^^^^^^^^^^ +warning: missing documentation for a function + --> $DIR/lints-in-foreign-macros.rs:28:6 + | +LL | baz!(pub fn undocumented() {}); //~ WARN: missing documentation for a function + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: missing documentation for a function + --> $DIR/lints-in-foreign-macros.rs:29:7 + | +LL | baz2!(pub fn undocumented2() {}); //~ WARN: missing documentation for a function + | ^^^^^^^^^^^^^^^^^^^^^^ +