From d63e9257b9ff43506a4f697f552beb76963408a1 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 20 Jul 2018 00:53:56 -0700 Subject: [PATCH 1/4] Update clippy --- src/Cargo.lock | 20 ++++++++++---------- src/tools/clippy | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 8299dea1c4b0e..09baaeadaee43 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -44,7 +44,7 @@ dependencies = [ "html5ever 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -342,10 +342,10 @@ name = "clippy_lints" version = "0.0.212" dependencies = [ "cargo_metadata 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", - "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -887,14 +887,14 @@ name = "idna" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "if_chain" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1153,7 +1153,7 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2868,7 +2868,7 @@ name = "unicode-bidi" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2932,7 +2932,7 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "matches 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3123,7 +3123,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum html5ever 0.22.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b04478cf718862650a0bf66acaf8f2f8c906fbc703f35c916c1f4211b069a364" "checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -"checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" +"checksum if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec" "checksum ignore 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "787a5940ab88e0f2f3b2cad3687060bddcf67520f3b761abc31065c9c495d088" "checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053" "checksum isatty 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6c324313540cd4d7ba008d43dc6606a32a5579f13cc17b2804c13096f0a5c522" @@ -3148,7 +3148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" "checksum markup5ever 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfedc97d5a503e96816d10fedcd5b42f760b2e525ce2f7ec71f6a41780548475" -"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" +"checksum matches 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "835511bab37c34c47da5cb44844bea2cfde0236db0b506f90ea4224482c9774a" "checksum mdbook 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "90b5a8d7e341ceee5db3882a06078d42661ddcfa2b3687319cc5da76ec4e782f" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" diff --git a/src/tools/clippy b/src/tools/clippy index c05adc545cff4..1f656173723dc 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit c05adc545cff45449d40b1c72070ada7db5fc953 +Subproject commit 1f656173723dce4efc3fc90ff5763a2186ec9089 From b6e05476809a6bc58da03cf546c6a4d9ec58d8f2 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 20 Jul 2018 22:45:52 +0200 Subject: [PATCH 2/4] Allow individual lints to opt into being reported in external macros --- src/librustc/lint/builtin.rs | 6 ++++-- src/librustc/lint/mod.rs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index a46b312062247..430e06ecbdfbc 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -77,7 +77,8 @@ declare_lint! { declare_lint! { pub UNREACHABLE_CODE, Warn, - "detects unreachable code paths" + "detects unreachable code paths", + report_in_external_macro } declare_lint! { @@ -216,7 +217,8 @@ declare_lint! { declare_lint! { pub DEPRECATED, Warn, - "detects use of deprecated items" + "detects use of deprecated items", + report_in_external_macro } declare_lint! { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 8efce297a9117..6fa6c31c7421d 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -80,6 +80,9 @@ pub struct Lint { /// Starting at the given edition, default to the given lint level. If this is `None`, then use /// `default_level`. pub edition_lint_opts: Option<(Edition, Level)>, + + /// Whether this lint is reported even inside expansions of external macros + pub report_in_external_macro: bool, } impl Lint { @@ -100,11 +103,18 @@ impl Lint { #[macro_export] macro_rules! declare_lint { ($vis: vis $NAME: ident, $Level: ident, $desc: expr) => ( + declare_lint!{$vis $NAME, $Level, $desc, false} + ); + ($vis: vis $NAME: ident, $Level: ident, $desc: expr, report_in_external_macro) => ( + declare_lint!{$vis $NAME, $Level, $desc, true} + ); + ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $external: expr) => ( $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { name: stringify!($NAME), default_level: $crate::lint::$Level, desc: $desc, edition_lint_opts: None, + report_in_external_macro: $external, }; ); ($vis: vis $NAME: ident, $Level: ident, $desc: expr, @@ -115,6 +125,7 @@ macro_rules! declare_lint { default_level: $crate::lint::$Level, desc: $desc, edition_lint_opts: Some(($lint_edition, $crate::lint::Level::$edition_level)), + report_in_external_macro: false, }; ); } @@ -583,8 +594,7 @@ pub fn struct_lint_level<'a>(sess: &'a Session, // items to take care of (delete the macro invocation). As a result we have // a few lints we whitelist here for allowing a lint even though it's in a // foreign macro invocation. - } else if lint_id != LintId::of(builtin::UNREACHABLE_CODE) && - lint_id != LintId::of(builtin::DEPRECATED) { + } else if !lint.report_in_external_macro { if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) { err.cancel(); } From d3c1e2fb7c3d74098efaf4399f50907e82693450 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 20 Jul 2018 22:50:32 +0200 Subject: [PATCH 3/4] Clippy opts out of in_external_macro --- src/tools/clippy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy b/src/tools/clippy index 1f656173723dc..2fa85d86e0cbd 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 1f656173723dce4efc3fc90ff5763a2186ec9089 +Subproject commit 2fa85d86e0cbd5fc0c17d1cbcca2005454b86cd4 From 2f7edccb036ee4c6a63664b622d9355ef594979f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Sat, 21 Jul 2018 12:36:18 +0200 Subject: [PATCH 4/4] Don't invent new magic keywords --- src/librustc/lint/builtin.rs | 4 ++-- src/librustc/lint/mod.rs | 4 ++-- src/tools/clippy | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 430e06ecbdfbc..0ab10bf223f07 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -78,7 +78,7 @@ declare_lint! { pub UNREACHABLE_CODE, Warn, "detects unreachable code paths", - report_in_external_macro + report_in_external_macro: true } declare_lint! { @@ -218,7 +218,7 @@ declare_lint! { pub DEPRECATED, Warn, "detects use of deprecated items", - report_in_external_macro + report_in_external_macro: true } declare_lint! { diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 6fa6c31c7421d..8161dcf675da7 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -105,8 +105,8 @@ macro_rules! declare_lint { ($vis: vis $NAME: ident, $Level: ident, $desc: expr) => ( declare_lint!{$vis $NAME, $Level, $desc, false} ); - ($vis: vis $NAME: ident, $Level: ident, $desc: expr, report_in_external_macro) => ( - declare_lint!{$vis $NAME, $Level, $desc, true} + ($vis: vis $NAME: ident, $Level: ident, $desc: expr, report_in_external_macro: $rep: expr) => ( + declare_lint!{$vis $NAME, $Level, $desc, $rep} ); ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $external: expr) => ( $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { diff --git a/src/tools/clippy b/src/tools/clippy index 2fa85d86e0cbd..8085ed733fefe 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 2fa85d86e0cbd5fc0c17d1cbcca2005454b86cd4 +Subproject commit 8085ed733fefeaf37aca0a39da93344326de5d57