about summary refs log tree commit diff
path: root/tests/ui/macros
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2024-09-04 17:15:13 -0700
committerVincenzo Palazzo <vincenzopalazzodev@gmail.com>2024-10-01 07:51:58 +0000
commitc7cd55f7c5032c646db22f144dda2f04d8ee6009 (patch)
tree1b13d74b42484ebea281f702dc73f11d1c61b28c /tests/ui/macros
parentf79ef02e4bc87eb6dc8374cd4bde8e86f9695cf9 (diff)
downloadrust-c7cd55f7c5032c646db22f144dda2f04d8ee6009.tar.gz
rust-c7cd55f7c5032c646db22f144dda2f04d8ee6009.zip
Stabilize expr_2021 fragment in all editions
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Diffstat (limited to 'tests/ui/macros')
-rw-r--r--tests/ui/macros/expr_2021.rs14
-rw-r--r--tests/ui/macros/expr_2021_cargo_fix_edition.fixed2
-rw-r--r--tests/ui/macros/expr_2021_cargo_fix_edition.rs2
-rw-r--r--tests/ui/macros/expr_2021_cargo_fix_edition.stderr6
-rw-r--r--tests/ui/macros/expr_2021_inline_const.edi2021.stderr8
-rw-r--r--tests/ui/macros/expr_2021_inline_const.edi2024.stderr4
-rw-r--r--tests/ui/macros/expr_2021_inline_const.rs3
-rw-r--r--tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr8
-rw-r--r--tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr4
-rw-r--r--tests/ui/macros/expr_2024_underscore_expr.rs3
-rw-r--r--tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs11
-rw-r--r--tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr13
-rw-r--r--tests/ui/macros/invalid-fragment-specifier.stderr4
-rw-r--r--tests/ui/macros/issue-21356.stderr2
-rw-r--r--tests/ui/macros/macro-missing-fragment.e2024.stderr6
-rw-r--r--tests/ui/macros/metavar_cross_edition_recursive_macros.rs1
16 files changed, 35 insertions, 56 deletions
diff --git a/tests/ui/macros/expr_2021.rs b/tests/ui/macros/expr_2021.rs
new file mode 100644
index 00000000000..8a274e77533
--- /dev/null
+++ b/tests/ui/macros/expr_2021.rs
@@ -0,0 +1,14 @@
+//@ check-pass
+//@ edition: 2015
+
+// Ensures expr_2021 fragment specifier is accepted in old editions
+
+macro_rules! my_macro {
+    ($x:expr_2021) => {
+        println!("Hello, {}!", $x);
+    };
+}
+
+fn main() {
+    my_macro!("world");
+}
diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.fixed b/tests/ui/macros/expr_2021_cargo_fix_edition.fixed
index 1becd8a92d6..061a4b98033 100644
--- a/tests/ui/macros/expr_2021_cargo_fix_edition.fixed
+++ b/tests/ui/macros/expr_2021_cargo_fix_edition.fixed
@@ -1,8 +1,6 @@
 //@ run-rustfix
 //@ check-pass
 //@ compile-flags: --edition=2021
