Skip to content

Commit

Permalink
Rollup merge of rust-lang#59394 - mark-i-m:dup-matcher-bindings-2, r=…
Browse files Browse the repository at this point in the history
…Centril

warn -> deny duplicate match bindings

This is the next step of rust-lang#57742

r? @Centril

- [x] Decide whether to go to deny-by-default or hard error.
     - My preference is to make this deny-by-default, rather than going straight to a hard error. The CI should fail because I haven't updated the ui test yet. I'll update it when we decide which to do.
- [x] Update [test](https://github.com/mark-i-m/rust/blob/c25d6b83441e0c060ee0273193ef27b29e1318cd/src/test/ui/macros/macro-multiple-matcher-bindings.rs)
- [ ] ~Crater run~ see rust-lang#59394 (comment)
  • Loading branch information
Centril authored Mar 29, 2019
2 parents 97927da + 9f14e14 commit f9262af
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 f9262af

Please sign in to comment.