Skip to content

Commit b67175b

Browse files
committed
Add a test for new 2024 standard library behavior
When migrating the standard library to 2024, there will be some behavior changes that users will be able to observe. This test should cover that (I cannot think of any other observable differences).
1 parent 79b43df commit b67175b

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

tests/ui/macros/std-2024-macros.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Tests a small handful of macros in the standard library how they handle the
2+
// new behavior introduced in 2024.
3+
4+
fn main() {
5+
assert_eq!(0, const { 0 });
6+
//~^ ERROR: no rules expected keyword `const`
7+
assert_eq!(const { 0 }, const { 0 });
8+
//~^ ERROR: no rules expected keyword `const`
9+
assert_eq!(const { 0 }, 0);
10+
//~^ ERROR: no rules expected keyword `const`
11+
12+
let _: Vec<Vec<String>> = vec![const { vec![] }];
13+
//~^ ERROR: no rules expected keyword `const`
14+
let _: Vec<Vec<String>> = vec![const { vec![] }; 10];
15+
//~^ ERROR: no rules expected keyword `const`
16+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
error: no rules expected keyword `const`
2+
--> $DIR/std-2024-macros.rs:5:19
3+
|
4+
LL | assert_eq!(0, const { 0 });
5+
| ^^^^^ no rules expected this token in macro call
6+
|
7+
note: while trying to match meta-variable `$right:expr`
8+
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
9+
10+
error: no rules expected keyword `const`
11+
--> $DIR/std-2024-macros.rs:7:16
12+
|
13+
LL | assert_eq!(const { 0 }, const { 0 });
14+
| ^^^^^ no rules expected this token in macro call
15+
|
16+
note: while trying to match meta-variable `$left:expr`
17+
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
18+
19+
error: no rules expected keyword `const`
20+
--> $DIR/std-2024-macros.rs:9:16
21+
|
22+
LL | assert_eq!(const { 0 }, 0);
23+
| ^^^^^ no rules expected this token in macro call
24+
|
25+
note: while trying to match meta-variable `$left:expr`
26+
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
27+
28+
error: no rules expected keyword `const`
29+
--> $DIR/std-2024-macros.rs:12:36
30+
|
31+
LL | let _: Vec<Vec<String>> = vec![const { vec![] }];
32+
| ^^^^^ no rules expected this token in macro call
33+
|
34+
= note: while trying to match end of macro
35+
36+
error: no rules expected keyword `const`
37+
--> $DIR/std-2024-macros.rs:14:36
38+
|
39+
LL | let _: Vec<Vec<String>> = vec![const { vec![] }; 10];
40+
| ^^^^^ no rules expected this token in macro call
41+
|
42+
= note: while trying to match end of macro
43+
44+
error: aborting due to 5 previous errors
45+

0 commit comments

Comments
 (0)