Skip to content

Commit

Permalink
deny duplicate matcher bindings by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-i-m committed Mar 28, 2019
1 parent 237bf32 commit 9f14e14
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ declare_lint! {

declare_lint! {
pub DUPLICATE_MATCHER_BINDING_NAME,
Warn,
Deny,
"duplicate macro matcher binding name"
}

Expand Down Expand Up @@ -464,6 +464,7 @@ impl LintPass for HardwiredLints {
DEPRECATED_IN_FUTURE,
AMBIGUOUS_ASSOCIATED_ITEMS,
NESTED_IMPL_TRAIT,
DUPLICATE_MATCHER_BINDING_NAME,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/macros/macro-multiple-matcher-bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/test/ui/macros/macro-multiple-matcher-bindings.stderr
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/rust-lang/rust/issues/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) => {};
| ^^^^^^^^ ^^^^^^^
Expand All @@ -18,7 +22,7 @@ LL | ($a:ident, $a:path) => {};
= note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/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),*) => {};
| ^^^^^^^^ ^^^^^^^^
Expand All @@ -27,7 +31,7 @@ LL | ($a:ident, $($a:ident),*) => {};
= note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/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),+);*) => {};
| ^^^^^^^^ ^^^^^^^
Expand Down

0 comments on commit 9f14e14

Please sign in to comment.