File tree 3 files changed +20
-10
lines changed
compiler/rustc_resolve/src
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> {
971
971
false ,
972
972
ident. span ,
973
973
) {
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 ! (
982
992
"{} {}, not {} {}" ,
983
993
res. article( ) ,
984
994
res. descr( ) ,
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ mod hey {
15
15
}
16
16
17
17
use 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
19
19
//~| NOTE `Deserialize` is imported here, but it is a trait
20
20
//~| NOTE `X` is imported here, but it is a struct
21
21
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ error: cannot find derive macro `Serialize` in this scope
104
104
LL | #[derive(Serialize)]
105
105
| ^^^^^^^^^
106
106
|
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
108
108
--> $DIR/issue-88206.rs:17:11
109
109
|
110
110
LL | use hey::{Serialize, Deserialize, X};
You can’t perform that action at this time.
0 commit comments