Skip to content

Commit 65da4ad

Browse files
Add test that expr_2021 only works on 2024 edition
Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent ef6478b commit 65da4ad

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ compile-flags: --edition=2021
2+
3+
// This test ensures that expr_2021 is not allowed on pre-2024 editions
4+
5+
macro_rules! m {
6+
($e:expr_2021) => { //~ ERROR: invalid fragment specifier `expr_2021`
7+
$e
8+
};
9+
}
10+
11+
fn main() {
12+
m!(()); //~ ERROR: no rules expected the token `(`
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error: invalid fragment specifier `expr_2021`
2+
--> $DIR/expr_2021_old_edition.rs:6:6
3+
|
4+
LL | ($e:expr_2021) => {
5+
| ^^^^^^^^^^^^
6+
|
7+
= help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis`
8+
9+
error: no rules expected the token `(`
10+
--> $DIR/expr_2021_old_edition.rs:12:8
11+
|
12+
LL | macro_rules! m {
13+
| -------------- when calling this macro
14+
...
15+
LL | m!(());
16+
| ^ no rules expected this token in macro call
17+
|
18+
note: while trying to match meta-variable `$e:ident`
19+
--> $DIR/expr_2021_old_edition.rs:6:6
20+
|
21+
LL | ($e:expr_2021) => {
22+
| ^^^^^^^^^^^^
23+
24+
error: aborting due to 2 previous errors
25+

0 commit comments

Comments
 (0)