File tree Expand file tree Collapse file tree 3 files changed +20
-10
lines changed
compiler/rustc_resolve/src Expand file tree Collapse file tree 3 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -971,14 +971,24 @@ impl<'a> Resolver<'a> {
971971 false ,
972972 ident. span ,
973973 ) {
974- let res = binding. res ( ) ;
975- let desc = match res. macro_kind ( ) {
976- Some ( MacroKind :: Bang ) => "a function-like macro" . to_string ( ) ,
977- Some ( MacroKind :: Attr ) => format ! ( "an attribute: `#[{}]`" , ident) ,
978- Some ( MacroKind :: Derive ) => format ! ( "a derive macro: `#[derive({})]`" , ident) ,
979- // Don't confuse the user with tool modules.
980- None if res == Res :: ToolMod => continue ,
981- None => format ! (
974+ let desc = match binding. res ( ) {
975+ Res :: Def ( DefKind :: Macro ( MacroKind :: Bang ) , _) => {
976+ "a function-like macro" . to_string ( )
977+ }
978+ Res :: Def ( DefKind :: Macro ( MacroKind :: Attr ) , _) | Res :: NonMacroAttr ( ..) => {
979+ format ! ( "an attribute: `#[{}]`" , ident)
980+ }
981+ Res :: Def ( DefKind :: Macro ( MacroKind :: Derive ) , _) => {
982+ format ! ( "a derive macro: `#[derive({})]`" , ident)
983+ }
984+ Res :: ToolMod => {
985+ // Don't confuse the user with tool modules.
986+ continue ;
987+ }
988+ Res :: Def ( DefKind :: Trait , _) if macro_kind == MacroKind :: Derive => {
989+ "only a trait, without a derive macro" . to_string ( )
990+ }
991+ res => format ! (
982992 "{} {}, not {} {}" ,
983993 res. article( ) ,
984994 res. descr( ) ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ mod hey {
1515}
1616
1717use hey:: { Serialize , Deserialize , X } ;
18- //~^ NOTE `Serialize` is imported here, but it is a trait
18+ //~^ NOTE `Serialize` is imported here, but it is only a trait, without a derive macro
1919//~| NOTE `Deserialize` is imported here, but it is a trait
2020//~| NOTE `X` is imported here, but it is a struct
2121
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ error: cannot find derive macro `Serialize` in this scope
104104LL | #[derive(Serialize)]
105105 | ^^^^^^^^^
106106 |
107- note: `Serialize` is imported here, but it is a trait, not a derive macro
107+ note: `Serialize` is imported here, but it is only a trait, without a derive macro
108108 --> $DIR/issue-88206.rs:17:11
109109 |
110110LL | use hey::{Serialize, Deserialize, X};
You can’t perform that action at this time.
0 commit comments