@@ -1124,10 +1124,13 @@ impl DefCollector<'_> {
1124
1124
}
1125
1125
}
1126
1126
1127
- let def = resolver ( path. clone ( ) ) . filter ( MacroDefId :: is_attribute) ;
1127
+ let def = match resolver ( path. clone ( ) ) {
1128
+ Some ( def) if def. is_attribute ( ) => def,
1129
+ _ => return true ,
1130
+ } ;
1128
1131
if matches ! (
1129
1132
def,
1130
- Some ( MacroDefId { kind: MacroDefKind :: BuiltInAttr ( expander, _) , .. } )
1133
+ MacroDefId { kind: MacroDefKind :: BuiltInAttr ( expander, _) , .. }
1131
1134
if expander. is_derive( )
1132
1135
) {
1133
1136
// Resolved to `#[derive]`
@@ -1184,52 +1187,46 @@ impl DefCollector<'_> {
1184
1187
return true ;
1185
1188
}
1186
1189
1187
- // Not resolved to a derive helper or the derive attribute, so try to resolve as a normal attribute.
1188
- match attr_macro_as_call_id ( file_ast_id, attr, self . db , self . def_map . krate , def)
1189
- {
1190
- Ok ( call_id) => {
1191
- let loc: MacroCallLoc = self . db . lookup_intern_macro_call ( call_id) ;
1192
-
1193
- // Skip #[test]/#[bench] expansion, which would merely result in more memory usage
1194
- // due to duplicating functions into macro expansions
1195
- if matches ! (
1196
- loc. def. kind,
1197
- MacroDefKind :: BuiltInAttr ( expander, _)
1198
- if expander. is_test( ) || expander. is_bench( )
1199
- ) {
1200
- return recollect_without ( self ) ;
1201
- }
1202
-
1203
- if let MacroDefKind :: ProcMacro ( exp, ..) = loc. def . kind {
1204
- if exp. is_dummy ( ) {
1205
- // Proc macros that cannot be expanded are treated as not
1206
- // resolved, in order to fall back later.
1207
- self . def_map . diagnostics . push (
1208
- DefDiagnostic :: unresolved_proc_macro (
1209
- directive. module_id ,
1210
- loc. kind ,
1211
- ) ,
1212
- ) ;
1213
-
1214
- return recollect_without ( self ) ;
1215
- }
1216
- }
1190
+ // Not resolved to a derive helper or the derive attribute, so try to treat as a normal attribute.
1191
+ let call_id =
1192
+ attr_macro_as_call_id ( file_ast_id, attr, self . db , self . def_map . krate , def) ;
1193
+ let loc: MacroCallLoc = self . db . lookup_intern_macro_call ( call_id) ;
1217
1194
1218
- self . def_map . modules [ directive. module_id ]
1219
- . scope
1220
- . add_attr_macro_invoc ( ast_id, call_id) ;
1195
+ // Skip #[test]/#[bench] expansion, which would merely result in more memory usage
1196
+ // due to duplicating functions into macro expansions
1197
+ if matches ! (
1198
+ loc. def. kind,
1199
+ MacroDefKind :: BuiltInAttr ( expander, _)
1200
+ if expander. is_test( ) || expander. is_bench( )
1201
+ ) {
1202
+ return recollect_without ( self ) ;
1203
+ }
1221
1204
1222
- resolved. push ( (
1205
+ if let MacroDefKind :: ProcMacro ( exp, ..) = loc. def . kind {
1206
+ if exp. is_dummy ( ) {
1207
+ // Proc macros that cannot be expanded are treated as not
1208
+ // resolved, in order to fall back later.
1209
+ self . def_map . diagnostics . push ( DefDiagnostic :: unresolved_proc_macro (
1223
1210
directive. module_id ,
1224
- call_id,
1225
- directive. depth ,
1226
- directive. container ,
1211
+ loc. kind ,
1227
1212
) ) ;
1228
- res = ReachedFixedPoint :: No ;
1229
- return false ;
1213
+
1214
+ return recollect_without ( self ) ;
1230
1215
}
1231
- Err ( UnresolvedMacro { .. } ) => ( ) ,
1232
1216
}
1217
+
1218
+ self . def_map . modules [ directive. module_id ]
1219
+ . scope
1220
+ . add_attr_macro_invoc ( ast_id, call_id) ;
1221
+
1222
+ resolved. push ( (
1223
+ directive. module_id ,
1224
+ call_id,
1225
+ directive. depth ,
1226
+ directive. container ,
1227
+ ) ) ;
1228
+ res = ReachedFixedPoint :: No ;
1229
+ return false ;
1233
1230
}
1234
1231
}
1235
1232
0 commit comments