@@ -61,7 +61,7 @@ pub struct ItemScope {
6161 /// Module scoped macros will be inserted into `items` instead of here.
6262 // FIXME: Macro shadowing in one module is not properly handled. Non-item place macros will
6363 // be all resolved to the last one defined if shadowing happens.
64- legacy_macros : FxHashMap < Name , MacroId > ,
64+ legacy_macros : FxHashMap < Name , SmallVec < [ MacroId ; 1 ] > > ,
6565 /// The derive macro invocations in this scope.
6666 attr_macros : FxHashMap < AstId < ast:: Item > , MacroCallId > ,
6767 /// The derive macro invocations in this scope, keyed by the owner item over the actual derive attributes
@@ -129,13 +129,13 @@ impl ItemScope {
129129 }
130130
131131 /// Iterate over all module scoped macros
132- pub ( crate ) fn macros < ' a > ( & ' a self ) -> impl Iterator < Item = ( & ' a Name , MacroId ) > + ' a {
132+ pub ( crate ) fn macros ( & self ) -> impl Iterator < Item = ( & Name , MacroId ) > + ' _ {
133133 self . entries ( ) . filter_map ( |( name, def) | def. take_macros ( ) . map ( |macro_| ( name, macro_) ) )
134134 }
135135
136136 /// Iterate over all legacy textual scoped macros visible at the end of the module
137- pub fn legacy_macros < ' a > ( & ' a self ) -> impl Iterator < Item = ( & ' a Name , MacroId ) > + ' a {
138- self . legacy_macros . iter ( ) . map ( |( name, def) | ( name, * def) )
137+ pub fn legacy_macros ( & self ) -> impl Iterator < Item = ( & Name , & [ MacroId ] ) > + ' _ {
138+ self . legacy_macros . iter ( ) . map ( |( name, def) | ( name, & * * def) )
139139 }
140140
141141 /// Get a name from current module scope, legacy macros are not included
@@ -180,8 +180,8 @@ impl ItemScope {
180180 self . declarations . push ( def)
181181 }
182182
183- pub ( crate ) fn get_legacy_macro ( & self , name : & Name ) -> Option < MacroId > {
184- self . legacy_macros . get ( name) . copied ( )
183+ pub ( crate ) fn get_legacy_macro ( & self , name : & Name ) -> Option < & [ MacroId ] > {
184+ self . legacy_macros . get ( name) . map ( |it| & * * it )
185185 }
186186
187187 pub ( crate ) fn define_impl ( & mut self , imp : ImplId ) {
@@ -193,7 +193,7 @@ impl ItemScope {
193193 }
194194
195195 pub ( crate ) fn define_legacy_macro ( & mut self , name : Name , mac : MacroId ) {
196- self . legacy_macros . insert ( name, mac) ;
196+ self . legacy_macros . entry ( name) . or_default ( ) . push ( mac) ;
197197 }
198198
199199 pub ( crate ) fn add_attr_macro_invoc ( & mut self , item : AstId < ast:: Item > , call : MacroCallId ) {
@@ -322,7 +322,7 @@ impl ItemScope {
322322 )
323323 }
324324
325- pub ( crate ) fn collect_legacy_macros ( & self ) -> FxHashMap < Name , MacroId > {
325+ pub ( crate ) fn collect_legacy_macros ( & self ) -> FxHashMap < Name , SmallVec < [ MacroId ; 1 ] > > {
326326 self . legacy_macros . clone ( )
327327 }
328328
0 commit comments