Skip to content

Commit 4e22bf4

Browse files
committed
Show what things are, but also what they are not.
1 parent a13c66e commit 4e22bf4

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,13 @@ impl<'a> Resolver<'a> {
978978
Some(MacroKind::Derive) => format!("a derive macro: `#[derive({})]`", ident),
979979
// Don't confuse the user with tool modules.
980980
None if res == Res::ToolMod => continue,
981-
None => format!("{} {}", res.article(), res.descr()),
981+
None => format!(
982+
"{} {}, not {} {}",
983+
res.article(),
984+
res.descr(),
985+
macro_kind.article(),
986+
macro_kind.descr_expected(),
987+
),
982988
};
983989
if let crate::NameBindingKind::Import { import, .. } = binding.kind {
984990
if !import.span.is_dummy() {

src/test/ui/macros/issue-88206.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: cannot find macro `X` in this scope
44
LL | X!();
55
| ^
66
|
7-
note: `X` is imported here, but it is a struct
7+
note: `X` is imported here, but it is a struct, not a macro
88
--> $DIR/issue-88206.rs:17:35
99
|
1010
LL | use hey::{Serialize, Deserialize, X};
@@ -32,15 +32,15 @@ error: cannot find macro `Box` in this scope
3232
LL | Box!();
3333
| ^^^
3434
|
35-
= note: `Box` is in scope, but it is a struct
35+
= note: `Box` is in scope, but it is a struct, not a macro
3636

3737
error: cannot find macro `from_utf8` in this scope
3838
--> $DIR/issue-88206.rs:49:5
3939
|
4040
LL | from_utf8!();
4141
| ^^^^^^^^^
4242
|
43-
note: `from_utf8` is imported here, but it is a function
43+
note: `from_utf8` is imported here, but it is a function, not a macro
4444
--> $DIR/issue-88206.rs:5:5
4545
|
4646
LL | use std::str::*;
@@ -60,7 +60,7 @@ error: cannot find attribute `from_utf8_unchecked` in this scope
6060
LL | #[from_utf8_unchecked]
6161
| ^^^^^^^^^^^^^^^^^^^
6262
|
63-
note: `from_utf8_unchecked` is imported here, but it is a function
63+
note: `from_utf8_unchecked` is imported here, but it is a function, not an attribute
6464
--> $DIR/issue-88206.rs:5:5
6565
|
6666
LL | use std::str::*;
@@ -72,7 +72,7 @@ error: cannot find attribute `Deserialize` in this scope
7272
LL | #[Deserialize]
7373
| ^^^^^^^^^^^
7474
|
75-
note: `Deserialize` is imported here, but it is a trait
75+
note: `Deserialize` is imported here, but it is a trait, not an attribute
7676
--> $DIR/issue-88206.rs:17:22
7777
|
7878
LL | use hey::{Serialize, Deserialize, X};
@@ -92,7 +92,7 @@ error: cannot find derive macro `from_utf8_mut` in this scope
9292
LL | #[derive(from_utf8_mut)]
9393
| ^^^^^^^^^^^^^
9494
|
95-
note: `from_utf8_mut` is imported here, but it is a function
95+
note: `from_utf8_mut` is imported here, but it is a function, not a derive macro
9696
--> $DIR/issue-88206.rs:5:5
9797
|
9898
LL | use std::str::*;
@@ -104,7 +104,7 @@ error: cannot find derive macro `Serialize` in this scope
104104
LL | #[derive(Serialize)]
105105
| ^^^^^^^^^
106106
|
107-
note: `Serialize` is imported here, but it is a trait
107+
note: `Serialize` is imported here, but it is a trait, not a derive macro
108108
--> $DIR/issue-88206.rs:17:11
109109
|
110110
LL | use hey::{Serialize, Deserialize, X};

0 commit comments

Comments
 (0)