-#![allow(incomplete_features)]
-#![feature(expr_fragment_specifier_2024)]
 #![warn(edition_2024_expr_fragment_specifier)]
 
 macro_rules! m {
diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.rs b/tests/ui/macros/expr_2021_cargo_fix_edition.rs
index ec0b86d2c23..cd9cd965fad 100644
--- a/tests/ui/macros/expr_2021_cargo_fix_edition.rs
+++ b/tests/ui/macros/expr_2021_cargo_fix_edition.rs
@@ -1,8 +1,6 @@
 //@ run-rustfix
 //@ check-pass
 //@ compile-flags: --edition=2021
-#![allow(incomplete_features)]
-#![feature(expr_fragment_specifier_2024)]
 #![warn(edition_2024_expr_fragment_specifier)]
 
 macro_rules! m {
diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr
index e8a44fed322..fe1fd4a26a0 100644
--- a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr
+++ b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr
@@ -1,5 +1,5 @@
 warning: the `expr` fragment specifier will accept more expressions in the 2024 edition
-  --> $DIR/expr_2021_cargo_fix_edition.rs:9:9
+  --> $DIR/expr_2021_cargo_fix_edition.rs:7:9
    |
 LL |     ($e:expr) => {
    |         ^^^^
@@ -7,7 +7,7 @@ LL |     ($e:expr) => {
    = warning: this changes meaning in Rust 2024
    = note: for more information, see Migration Guide <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/macro-fragment-specifiers.html>
 note: the lint level is defined here
-  --> $DIR/expr_2021_cargo_fix_edition.rs:6:9
+  --> $DIR/expr_2021_cargo_fix_edition.rs:4:9
    |
 LL | #![warn(edition_2024_expr_fragment_specifier)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@ LL |     ($e:expr_2021) => {
    |         ~~~~~~~~~
 
 warning: the `expr` fragment specifier will accept more expressions in the 2024 edition
-  --> $DIR/expr_2021_cargo_fix_edition.rs:13:11
+  --> $DIR/expr_2021_cargo_fix_edition.rs:11:11
    |
 LL |     ($($i:expr)*) => { };
    |           ^^^^
diff --git a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr
index b55ae62030c..22d662aaaf2 100644
--- a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr
+++ b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr
@@ -1,5 +1,5 @@
 error: no rules expected the token `const`
-  --> $DIR/expr_2021_inline_const.rs:26:12
+  --> $DIR/expr_2021_inline_const.rs:23:12
    |
 LL | macro_rules! m2021 {
    | ------------------ when calling this macro
@@ -8,13 +8,13 @@ LL |     m2021!(const { 1 });
    |            ^^^^^ no rules expected this token in macro call
    |
 note: while trying to match meta-variable `$e:expr_2021`
-  --> $DIR/expr_2021_inline_const.rs:10:6
+  --> $DIR/expr_2021_inline_const.rs:7:6
    |
 LL |     ($e:expr_2021) => {
    |      ^^^^^^^^^^^^
 
 error: no rules expected the token `const`
-  --> $DIR/expr_2021_inline_const.rs:27:12
+  --> $DIR/expr_2021_inline_const.rs:24:12
    |
 LL | macro_rules! m2024 {
    | ------------------ when calling this macro
@@ -23,7 +23,7 @@ LL |     m2024!(const { 1 });
    |            ^^^^^ no rules expected this token in macro call
    |
 note: while trying to match meta-variable `$e:expr`
-  --> $DIR/expr_2021_inline_const.rs:16:6
+  --> $DIR/expr_2021_inline_const.rs:13:6
    |
 LL |     ($e:expr) => {
    |      ^^^^^^^
diff --git a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr
index 285db53d6c8..2555e4f757a 100644
--- a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr
+++ b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr
@@ -1,5 +1,5 @@
 error: no rules expected the token `const`
-  --> $DIR/expr_2021_inline_const.rs:26:12
+  --> $DIR/expr_2021_inline_const.rs:23:12
    |
 LL | macro_rules! m2021 {
    | ------------------ when calling this macro
@@ -8,7 +8,7 @@ LL |     m2021!(const { 1 });
    |            ^^^^^ no rules expected this token in macro call
    |
 note: while trying to match meta-variable `$e:expr_2021`
-  --> $DIR/expr_2021_inline_const.rs:10:6
+  --> $DIR/expr_2021_inline_const.rs:7:6
    |
 LL |     ($e:expr_2021) => {
    |      ^^^^^^^^^^^^
diff --git a/tests/ui/macros/expr_2021_inline_const.rs b/tests/ui/macros/expr_2021_inline_const.rs
index 06b74a466d6..39a542fe4d9 100644
--- a/tests/ui/macros/expr_2021_inline_const.rs
+++ b/tests/ui/macros/expr_2021_inline_const.rs
@@ -3,9 +3,6 @@
 //@[edi2021]compile-flags: --edition=2021
 
 // This test ensures that the inline const match only on edition 2024
-#![feature(expr_fragment_specifier_2024)]
-#![allow(incomplete_features)]
-
 macro_rules! m2021 {
     ($e:expr_2021) => {
         $e
diff --git a/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr b/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr
index 335b3f61343..34df20a69ef 100644
--- a/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr
+++ b/tests/ui/macros/expr_2024_underscore_expr.edi2021.stderr
@@ -1,5 +1,5 @@
 error: no rules expected the token `_`
-  --> $DIR/expr_2024_underscore_expr.rs:22:12
+  --> $DIR/expr_2024_underscore_expr.rs:19:12
    |
 LL | macro_rules! m2021 {
    | ------------------ when calling this macro
@@ -8,13 +8,13 @@ LL |     m2021!(_);
    |            ^ no rules expected this token in macro call
    |
 note: while trying to match meta-variable `$e:expr_2021`
-  --> $DIR/expr_2024_underscore_expr.rs:10:6
+  --> $DIR/expr_2024_underscore_expr.rs:7:6
    |
 LL |     ($e:expr_2021) => {
    |      ^^^^^^^^^^^^
 
 error: no rules expected the token `_`
-  --> $DIR/expr_2024_underscore_expr.rs:23:12
+  --> $DIR/expr_2024_underscore_expr.rs:20:12
    |
 LL | macro_rules! m2024 {
    | ------------------ when calling this macro
@@ -23,7 +23,7 @@ LL |     m2024!(_);
    |            ^ no rules expected this token in macro call
    |
 note: while trying to match meta-variable `$e:expr`
-  --> $DIR/expr_2024_underscore_expr.rs:16:6
+  --> $DIR/expr_2024_underscore_expr.rs:13:6
    |
 LL |     ($e:expr) => {
    |      ^^^^^^^
diff --git a/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr b/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr
index 9e49f66a89a..372c5d8637c 100644
--- a/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr
+++ b/tests/ui/macros/expr_2024_underscore_expr.edi2024.stderr
@@ -1,5 +1,5 @@
 error: no rules expected the token `_`
-  --> $DIR/expr_2024_underscore_expr.rs:22:12
+  --> $DIR/expr_2024_underscore_expr.rs:19:12
    |
 LL | macro_rules! m2021 {
    | ------------------ when calling this macro
@@ -8,7 +8,7 @@ LL |     m2021!(_);
    |            ^ no rules expected this token in macro call
    |
 note: while trying to match meta-variable `$e:expr_2021`
-  --> $DIR/expr_2024_underscore_expr.rs:10:6
+  --> $DIR/expr_2024_underscore_expr.rs:7:6
    |
 LL |     ($e:expr_2021) => {
    |      ^^^^^^^^^^^^
diff --git a/tests/ui/macros/expr_2024_underscore_expr.rs b/tests/ui/macros/expr_2024_underscore_expr.rs
index b2129bf154f..86e31374506 100644
--- a/tests/ui/macros/expr_2024_underscore_expr.rs
+++ b/tests/ui/macros/expr_2024_underscore_expr.rs
@@ -3,9 +3,6 @@
 //@[edi2021]compile-flags: --edition=2021
 // This test ensures that the `_` tok is considered an
 // expression on edition 2024.
-#![feature(expr_fragment_specifier_2024)]
-#![allow(incomplete_features)]
-
 macro_rules! m2021 {
     ($e:expr_2021) => {
         $e = 1;
diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs
deleted file mode 100644
index 5a737b29821..00000000000
--- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-//@  compile-flags: --edition=2024 -Z unstable-options
-
-macro_rules! m {
-    ($e:expr_2021) => { //~ ERROR: fragment specifier `expr_2021` is unstable
-        $e
-    };
-}
-
-fn main() {
-    m!(());
-}
diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr
deleted file mode 100644
index 273a93877ce..00000000000
--- a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0658]: fragment specifier `expr_2021` is unstable
-  --> $DIR/feature-gate-expr_fragment_specifier_2024.rs:4:6
-   |
-LL |     ($e:expr_2021) => {
-   |      ^^^^^^^^^^^^
-   |
-   = note: see issue #123742 <https://github.com/rust-lang/rust/issues/123742> for more information
-   = help: add `#![feature(expr_fragment_specifier_2024)]` to the crate attributes to enable
-   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/macros/invalid-fragment-specifier.stderr b/tests/ui/macros/invalid-fragment-specifier.stderr
index 7516dbc3a08..a51ea619b36 100644
--- a/tests/ui/macros/invalid-fragment-specifier.stderr
+++ b/tests/ui/macros/invalid-fragment-specifier.stderr
@@ -4,7 +4,7 @@ error: invalid fragment specifier `id`
 LL |     ($wrong:id) => {};
    |      ^^^^^^^^^
    |
-   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
 
 error: invalid fragment specifier `r#if`
   --> $DIR/invalid-fragment-specifier.rs:7:6
@@ -12,7 +12,7 @@ error: invalid fragment specifier `r#if`
 LL |     ($wrong:r#if) => {};
    |      ^^^^^^^^^^^
    |
-   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/macros/issue-21356.stderr b/tests/ui/macros/issue-21356.stderr
index dd09da6df4f..5ff92642514 100644
--- a/tests/ui/macros/issue-21356.stderr
+++ b/tests/ui/macros/issue-21356.stderr
@@ -4,7 +4,7 @@ error: invalid fragment specifier `t_ty`
 LL | macro_rules! test { ($wrong:t_ty ..) => () }
    |                      ^^^^^^^^^^^
    |
-   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/macros/macro-missing-fragment.e2024.stderr b/tests/ui/macros/macro-missing-fragment.e2024.stderr
index 3afa069c170..0dc48e0c7b2 100644
--- a/tests/ui/macros/macro-missing-fragment.e2024.stderr
+++ b/tests/ui/macros/macro-missing-fragment.e2024.stderr
@@ -5,7 +5,7 @@ LL |     ( $( any_token $field_rust_type )* ) => {};
    |                    ^^^^^^^^^^^^^^^^
    |
    = note: fragment specifiers must be specified in the 2024 edition
-   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
 help: try adding a specifier here
    |
 LL |     ( $( any_token $field_rust_type:spec )* ) => {};
@@ -18,7 +18,7 @@ LL |     ( $name ) => {};
    |       ^^^^^
    |
    = note: fragment specifiers must be specified in the 2024 edition
-   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
 help: try adding a specifier here
    |
 LL |     ( $name:spec ) => {};
@@ -31,7 +31,7 @@ LL |     ( $name ) => {};
    |       ^^^^^
    |
    = note: fragment specifiers must be specified in the 2024 edition
-   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
+   = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`, along with `expr_2021` and `pat_param` for edition compatibility
 help: try adding a specifier here
    |
 LL |     ( $name:spec ) => {};
diff --git a/tests/ui/macros/metavar_cross_edition_recursive_macros.rs b/tests/ui/macros/metavar_cross_edition_recursive_macros.rs
index 3eec1208b89..9a5b92f5032 100644
--- a/tests/ui/macros/metavar_cross_edition_recursive_macros.rs
+++ b/tests/ui/macros/metavar_cross_edition_recursive_macros.rs
@@ -6,7 +6,6 @@
 // This test captures the behavior of macro-generating-macros with fragment
 // specifiers across edition boundaries.
 
-#![feature(expr_fragment_specifier_2024)]
 #![feature(macro_metavar_expr)]
 #![allow(incomplete_features)]