From 2ce06271948962b20ad184524cc8e8fa5066e3f5 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 25 May 2024 10:50:25 +0200 Subject: [PATCH] tests: adds cargo fix tests Co-Developed-by: Eric Holk Signed-off-by: Vincenzo Palazzo --- .../ui/macros/expr_2021_cargo_fix_edition.rs | 15 ++++++++++++++ .../macros/expr_2021_cargo_fix_edition.stderr | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/ui/macros/expr_2021_cargo_fix_edition.rs create mode 100644 tests/ui/macros/expr_2021_cargo_fix_edition.stderr diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.rs b/tests/ui/macros/expr_2021_cargo_fix_edition.rs new file mode 100644 index 0000000000000..7396eb640d717 --- /dev/null +++ b/tests/ui/macros/expr_2021_cargo_fix_edition.rs @@ -0,0 +1,15 @@ +//@ compile-flags: --edition=2021 +// This test ensures that expr_2021 is not allowed on pre-2021 editions +#![deny(edition_2024_expr_fragment_specifier)] + +macro_rules! m { + ($e:expr) => { //~ ERROR: the `expr` fragment specifier will accept more expressions in the 2024 edition. + //~^ WARN: this changes meaning in Rust 2024 + $e + }; +} + +fn main() { + m!(()); +} + diff --git a/tests/ui/macros/expr_2021_cargo_fix_edition.stderr b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr new file mode 100644 index 0000000000000..1ae88f4f0d7f8 --- /dev/null +++ b/tests/ui/macros/expr_2021_cargo_fix_edition.stderr @@ -0,0 +1,20 @@ +error: the `expr` fragment specifier will accept more expressions in the 2024 edition. + --> $DIR/expr_2021_cargo_fix_edition.rs:6:9 + | +LL | ($e:expr) => { + | ^^^^ + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see issue #123742 +note: the lint level is defined here + --> $DIR/expr_2021_cargo_fix_edition.rs:3:9 + | +LL | #![deny(edition_2024_expr_fragment_specifier)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to keep the existing behavior, use the `expr_2021` fragment specifier. + | +LL | ($e:expr_2021) => { + | ~~~~~~~~~ + +error: aborting due to 1 previous error +