Skip to content

Commit 3b18e21

Browse files
m-ou-selrh2000
authored andcommitted
Add test for the reserved_prefix migration lint.
1 parent d837c00 commit 3b18e21

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// check-pass
2+
// run-rustfix
3+
// compile-flags: -Z unstable-options --edition 2018
4+
5+
#![warn(reserved_prefix)]
6+
7+
macro_rules! m2 {
8+
($a:tt $b:tt) => {};
9+
}
10+
11+
macro_rules! m3 {
12+
($a:tt $b:tt $c:tt) => {};
13+
}
14+
15+
fn main() {
16+
m2!(z "hey");
17+
//~^ WARNING prefix `z` is unknown [reserved_prefix]
18+
//~| WARNING become a hard error
19+
m2!(prefix "hey");
20+
//~^ WARNING prefix `prefix` is unknown [reserved_prefix]
21+
//~| WARNING become a hard error
22+
m3!(hey #123);
23+
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
24+
//~| WARNING become a hard error
25+
m3!(hey #hey);
26+
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
27+
//~| WARNING become a hard error
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// check-pass
2+
// run-rustfix
3+
// compile-flags: -Z unstable-options --edition 2018
4+
5+
#![warn(reserved_prefix)]
6+
7+
macro_rules! m2 {
8+
($a:tt $b:tt) => {};
9+
}
10+
11+
macro_rules! m3 {
12+
($a:tt $b:tt $c:tt) => {};
13+
}
14+
15+
fn main() {
16+
m2!(z"hey");
17+
//~^ WARNING prefix `z` is unknown [reserved_prefix]
18+
//~| WARNING become a hard error
19+
m2!(prefix"hey");
20+
//~^ WARNING prefix `prefix` is unknown [reserved_prefix]
21+
//~| WARNING become a hard error
22+
m3!(hey#123);
23+
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
24+
//~| WARNING become a hard error
25+
m3!(hey#hey);
26+
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
27+
//~| WARNING become a hard error
28+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
warning: prefix `z` is unknown
2+
--> $DIR/reserved-prefixes-migration.rs:16:9
3+
|
4+
LL | m2!(z"hey");
5+
| ^ unknown prefix
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/reserved-prefixes-migration.rs:5:9
9+
|
10+
LL | #![warn(reserved_prefix)]
11+
| ^^^^^^^^^^^^^^^
12+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
13+
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
14+
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
15+
|
16+
LL | m2!(z "hey");
17+
| --
18+
19+
warning: prefix `prefix` is unknown
20+
--> $DIR/reserved-prefixes-migration.rs:19:9
21+
|
22+
LL | m2!(prefix"hey");
23+
| ^^^^^^ unknown prefix
24+
|
25+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
26+
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
27+
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
28+
|
29+
LL | m2!(prefix "hey");
30+
| --
31+
32+
warning: prefix `hey` is unknown
33+
--> $DIR/reserved-prefixes-migration.rs:22:9
34+
|
35+
LL | m3!(hey#123);
36+
| ^^^ unknown prefix
37+
|
38+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
39+
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
40+
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
41+
|
42+
LL | m3!(hey #123);
43+
| --
44+
45+
warning: prefix `hey` is unknown
46+
--> $DIR/reserved-prefixes-migration.rs:25:9
47+
|
48+
LL | m3!(hey#hey);
49+
| ^^^ unknown prefix
50+
|
51+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
52+
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
53+
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
54+
|
55+
LL | m3!(hey #hey);
56+
| --
57+
58+
warning: 4 warnings emitted
59+

0 commit comments

Comments
 (0)