about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-08-22 20:52:55 +0200
committerGitHub <noreply@github.com>2021-08-22 20:52:55 +0200
commit518b27b57ae2ce9e3a10f167c36385b1dbbbf614 (patch)
tree59350f79900e3785875ace9b84f97dd4c9feb3bd /src
parent167ae26a889649fd6d6499eaeef3e7acd5c9c5df (diff)
parentbcc5ecb969579eb1c5fd4df0f7855105b66fe907 (diff)
Rollup merge of #88229 - m-ou-se:macro-suggest-right-kind, r=estebank
Suggest importing the right kind of macro.

Fixes #88228.

r? `@estebank`
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/macros/issue-88228.rs22
-rw-r--r--src/test/ui/macros/issue-88228.stderr26
-rw-r--r--src/test/ui/proc-macro/derive-helper-shadowing.stderr4
3 files changed, 52 insertions, 0 deletions
diff --git a/src/test/ui/macros/issue-88228.rs b/src/test/ui/macros/issue-88228.rs
new file mode 100644
index 00000000000..615b865e9f1
--- /dev/null
+++ b/src/test/ui/macros/issue-88228.rs
@@ -0,0 +1,22 @@
+// compile-flags: -Z deduplicate-diagnostics=yes
+// edition:2018
+
+mod hey {
+    pub use Copy as Bla;
+    pub use std::println as bla;
+}
+
+#[derive(Bla)]
+//~^ ERROR cannot find derive macro `Bla`
+//~| NOTE consider importing this derive macro
+struct A;
+
+#[derive(println)]
+//~^ ERROR cannot find derive macro `println`
+struct B;
+
+fn main() {
+    bla!();
+    //~^ ERROR cannot find macro `bla`
+    //~| NOTE consider importing this macro
+}
diff --git a/src/test/ui/macros/issue-88228.stderr b/src/test/ui/macros/issue-88228.stderr
new file mode 100644
index 00000000000..b164e39064c
--- /dev/null
+++ b/src/test/ui/macros/issue-88228.stderr
@@ -0,0 +1,26 @@
+error: cannot find macro `bla` in this scope
+  --> $DIR/issue-88228.rs:19:5
+   |
+LL |     bla!();
+   |     ^^^
+   |
+   = note: consider importing this macro:
+           crate::hey::bla
+
+error: cannot find derive macro `println` in this scope
+  --> $DIR/issue-88228.rs:14:10
+   |
+LL | #[derive(println)]
+   |          ^^^^^^^
+
+error: cannot find derive macro `Bla` in this scope
+  --> $DIR/issue-88228.rs:9:10
+   |
+LL | #[derive(Bla)]
+   |          ^^^
+   |
+   = note: consider importing this derive macro:
+           crate::hey::Bla
+
+error: aborting due to 3 previous errors
+
diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr
index 4115fec86fb..3b160935a2f 100644
--- a/src/test/ui/proc-macro/derive-helper-shadowing.stderr
+++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr
@@ -16,6 +16,8 @@ error: cannot find attribute `empty_helper` in this scope
 LL |             #[derive(GenHelperUse)]
    |                      ^^^^^^^^^^^^
    |
+   = note: consider importing this attribute macro:
+           empty_helper
    = note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot find attribute `empty_helper` in this scope
@@ -27,6 +29,8 @@ LL |         #[empty_helper]
 LL |             gen_helper_use!();
    |             ------------------ in this macro invocation
    |
+   = note: consider importing this attribute macro:
+           crate::empty_helper
    = note: this error originates in the macro `gen_helper_use` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `empty_helper` is ambiguous (name vs any other name during import resolution)