1
Fork 0

Add test for the reserved_prefix migration lint.

This commit is contained in:
Mara Bos 2021-06-14 12:57:26 +00:00 committed by lrh2000
parent d837c00d10
commit 3b18e215a3
3 changed files with 115 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// check-pass
// run-rustfix
// compile-flags: -Z unstable-options --edition 2018
#![warn(reserved_prefix)]
macro_rules! m2 {
($a:tt $b:tt) => {};
}
macro_rules! m3 {
($a:tt $b:tt $c:tt) => {};
}
fn main() {
m2!(z "hey");
//~^ WARNING prefix `z` is unknown [reserved_prefix]
//~| WARNING become a hard error
m2!(prefix "hey");
//~^ WARNING prefix `prefix` is unknown [reserved_prefix]
//~| WARNING become a hard error
m3!(hey #123);
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
//~| WARNING become a hard error
m3!(hey #hey);
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
//~| WARNING become a hard error
}

View file

@ -0,0 +1,28 @@
// check-pass
// run-rustfix
// compile-flags: -Z unstable-options --edition 2018
#![warn(reserved_prefix)]
macro_rules! m2 {
($a:tt $b:tt) => {};
}
macro_rules! m3 {
($a:tt $b:tt $c:tt) => {};
}
fn main() {
m2!(z"hey");
//~^ WARNING prefix `z` is unknown [reserved_prefix]
//~| WARNING become a hard error
m2!(prefix"hey");
//~^ WARNING prefix `prefix` is unknown [reserved_prefix]
//~| WARNING become a hard error
m3!(hey#123);
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
//~| WARNING become a hard error
m3!(hey#hey);
//~^ WARNING prefix `hey` is unknown [reserved_prefix]
//~| WARNING become a hard error
}

View file

@ -0,0 +1,59 @@
warning: prefix `z` is unknown
--> $DIR/reserved-prefixes-migration.rs:16:9
|
LL | m2!(z"hey");
| ^ unknown prefix
|
note: the lint level is defined here
--> $DIR/reserved-prefixes-migration.rs:5:9
|
LL | #![warn(reserved_prefix)]
| ^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
|
LL | m2!(z "hey");
| --
warning: prefix `prefix` is unknown
--> $DIR/reserved-prefixes-migration.rs:19:9
|
LL | m2!(prefix"hey");
| ^^^^^^ unknown prefix
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
|
LL | m2!(prefix "hey");
| --
warning: prefix `hey` is unknown
--> $DIR/reserved-prefixes-migration.rs:22:9
|
LL | m3!(hey#123);
| ^^^ unknown prefix
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
|
LL | m3!(hey #123);
| --
warning: prefix `hey` is unknown
--> $DIR/reserved-prefixes-migration.rs:25:9
|
LL | m3!(hey#hey);
| ^^^ unknown prefix
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
= note: for more information, see issue #84978 <https://github.com/rust-lang/rust/issues/84978>
help: insert whitespace here to avoid this being parsed as a prefix in Rust 2021
|
LL | m3!(hey #hey);
| --
warning: 4 warnings emitted