diff options
| -rw-r--r-- | tests/ui/macros/auxiliary/expr_2021_implicit.rs | 9 | ||||
| -rw-r--r-- | tests/ui/macros/expr_2021_implicit_in_2024.rs | 10 | ||||
| -rw-r--r-- | tests/ui/macros/expr_2021_implicit_in_2024.stderr | 10 |
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/ui/macros/auxiliary/expr_2021_implicit.rs b/tests/ui/macros/auxiliary/expr_2021_implicit.rs new file mode 100644 index 00000000000..61762e41dee --- /dev/null +++ b/tests/ui/macros/auxiliary/expr_2021_implicit.rs @@ -0,0 +1,9 @@ +//@ edition:2021 + +#[macro_export] +macro_rules! m { + ($expr:expr) => { + compile_error!("did not expect an expression to be parsed"); + }; + (const { }) => {}; +} diff --git a/tests/ui/macros/expr_2021_implicit_in_2024.rs b/tests/ui/macros/expr_2021_implicit_in_2024.rs new file mode 100644 index 00000000000..d612c03650d --- /dev/null +++ b/tests/ui/macros/expr_2021_implicit_in_2024.rs @@ -0,0 +1,10 @@ +//@ compile-flags: --edition=2024 -Zunstable-options +//@ aux-build:expr_2021_implicit.rs + +extern crate expr_2021_implicit; + +// Makes sure that a `:expr` fragment matcher defined in a edition 2021 crate +// still parses like an `expr_2021` fragment matcher in a 2024 user crate. +expr_2021_implicit::m!(const {}); + +fn main() {} diff --git a/tests/ui/macros/expr_2021_implicit_in_2024.stderr b/tests/ui/macros/expr_2021_implicit_in_2024.stderr new file mode 100644 index 00000000000..962d572ca07 --- /dev/null +++ b/tests/ui/macros/expr_2021_implicit_in_2024.stderr @@ -0,0 +1,10 @@ +error: did not expect an expression to be parsed + --> $DIR/expr_2021_implicit_in_2024.rs:8:1 + | +LL | expr_2021_implicit::m!(const {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `expr_2021_implicit::m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + |
