about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-06-19 12:33:25 -0400
committerMichael Goulet <michael@errs.io>2024-06-19 12:37:32 -0400
commit50d1efa3e2aa3c1e91f9f7869225897800ce1cce (patch)
tree07a58fcec036fd642ca786ff1266d9f72c5f70a8
parent894f7a4ba6554d3797404bbf550d9919df060b97 (diff)
downloadrust-50d1efa3e2aa3c1e91f9f7869225897800ce1cce.tar.gz
rust-50d1efa3e2aa3c1e91f9f7869225897800ce1cce.zip
Add a test demonstrating the problem
-rw-r--r--tests/ui/macros/auxiliary/expr_2021_implicit.rs9
-rw-r--r--tests/ui/macros/expr_2021_implicit_in_2024.rs10
-rw-r--r--tests/ui/macros/expr_2021_implicit_in_2024.stderr10
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
+