diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-06-23 14:07:32 +0000 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-06-24 22:04:55 +0000 |
| commit | 06db2104597b405a643c02307be68d1188a95f61 (patch) | |
| tree | 318099f0c92c10de8422f56239bb96214944691b /src | |
| parent | b6f3cb9502b1910f6af32f426fdb78e813b390ef (diff) | |
| download | rust-06db2104597b405a643c02307be68d1188a95f61.tar.gz rust-06db2104597b405a643c02307be68d1188a95f61.zip | |
Don't lint :pat when re-parsing a macro from another crate.
Diffstat (limited to 'src')
4 files changed, 23 insertions, 5 deletions
diff --git a/src/test/ui/macros/auxiliary/or-pattern.rs b/src/test/ui/macros/auxiliary/or-pattern.rs new file mode 100644 index 00000000000..a319c405eb6 --- /dev/null +++ b/src/test/ui/macros/auxiliary/or-pattern.rs @@ -0,0 +1,6 @@ +#![crate_type = "lib"] + +#[macro_export] +macro_rules! a { + ($x:pat|) => (); +} diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.fixed b/src/test/ui/macros/macro-or-patterns-back-compat.fixed index f4e81a6be2a..70425429278 100644 --- a/src/test/ui/macros/macro-or-patterns-back-compat.fixed +++ b/src/test/ui/macros/macro-or-patterns-back-compat.fixed @@ -1,14 +1,19 @@ // run-rustfix +// aux-build:or-pattern.rs #![deny(or_patterns_back_compat)] #![allow(unused_macros)] +#[macro_use] +extern crate or_pattern; + 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 //~| WARN this was previously accepted 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 //~| WARN this was previously accepted + macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok macro_rules! ogg { ($x:pat_param | $y:pat_param) => {} } @@ -30,4 +35,5 @@ 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); + a!(1|); } diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.rs b/src/test/ui/macros/macro-or-patterns-back-compat.rs index 49affdd38da..b19942a830e 100644 --- a/src/test/ui/macros/macro-or-patterns-back-compat.rs +++ b/src/test/ui/macros/macro-or-patterns-back-compat.rs @@ -1,14 +1,19 @@ // run-rustfix +// aux-build:or-pattern.rs #![deny(or_patterns_back_compat)] #![allow(unused_macros)] +#[macro_use] +extern crate or_pattern; + 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 //~| WARN this was previously accepted 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 //~| WARN this was previously accepted + macro_rules! baz { ($x:pat_param | $y:pat_param) => {} } // should be ok macro_rules! qux { ($x:pat_param | $y:pat) => {} } // should be ok macro_rules! ogg { ($x:pat | $y:pat_param) => {} } @@ -30,4 +35,5 @@ 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); + a!(1|); } diff --git a/src/test/ui/macros/macro-or-patterns-back-compat.stderr b/src/test/ui/macros/macro-or-patterns-back-compat.stderr index 62687eb36b8..4f5a450518f 100644 --- a/src/test/ui/macros/macro-or-patterns-back-compat.stderr +++ b/src/test/ui/macros/macro-or-patterns-back-compat.stderr @@ -1,11 +1,11 @@ error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro - --> $DIR/macro-or-patterns-back-compat.rs:6:21 + --> $DIR/macro-or-patterns-back-compat.rs:10:21 | LL | macro_rules! foo { ($x:pat | $y:pat) => {} } | ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param` | note: the lint level is defined here - --> $DIR/macro-or-patterns-back-compat.rs:3:9 + --> $DIR/macro-or-patterns-back-compat.rs:4:9 | LL | #![deny(or_patterns_back_compat)] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | #![deny(or_patterns_back_compat)] = note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869> error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro - --> $DIR/macro-or-patterns-back-compat.rs:9:23 + --> $DIR/macro-or-patterns-back-compat.rs:13:23 | LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } | ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param` @@ -22,7 +22,7 @@ LL | macro_rules! bar { ($($x:pat)+ | $($y:pat)+) => {} } = note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869> error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro - --> $DIR/macro-or-patterns-back-compat.rs:14:21 + --> $DIR/macro-or-patterns-back-compat.rs:19:21 | LL | macro_rules! ogg { ($x:pat | $y:pat_param) => {} } | ^^^^^^ help: use pat_param to preserve semantics: `$x:pat_param` @@ -31,7 +31,7 @@ LL | macro_rules! ogg { ($x:pat | $y:pat_param) => {} } = note: for more information, see issue #84869 <https://github.com/rust-lang/rust/issues/84869> error: the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro - --> $DIR/macro-or-patterns-back-compat.rs:18:26 + --> $DIR/macro-or-patterns-back-compat.rs:23:26 | LL | ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => { | ^^^^^^^^ help: use pat_param to preserve semantics: `$pat:pat_param` |
