Skip to content

Commit 568e78f

Browse files
tests: adds cargo fix tests
Co-Developed-by: Eric Holk Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent 25637e2 commit 568e78f

6 files changed

+91
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ run-rustfix
2+
//@ check-pass
3+
//@ compile-flags: --edition=2021
4+
#![allow(incomplete_features)]
5+
#![feature(expr_fragment_specifier_2024)]
6+
#![warn(edition_2024_expr_fragment_specifier)]
7+
8+
macro_rules! m {
9+
($e:expr_2021) => { //~ WARN: the `expr` fragment specifier will accept more expressions in the 2024 edition
10+
//~^ WARN: this changes meaning in Rust 2024
11+
$e
12+
};
13+
($($i:expr_2021)*) => { }; //~ WARN: the `expr` fragment specifier will accept more expressions in the 2024 edition
14+
//~^ WARN: this changes meaning in Rust 2024
15+
}
16+
17+
macro_rules! test {
18+
(expr) => {}
19+
}
20+
21+
fn main() {
22+
m!(());
23+
test!(expr);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ run-rustfix
2+
//@ check-pass
3+
//@ compile-flags: --edition=2021
4+
#![allow(incomplete_features)]
5+
#![feature(expr_fragment_specifier_2024)]
6+
#![warn(edition_2024_expr_fragment_specifier)]
7+
8+
macro_rules! m {
9+
($e:expr) => { //~ WARN: the `expr` fragment specifier will accept more expressions in the 2024 edition
10+
//~^ WARN: this changes meaning in Rust 2024
11+
$e
12+
};
13+
($($i:expr)*) => { }; //~ WARN: the `expr` fragment specifier will accept more expressions in the 2024 edition
14+
//~^ WARN: this changes meaning in Rust 2024
15+
}
16+
17+
macro_rules! test {
18+
(expr) => {}
19+
}
20+
21+
fn main() {
22+
m!(());
23+
test!(expr);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
warning: the `expr` fragment specifier will accept more expressions in the 2024 edition
2+
--> $DIR/expr_2021_cargo_fix_edition.rs:9:9
3+
|
4+
LL | ($e:expr) => {
5+
| ^^^^
6+
|
7+
= warning: this changes meaning in Rust 2024
8+
= note: for more information, see Migration Guide <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/macro-fragment-specifiers.html>
9+
note: the lint level is defined here
10+
--> $DIR/expr_2021_cargo_fix_edition.rs:6:9
11+
|
12+
LL | #![warn(edition_2024_expr_fragment_specifier)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
help: to keep the existing behavior, use the `expr_2021` fragment specifier
15+
|
16+
LL | ($e:expr_2021) => {
17+
| ~~~~~~~~~
18+
19+
warning: the `expr` fragment specifier will accept more expressions in the 2024 edition
20+
--> $DIR/expr_2021_cargo_fix_edition.rs:13:11
21+
|
22+
LL | ($($i:expr)*) => { };
23+
| ^^^^
24+
|
25+
= warning: this changes meaning in Rust 2024
26+
= note: for more information, see Migration Guide <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/macro-fragment-specifiers.html>
27+
help: to keep the existing behavior, use the `expr_2021` fragment specifier
28+
|
29+
LL | ($($i:expr_2021)*) => { };
30+
| ~~~~~~~~~
31+
32+
warning: 2 warnings emitted
33+

tests/ui/macros/expr_2021_inline_const.edi2021.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: no rules expected the token `const`
2-
--> $DIR/expr_2021_inline_const.rs:21:12
2+
--> $DIR/expr_2021_inline_const.rs:26:12
33
|
44
LL | macro_rules! m2021 {
55
| ------------------ when calling this macro
@@ -14,7 +14,7 @@ LL | ($e:expr_2021) => {
1414
| ^^^^^^^^^^^^
1515

1616
error: no rules expected the token `const`
17-
--> $DIR/expr_2021_inline_const.rs:22:12
17+
--> $DIR/expr_2021_inline_const.rs:27:12
1818
|
1919
LL | macro_rules! m2024 {
2020
| ------------------ when calling this macro

tests/ui/macros/expr_2021_inline_const.edi2024.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: no rules expected the token `const`
2-
--> $DIR/expr_2021_inline_const.rs:21:12
2+
--> $DIR/expr_2021_inline_const.rs:26:12
33
|
44
LL | macro_rules! m2021 {
55
| ------------------ when calling this macro

tests/ui/macros/expr_2021_inline_const.rs

+7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ macro_rules! m2024 {
1717
$e
1818
};
1919
}
20+
21+
macro_rules! test {
22+
(expr) => {}
23+
}
24+
2025
fn main() {
2126
m2021!(const { 1 }); //~ ERROR: no rules expected the token `const`
2227
m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected the token `const`
28+
29+
test!(expr);
2330
}

0 commit comments

Comments
 (0)