about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/rust-2021/reserved-prefixes-migration.fixed28
-rw-r--r--src/test/ui/rust-2021/reserved-prefixes-migration.rs28
-rw-r--r--src/test/ui/rust-2021/reserved-prefixes-migration.stderr59
3 files changed, 115 insertions, 0 deletions
diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed
new file mode 100644
index 00000000000..88e7584c197
--- /dev/null
+++ b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed
@@ -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
+}
diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.rs b/src/test/ui/rust-2021/reserved-prefixes-migration.rs
new file mode 100644
index 00000000000..ee835eb97a2
--- /dev/null
+++ b/src/test/ui/rust-2021/reserved-prefixes-migration.rs
@@ -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
+}
diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.stderr b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr
new file mode 100644
index 00000000000..2c9d94803be
--- /dev/null
+++ b/src/test/ui/rust-2021/reserved-prefixes-migration.stderr
@@ -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
+