forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#83468 - hi-rustin:rustin-patch-lint, r=niko…
…matsakis add OR_PATTERNS_BACK_COMPAT lint close rust-lang#83318
- Loading branch information
Showing
7 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ignore-tidy-linelength | ||
// run-rustfix | ||
|
||
#![feature(edition_macro_pats)] | ||
#![deny(or_patterns_back_compat)] | ||
#![allow(unused_macros)] | ||
macro_rules! foo { ($x:pat2015 | $y:pat) => {} } //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
macro_rules! bar { ($($x:pat2015)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok | ||
macro_rules! qux { ($x:pat2015 | $y:pat) => {} } // should be ok | ||
macro_rules! ogg { ($x:pat2015 | $y:pat2015) => {} } //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
macro_rules! match_any { | ||
( $expr:expr , $( $( $pat:pat2015 )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
match $expr { | ||
$( | ||
$( $pat => $expr_arm, )+ | ||
)+ | ||
} | ||
}; | ||
} | ||
|
||
fn main() { | ||
let result: Result<i64, i32> = Err(42); | ||
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into()); | ||
assert_eq!(int, 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ignore-tidy-linelength | ||
// run-rustfix | ||
|
||
#![feature(edition_macro_pats)] | ||
#![deny(or_patterns_back_compat)] | ||
#![allow(unused_macros)] | ||
macro_rules! foo { ($x:pat | $y:pat) => {} } //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
macro_rules! baz { ($x:pat2015 | $y:pat2015) => {} } // should be ok | ||
macro_rules! qux { ($x:pat2015 | $y:pat) => {} } // should be ok | ||
macro_rules! ogg { ($x:pat | $y:pat2015) => {} } //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
macro_rules! match_any { | ||
( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { //~ ERROR the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
match $expr { | ||
$( | ||
$( $pat => $expr_arm, )+ | ||
)+ | ||
} | ||
}; | ||
} | ||
|
||
fn main() { | ||
let result: Result<i64, i32> = Err(42); | ||
let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into()); | ||
assert_eq!(int, 42); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error: the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
--> $DIR/macro-or-patterns-back-compat.rs:7:21 | ||
| | ||
LL | macro_rules! foo { ($x:pat | $y:pat) => {} } | ||
| ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/macro-or-patterns-back-compat.rs:5:9 | ||
| | ||
LL | #![deny(or_patterns_back_compat)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
--> $DIR/macro-or-patterns-back-compat.rs:8:23 | ||
| | ||
LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } | ||
| ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015` | ||
|
||
error: the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
--> $DIR/macro-or-patterns-back-compat.rs:11:21 | ||
| | ||
LL | macro_rules! ogg { ($x:pat | $y:pat2015) => {} } | ||
| ^^^^^^ help: use pat2015 to preserve semantics: `$x:pat2015` | ||
|
||
error: the meaning of the pat fragment specific is changing in Rust 2021, which may affect this macro | ||
--> $DIR/macro-or-patterns-back-compat.rs:13:26 | ||
| | ||
LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { | ||
| ^^^^^^^^ help: use pat2015 to preserve semantics: `$pat:pat2015` | ||
|
||
error: aborting due to 4 previous errors | ||
|