about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-08-22 15:05:13 +0200
committerMara Bos <m-ou.se@m-ou.se>2021-08-23 16:43:54 +0200
commit11c879d209d71700e5fa955fdfbbc0883768a942 (patch)
tree642c189f77af12168446c5a25120bd6e24888871
parent7977cb43b01af009434b54e4136c7e460e1f733f (diff)
downloadrust-11c879d209d71700e5fa955fdfbbc0883768a942.tar.gz
rust-11c879d209d71700e5fa955fdfbbc0883768a942.zip
Add tests for macro-not-found diagnostics.
-rw-r--r--src/test/ui/derives/issue-88206.rs18
-rw-r--r--src/test/ui/derives/issue-88206.stderr26
-rw-r--r--src/test/ui/macros/issue-88206.rs63
-rw-r--r--src/test/ui/macros/issue-88206.stderr120
4 files changed, 183 insertions, 44 deletions
diff --git a/src/test/ui/derives/issue-88206.rs b/src/test/ui/derives/issue-88206.rs
deleted file mode 100644
index 476c3467928..00000000000
--- a/src/test/ui/derives/issue-88206.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// compile-flags: -Z deduplicate-diagnostics=yes
-
-#![warn(unused_imports)]
-//~^ NOTE lint level
-
-mod hey {
-    pub trait Serialize {}
-}
-
-use hey::Serialize;
-//~^ WARNING unused import
-//~| NOTE `Serialize` is imported here
-
-#[derive(Serialize)]
-//~^ ERROR cannot find derive macro `Serialize`
-struct A;
-
-fn main() {}
diff --git a/src/test/ui/derives/issue-88206.stderr b/src/test/ui/derives/issue-88206.stderr
deleted file mode 100644
index 8a0cb7616c2..00000000000
--- a/src/test/ui/derives/issue-88206.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error: cannot find derive macro `Serialize` in this scope
-  --> $DIR/issue-88206.rs:14:10
-   |
-LL | #[derive(Serialize)]
-   |          ^^^^^^^^^
-   |
-note: `Serialize` is imported here, but it is not a derive macro
-  --> $DIR/issue-88206.rs:10:5
-   |
-LL | use hey::Serialize;
-   |     ^^^^^^^^^^^^^^
-
-warning: unused import: `hey::Serialize`
-  --> $DIR/issue-88206.rs:10:5
-   |
-LL | use hey::Serialize;
-   |     ^^^^^^^^^^^^^^
-   |
-note: the lint level is defined here
-  --> $DIR/issue-88206.rs:3:9
-   |
-LL | #![warn(unused_imports)]
-   |         ^^^^^^^^^^^^^^
-
-error: aborting due to previous error; 1 warning emitted
-
diff --git a/src/test/ui/macros/issue-88206.rs b/src/test/ui/macros/issue-88206.rs
new file mode 100644
index 00000000000..67b7448a3ed
--- /dev/null
+++ b/src/test/ui/macros/issue-88206.rs
@@ -0,0 +1,63 @@
+// compile-flags: -Z deduplicate-diagnostics=yes
+
+#![warn(unused_imports)]
+//~^ NOTE lint level
+
+use std::str::*;
+//~^ WARNING unused import
+//~| NOTE `from_utf8` is imported here, but it is not a macro
+//~| NOTE `from_utf8_mut` is imported here, but it is not a derive macro
+//~| NOTE `from_utf8_unchecked` is imported here, but it is not an attribute
+
+mod hey {
+    pub trait Serialize {}
+    pub trait Deserialize {}
+}
+
+use hey::{Serialize, Deserialize};
+//~^ WARNING unused import
+//~| NOTE `Serialize` is imported here, but it is not a derive macro
+//~| NOTE `Deserialize` is imported here, but it is not an attribute
+
+#[derive(Serialize)]
+//~^ ERROR cannot find derive macro `Serialize`
+struct A;
+
+#[derive(from_utf8_mut)]
+//~^ ERROR cannot find derive macro `from_utf8_mut`
+struct B;
+
+#[derive(println)]
+//~^ ERROR cannot find derive macro `println`
+//~| NOTE `println` is in scope, but it is a function-like macro
+struct C;
+
+#[Deserialize]
+//~^ ERROR cannot find attribute `Deserialize`
+struct D;
+
+#[from_utf8_unchecked]
+//~^ ERROR cannot find attribute `from_utf8_unchecked`
+struct E;
+
+#[println]
+//~^ ERROR cannot find attribute `println`
+//~| NOTE `println` is in scope, but it is a function-like macro
+struct F;
+
+fn main() {
+    from_utf8!();
+    //~^ ERROR cannot find macro `from_utf8`
+
+    Box!();
+    //~^ ERROR cannot find macro `Box`
+    //~| NOTE `Box` is in scope, but it is not a macro
+
+    Copy!();
+    //~^ ERROR cannot find macro `Copy`
+    //~| NOTE `Copy` is in scope, but it is a derive macro
+
+    test!();
+    //~^ ERROR cannot find macro `test`
+    //~| NOTE `test` is in scope, but it is an attribute
+}
diff --git a/src/test/ui/macros/issue-88206.stderr b/src/test/ui/macros/issue-88206.stderr
new file mode 100644
index 00000000000..4e45de2ee3e
--- /dev/null
+++ b/src/test/ui/macros/issue-88206.stderr
@@ -0,0 +1,120 @@
+error: cannot find macro `test` in this scope
+  --> $DIR/issue-88206.rs:60:5
+   |
+LL |     test!();
+   |     ^^^^
+   |
+   = note: `test` is in scope, but it is an attribute
+
+error: cannot find macro `Copy` in this scope
+  --> $DIR/issue-88206.rs:56:5
+   |
+LL |     Copy!();
+   |     ^^^^
+   |
+   = note: `Copy` is in scope, but it is a derive macro
+
+error: cannot find macro `Box` in this scope
+  --> $DIR/issue-88206.rs:52:5
+   |
+LL |     Box!();
+   |     ^^^
+   |
+   = note: `Box` is in scope, but it is not a macro
+
+error: cannot find macro `from_utf8` in this scope
+  --> $DIR/issue-88206.rs:49:5
+   |
+LL |     from_utf8!();
+   |     ^^^^^^^^^
+   |
+note: `from_utf8` is imported here, but it is not a macro
+  --> $DIR/issue-88206.rs:6:5
+   |
+LL | use std::str::*;
+   |     ^^^^^^^^^^^
+
+error: cannot find attribute `println` in this scope
+  --> $DIR/issue-88206.rs:43:3
+   |
+LL | #[println]
+   |   ^^^^^^^
+   |
+   = note: `println` is in scope, but it is a function-like macro
+
+error: cannot find attribute `from_utf8_unchecked` in this scope
+  --> $DIR/issue-88206.rs:39:3
+   |
+LL | #[from_utf8_unchecked]
+   |   ^^^^^^^^^^^^^^^^^^^
+   |
+note: `from_utf8_unchecked` is imported here, but it is not an attribute
+  --> $DIR/issue-88206.rs:6:5
+   |
+LL | use std::str::*;
+   |     ^^^^^^^^^^^
+
+error: cannot find attribute `Deserialize` in this scope
+  --> $DIR/issue-88206.rs:35:3
+   |
+LL | #[Deserialize]
+   |   ^^^^^^^^^^^
+   |
+note: `Deserialize` is imported here, but it is not an attribute
+  --> $DIR/issue-88206.rs:17:22
+   |
+LL | use hey::{Serialize, Deserialize};
+   |                      ^^^^^^^^^^^
+
+error: cannot find derive macro `println` in this scope
+  --> $DIR/issue-88206.rs:30:10
+   |
+LL | #[derive(println)]
+   |          ^^^^^^^
+   |
+   = note: `println` is in scope, but it is a function-like macro
+
+error: cannot find derive macro `from_utf8_mut` in this scope
+  --> $DIR/issue-88206.rs:26:10
+   |
+LL | #[derive(from_utf8_mut)]
+   |          ^^^^^^^^^^^^^
+   |
+note: `from_utf8_mut` is imported here, but it is not a derive macro
+  --> $DIR/issue-88206.rs:6:5
+   |
+LL | use std::str::*;
+   |     ^^^^^^^^^^^
+
+error: cannot find derive macro `Serialize` in this scope
+  --> $DIR/issue-88206.rs:22:10
+   |
+LL | #[derive(Serialize)]
+   |          ^^^^^^^^^
+   |
+note: `Serialize` is imported here, but it is not a derive macro
+  --> $DIR/issue-88206.rs:17:11
+   |
+LL | use hey::{Serialize, Deserialize};
+   |           ^^^^^^^^^
+
+warning: unused import: `std::str::*`
+  --> $DIR/issue-88206.rs:6:5
+   |
+LL | use std::str::*;
+   |     ^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-88206.rs:3:9
+   |
+LL | #![warn(unused_imports)]
+   |         ^^^^^^^^^^^^^^
+
+warning: unused imports: `Deserialize`, `Serialize`
+  --> $DIR/issue-88206.rs:17:11
+   |
+LL | use hey::{Serialize, Deserialize};
+   |           ^^^^^^^^^  ^^^^^^^^^^^
+
+error: aborting due to 10 previous errors; 2 warnings emitted
+