Improve wording of macro-not-found-but-name-exists note.
This commit is contained in:
parent
4e22bf47d0
commit
908ce2fd1f
3 changed files with 20 additions and 10 deletions
|
@ -971,14 +971,24 @@ impl<'a> Resolver<'a> {
|
||||||
false,
|
false,
|
||||||
ident.span,
|
ident.span,
|
||||||
) {
|
) {
|
||||||
let res = binding.res();
|
let desc = match binding.res() {
|
||||||
let desc = match res.macro_kind() {
|
Res::Def(DefKind::Macro(MacroKind::Bang), _) => {
|
||||||
Some(MacroKind::Bang) => "a function-like macro".to_string(),
|
"a function-like macro".to_string()
|
||||||
Some(MacroKind::Attr) => format!("an attribute: `#[{}]`", ident),
|
}
|
||||||
Some(MacroKind::Derive) => format!("a derive macro: `#[derive({})]`", ident),
|
Res::Def(DefKind::Macro(MacroKind::Attr), _) | Res::NonMacroAttr(..) => {
|
||||||
|
format!("an attribute: `#[{}]`", ident)
|
||||||
|
}
|
||||||
|
Res::Def(DefKind::Macro(MacroKind::Derive), _) => {
|
||||||
|
format!("a derive macro: `#[derive({})]`", ident)
|
||||||
|
}
|
||||||
|
Res::ToolMod => {
|
||||||
// Don't confuse the user with tool modules.
|
// Don't confuse the user with tool modules.
|
||||||
None if res == Res::ToolMod => continue,
|
continue;
|
||||||
None => format!(
|
}
|
||||||
|
Res::Def(DefKind::Trait, _) if macro_kind == MacroKind::Derive => {
|
||||||
|
"only a trait, without a derive macro".to_string()
|
||||||
|
}
|
||||||
|
res => format!(
|
||||||
"{} {}, not {} {}",
|
"{} {}, not {} {}",
|
||||||
res.article(),
|
res.article(),
|
||||||
res.descr(),
|
res.descr(),
|
||||||
|
|
|
@ -15,7 +15,7 @@ mod hey {
|
||||||
}
|
}
|
||||||
|
|
||||||
use hey::{Serialize, Deserialize, X};
|
use hey::{Serialize, Deserialize, X};
|
||||||
//~^ NOTE `Serialize` is imported here, but it is a trait
|
//~^ NOTE `Serialize` is imported here, but it is only a trait, without a derive macro
|
||||||
//~| NOTE `Deserialize` is imported here, but it is a trait
|
//~| NOTE `Deserialize` is imported here, but it is a trait
|
||||||
//~| NOTE `X` is imported here, but it is a struct
|
//~| NOTE `X` is imported here, but it is a struct
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ error: cannot find derive macro `Serialize` in this scope
|
||||||
LL | #[derive(Serialize)]
|
LL | #[derive(Serialize)]
|
||||||
| ^^^^^^^^^
|
| ^^^^^^^^^
|
||||||
|
|
|
|
||||||
note: `Serialize` is imported here, but it is a trait, not a derive macro
|
note: `Serialize` is imported here, but it is only a trait, without a derive macro
|
||||||
--> $DIR/issue-88206.rs:17:11
|
--> $DIR/issue-88206.rs:17:11
|
||||||
|
|
|
|
||||||
LL | use hey::{Serialize, Deserialize, X};
|
LL | use hey::{Serialize, Deserialize, X};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue