@@ -34,7 +34,7 @@ use syntax::attr;
34
34
35
35
use syntax:: ast:: { self , Block , ForeignItem , ForeignItemKind , Item , ItemKind , NodeId } ;
36
36
use syntax:: ast:: { Mutability , StmtKind , TraitItem , TraitItemKind , Variant } ;
37
- use syntax:: ext:: base:: SyntaxExtension ;
37
+ use syntax:: ext:: base:: { MacroKind , SyntaxExtension } ;
38
38
use syntax:: ext:: base:: Determinacy :: Undetermined ;
39
39
use syntax:: ext:: hygiene:: Mark ;
40
40
use syntax:: ext:: tt:: macro_rules;
@@ -335,6 +335,24 @@ impl<'a> Resolver<'a> {
335
335
ItemKind :: Fn ( ..) => {
336
336
let def = Def :: Fn ( self . definitions . local_def_id ( item. id ) ) ;
337
337
self . define ( parent, ident, ValueNS , ( def, vis, sp, expansion) ) ;
338
+
339
+ // Functions introducing procedural macros reserve a slot
340
+ // in the macro namespace as well (see #52225).
341
+ if attr:: contains_name ( & item. attrs , "proc_macro" ) ||
342
+ attr:: contains_name ( & item. attrs , "proc_macro_attribute" ) {
343
+ let def = Def :: Macro ( def. def_id ( ) , MacroKind :: ProcMacroStub ) ;
344
+ self . define ( parent, ident, MacroNS , ( def, vis, sp, expansion) ) ;
345
+ }
346
+ if let Some ( attr) = attr:: find_by_name ( & item. attrs , "proc_macro_derive" ) {
347
+ if let Some ( trait_attr) =
348
+ attr. meta_item_list ( ) . and_then ( |list| list. get ( 0 ) . cloned ( ) ) {
349
+ if let Some ( ident) = trait_attr. name ( ) . map ( Ident :: with_empty_ctxt) {
350
+ let sp = trait_attr. span ;
351
+ let def = Def :: Macro ( def. def_id ( ) , MacroKind :: ProcMacroStub ) ;
352
+ self . define ( parent, ident, MacroNS , ( def, vis, sp, expansion) ) ;
353
+ }
354
+ }
355
+ }
338
356
}
339
357
340
358
// These items live in the type namespace.
0 commit comments