@@ -70,12 +70,12 @@ use syntax::{ast, SmolStr};
7070use crate :: {
7171 db:: DefDatabase ,
7272 item_scope:: { BuiltinShadowMode , ItemScope } ,
73- item_tree:: TreeId ,
73+ item_tree:: { self , ItemTreeId , TreeId } ,
7474 nameres:: { diagnostics:: DefDiagnostic , path_resolution:: ResolveMode } ,
7575 path:: ModPath ,
7676 per_ns:: PerNs ,
7777 visibility:: Visibility ,
78- AstId , BlockId , BlockLoc , LocalModuleId , ModuleDefId , ModuleId ,
78+ AstId , BlockId , BlockLoc , LocalModuleId , ModuleDefId , ModuleId , ProcMacroId ,
7979} ;
8080
8181/// Contains the results of (early) name resolution.
@@ -102,6 +102,7 @@ pub struct DefMap {
102102
103103 /// Side table for resolving derive helpers.
104104 exported_derives : FxHashMap < MacroDefId , Box < [ Name ] > > ,
105+ fn_proc_macro_mapping : FxHashMap < ItemTreeId < item_tree:: Function > , ProcMacroId > ,
105106
106107 /// Custom attributes registered with `#![register_attr]`.
107108 registered_attrs : Vec < SmolStr > ,
@@ -271,6 +272,7 @@ impl DefMap {
271272 recursion_limit : None ,
272273 extern_prelude : FxHashMap :: default ( ) ,
273274 exported_derives : FxHashMap :: default ( ) ,
275+ fn_proc_macro_mapping : FxHashMap :: default ( ) ,
274276 prelude : None ,
275277 root,
276278 modules,
@@ -300,6 +302,11 @@ impl DefMap {
300302 self . root
301303 }
302304
305+ // FIXME: This is an odd interface....
306+ pub fn fn_as_proc_macro ( & self , id : ItemTreeId < item_tree:: Function > ) -> Option < ProcMacroId > {
307+ self . fn_proc_macro_mapping . get ( & id) . copied ( )
308+ }
309+
303310 pub ( crate ) fn krate ( & self ) -> CrateId {
304311 self . krate
305312 }
@@ -453,6 +460,7 @@ impl DefMap {
453460 modules,
454461 registered_attrs,
455462 registered_tools,
463+ fn_proc_macro_mapping,
456464 block : _,
457465 edition : _,
458466 recursion_limit : _,
@@ -467,6 +475,7 @@ impl DefMap {
467475 modules. shrink_to_fit ( ) ;
468476 registered_attrs. shrink_to_fit ( ) ;
469477 registered_tools. shrink_to_fit ( ) ;
478+ fn_proc_macro_mapping. shrink_to_fit ( ) ;
470479 for ( _, module) in modules. iter_mut ( ) {
471480 module. children . shrink_to_fit ( ) ;
472481 module. scope . shrink_to_fit ( ) ;
0 commit comments