From 9f14e146ed7805c4190c0c71c28935103820f75f Mon Sep 17 00:00:00 2001 From: mark Date: Sat, 23 Mar 2019 21:58:55 -0500 Subject: [PATCH] deny duplicate matcher bindings by default --- src/librustc/lint/builtin.rs | 3 ++- .../ui/macros/macro-multiple-matcher-bindings.rs | 1 + .../macros/macro-multiple-matcher-bindings.stderr | 14 +++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index ad0ed39185c..10a5c1479fa 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -354,7 +354,7 @@ declare_lint! { declare_lint! { pub DUPLICATE_MATCHER_BINDING_NAME, - Warn, + Deny, "duplicate macro matcher binding name" } @@ -464,6 +464,7 @@ impl LintPass for HardwiredLints { DEPRECATED_IN_FUTURE, AMBIGUOUS_ASSOCIATED_ITEMS, NESTED_IMPL_TRAIT, + DUPLICATE_MATCHER_BINDING_NAME, ) } } diff --git a/src/test/ui/macros/macro-multiple-matcher-bindings.rs b/src/test/ui/macros/macro-multiple-matcher-bindings.rs index 9e0fa388716..23d566780c8 100644 --- a/src/test/ui/macros/macro-multiple-matcher-bindings.rs +++ b/src/test/ui/macros/macro-multiple-matcher-bindings.rs @@ -6,6 +6,7 @@ // compile-pass #![allow(unused_macros)] +#![warn(duplicate_matcher_binding_name)] macro_rules! foo1 { ($a:ident, $a:ident) => {}; //~WARNING duplicate matcher binding diff --git a/src/test/ui/macros/macro-multiple-matcher-bindings.stderr b/src/test/ui/macros/macro-multiple-matcher-bindings.stderr index 41e9a3286ae..f7970dbd2eb 100644 --- a/src/test/ui/macros/macro-multiple-matcher-bindings.stderr +++ b/src/test/ui/macros/macro-multiple-matcher-bindings.stderr @@ -1,15 +1,19 @@ warning: duplicate matcher binding - --> $DIR/macro-multiple-matcher-bindings.rs:11:6 + --> $DIR/macro-multiple-matcher-bindings.rs:12:6 | LL | ($a:ident, $a:ident) => {}; | ^^^^^^^^ ^^^^^^^^ | - = note: #[warn(duplicate_matcher_binding_name)] on by default +note: lint level defined here + --> $DIR/macro-multiple-matcher-bindings.rs:9:9 + | +LL | #![warn(duplicate_matcher_binding_name)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57593 warning: duplicate matcher binding - --> $DIR/macro-multiple-matcher-bindings.rs:12:6 + --> $DIR/macro-multiple-matcher-bindings.rs:13:6 | LL | ($a:ident, $a:path) => {}; | ^^^^^^^^ ^^^^^^^ @@ -18,7 +22,7 @@ LL | ($a:ident, $a:path) => {}; = note: for more information, see issue #57593 warning: duplicate matcher binding - --> $DIR/macro-multiple-matcher-bindings.rs:21:6 + --> $DIR/macro-multiple-matcher-bindings.rs:22:6 | LL | ($a:ident, $($a:ident),*) => {}; | ^^^^^^^^ ^^^^^^^^ @@ -27,7 +31,7 @@ LL | ($a:ident, $($a:ident),*) => {}; = note: for more information, see issue #57593 warning: duplicate matcher binding - --> $DIR/macro-multiple-matcher-bindings.rs:22:8 + --> $DIR/macro-multiple-matcher-bindings.rs:23:8 | LL | ($($a:ident)+ # $($($a:path),+);*) => {}; | ^^^^^^^^ ^^^^^^^