Skip to content

Commit 3ee78b3

Browse files
authored
Rollup merge of #86192 - hi-rustin:rustin-patch-lint, r=nikomatsakis
Make OR_PATTERNS_BACK_COMPAT be a 2021 future-incompatible lint close #84869 r? `@nikomatsakis`
2 parents 9d93819 + 0fdd6cc commit 3ee78b3

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+4
Original file line numberDiff line numberDiff line change
@@ -3239,4 +3239,8 @@ declare_lint! {
32393239
pub OR_PATTERNS_BACK_COMPAT,
32403240
Allow,
32413241
"detects usage of old versions of or-patterns",
3242+
@future_incompatible = FutureIncompatibleInfo {
3243+
reference: "issue #84869 <https://github.com/rust-lang/rust/issues/84869>",
3244+
edition: Some(Edition::Edition2021),
3245+
};
32423246
}

src/test/ui/macros/macro-or-patterns-back-compat.fixed

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
#![deny(or_patterns_back_compat)]
44
#![allow(unused_macros)]
5-
macro_rules! foo { ($x:pat_param | $y:pat) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
6-
macro_rules! bar { ($($x:pat_param)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
5+
6+
macro_rules! foo { ($x:pat_param | $y:pat) => {} }
7+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
8+
//~| WARN this was previously accepted
9+
macro_rules! bar { ($($x:pat_param)+ | $($y:pat)+) => {} }
10+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
11+
//~| WARN this was previously accepted
712
macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
813
macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
9-
macro_rules! ogg { ($x:pat_param | $y:pat_param) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
14+
macro_rules! ogg { ($x:pat_param | $y:pat_param) => {} }
15+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
16+
//~| WARN this was previously accepted
1017
macro_rules! match_any {
11-
( $expr:expr , $( $( $pat:pat_param )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
18+
( $expr:expr , $( $( $pat:pat_param )|+ => $expr_arm:expr ),+ ) => {
19+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
20+
//~| WARN this was previously accepted
1221
match $expr {
1322
$(
1423
$( $pat => $expr_arm, )+

src/test/ui/macros/macro-or-patterns-back-compat.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22

33
#![deny(or_patterns_back_compat)]
44
#![allow(unused_macros)]
5-
macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
6-
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
5+
6+
macro_rules! foo { ($x:pat | $y:pat) => {} }
7+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
8+
//~| WARN this was previously accepted
9+
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
10+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
11+
//~| WARN this was previously accepted
712
macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok
813
macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok
9-
macro_rules! ogg { ($x:pat | $y:pat_param) => {} } //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
14+
macro_rules! ogg { ($x:pat | $y:pat_param) => {} }
15+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
16+
//~| WARN this was previously accepted
1017
macro_rules! match_any {
11-
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
18+
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
19+
//~^ ERROR the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
20+
//~| WARN this was previously accepted
1221
match $expr {
1322
$(
1423
$( $pat => $expr_arm, )+
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
2-
--> $DIR/macro-or-patterns-back-compat.rs:5:21
2+
--> $DIR/macro-or-patterns-back-compat.rs:6:21
33
|
44
LL | macro_rules! foo { ($x:pat | $y:pat) => {} }
55
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
@@ -9,24 +9,35 @@ note: the lint level is defined here
99
|
1010
LL | #![deny(or_patterns_back_compat)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
13+
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
1214

1315
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
14-
--> $DIR/macro-or-patterns-back-compat.rs:6:23
16+
--> $DIR/macro-or-patterns-back-compat.rs:9:23
1517
|
1618
LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} }
1719
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
20+
|
21+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
22+
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
1823

1924
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
20-
--> $DIR/macro-or-patterns-back-compat.rs:9:21
25+
--> $DIR/macro-or-patterns-back-compat.rs:14:21
2126
|
2227
LL | macro_rules! ogg { ($x:pat | $y:pat_param) => {} }
2328
| ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param`
29+
|
30+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
31+
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
2432

2533
error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
26-
--> $DIR/macro-or-patterns-back-compat.rs:11:26
34+
--> $DIR/macro-or-patterns-back-compat.rs:18:26
2735
|
2836
LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
2937
| ^^^^^^^^ help: use pat_param to preserve semantics: `$pat:pat_param`
38+
|
39+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
40+
= note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869>
3041

3142
error: aborting due to 4 previous errors
3243

0 commit comments

Comments
 (0)