From 50d1efa3e2aa3c1e91f9f7869225897800ce1cce Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 19 Jun 2024 12:33:25 -0400 Subject: [PATCH] Add a test demonstrating the problem --- tests/ui/macros/auxiliary/expr_2021_implicit.rs | 9 +++++++++ tests/ui/macros/expr_2021_implicit_in_2024.rs | 10 ++++++++++ tests/ui/macros/expr_2021_implicit_in_2024.stderr | 10 ++++++++++ 3 files changed, 29 insertions(+) create mode 100644 tests/ui/macros/auxiliary/expr_2021_implicit.rs create mode 100644 tests/ui/macros/expr_2021_implicit_in_2024.rs create mode 100644 tests/ui/macros/expr_2021_implicit_in_2024.stderr 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 +