Skip to content

Commit f9262af

Browse files
authored
Rollup merge of #59394 - mark-i-m:dup-matcher-bindings-2, r=Centril
warn -> deny duplicate match bindings This is the next step of #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 #59394 (comment)
2 parents 97927da + 9f14e14 commit f9262af

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/librustc/lint/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ declare_lint! {
354354

355355
declare_lint! {
356356
pub DUPLICATE_MATCHER_BINDING_NAME,
357-
Warn,
357+
Deny,
358358
"duplicate macro matcher binding name"
359359
}
360360

@@ -464,6 +464,7 @@ impl LintPass for HardwiredLints {
464464
DEPRECATED_IN_FUTURE,
465465
AMBIGUOUS_ASSOCIATED_ITEMS,
466466
NESTED_IMPL_TRAIT,
467+
DUPLICATE_MATCHER_BINDING_NAME,
467468
)
468469
}
469470
}

src/test/ui/macros/macro-multiple-matcher-bindings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// compile-pass
77

88
#![allow(unused_macros)]
9+
#![warn(duplicate_matcher_binding_name)]
910

1011
macro_rules! foo1 {
1112
($a:ident, $a:ident) => {}; //~WARNING duplicate matcher binding

src/test/ui/macros/macro-multiple-matcher-bindings.stderr

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
warning: duplicate matcher binding
2-
--> $DIR/macro-multiple-matcher-bindings.rs:11:6
2+
--> $DIR/macro-multiple-matcher-bindings.rs:12:6
33
|
44
LL | ($a:ident, $a:ident) => {};
55
| ^^^^^^^^ ^^^^^^^^
66
|
7-
= note: #[warn(duplicate_matcher_binding_name)] on by default
7+
note: lint level defined here
8+
--> $DIR/macro-multiple-matcher-bindings.rs:9:9
9+
|
10+
LL | #![warn(duplicate_matcher_binding_name)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
812
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
913
= note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
1014

1115
warning: duplicate matcher binding
12-
--> $DIR/macro-multiple-matcher-bindings.rs:12:6
16+
--> $DIR/macro-multiple-matcher-bindings.rs:13:6
1317
|
1418
LL | ($a:ident, $a:path) => {};
1519
| ^^^^^^^^ ^^^^^^^
@@ -18,7 +22,7 @@ LL | ($a:ident, $a:path) => {};
1822
= note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
1923

2024
warning: duplicate matcher binding
21-
--> $DIR/macro-multiple-matcher-bindings.rs:21:6
25+
--> $DIR/macro-multiple-matcher-bindings.rs:22:6
2226
|
2327
LL | ($a:ident, $($a:ident),*) => {};
2428
| ^^^^^^^^ ^^^^^^^^
@@ -27,7 +31,7 @@ LL | ($a:ident, $($a:ident),*) => {};
2731
= note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
2832

2933
warning: duplicate matcher binding
30-
--> $DIR/macro-multiple-matcher-bindings.rs:22:8
34+
--> $DIR/macro-multiple-matcher-bindings.rs:23:8
3135
|
3236
LL | ($($a:ident)+ # $($($a:path),+);*) => {};
3337
| ^^^^^^^^ ^^^^^^^

0 commit comments

Comments
 (0)