@@ -220,7 +220,7 @@ impl<'a> base::Resolver for Resolver<'a> {
220220 } ;
221221
222222 let parent_scope = self . invoc_parent_scope ( invoc_id, derives_in_scope) ;
223- let ( ext, res) = self . smart_resolve_macro_path ( path, kind, & parent_scope, true , force) ?;
223+ let ( ext, res) = self . smart_resolve_macro_path ( path, kind, & parent_scope, force) ?;
224224
225225 let span = invoc. span ( ) ;
226226 invoc. expansion_data . mark . set_expn_info ( ext. expn_info ( span, fast_print_path ( path) ) ) ;
@@ -269,10 +269,10 @@ impl<'a> Resolver<'a> {
269269 path : & ast:: Path ,
270270 kind : MacroKind ,
271271 parent_scope : & ParentScope < ' a > ,
272- trace : bool ,
273272 force : bool ,
274273 ) -> Result < ( Lrc < SyntaxExtension > , Res ) , Indeterminate > {
275- let ( ext, res) = match self . resolve_macro_path ( path, kind, parent_scope, trace, force) {
274+ let ( ext, res) = match self . resolve_macro_path ( path, Some ( kind) , parent_scope,
275+ true , force) {
276276 Ok ( ( Some ( ext) , res) ) => ( ext, res) ,
277277 // Use dummy syntax extensions for unresolved macros for better recovery.
278278 Ok ( ( None , res) ) => ( self . dummy_ext ( kind) , res) ,
@@ -334,7 +334,7 @@ impl<'a> Resolver<'a> {
334334 pub fn resolve_macro_path (
335335 & mut self ,
336336 path : & ast:: Path ,
337- kind : MacroKind ,
337+ kind : Option < MacroKind > ,
338338 parent_scope : & ParentScope < ' a > ,
339339 trace : bool ,
340340 force : bool ,
@@ -343,7 +343,7 @@ impl<'a> Resolver<'a> {
343343 let mut path = Segment :: from_path ( path) ;
344344
345345 // Possibly apply the macro helper hack
346- if kind == MacroKind :: Bang && path. len ( ) == 1 &&
346+ if kind == Some ( MacroKind :: Bang ) && path. len ( ) == 1 &&
347347 path[ 0 ] . ident . span . ctxt ( ) . outer_expn_info ( )
348348 . map_or ( false , |info| info. local_inner_macros ) {
349349 let root = Ident :: new ( kw:: DollarCrate , path[ 0 ] . ident . span ) ;
@@ -364,21 +364,25 @@ impl<'a> Resolver<'a> {
364364 } ;
365365
366366 if trace {
367+ let kind = kind. expect ( "macro kind must be specified if tracing is enabled" ) ;
367368 parent_scope. module . multi_segment_macro_resolutions . borrow_mut ( )
368369 . push ( ( path, path_span, kind, parent_scope. clone ( ) , res. ok ( ) ) ) ;
369370 }
370371
371372 self . prohibit_imported_non_macro_attrs ( None , res. ok ( ) , path_span) ;
372373 res
373374 } else {
375+ // Macro without a specific kind restriction is equvalent to a macro import.
376+ let scope_set = kind. map_or ( ScopeSet :: Import ( MacroNS ) , ScopeSet :: Macro ) ;
374377 let binding = self . early_resolve_ident_in_lexical_scope (
375- path[ 0 ] . ident , ScopeSet :: Macro ( kind ) , parent_scope, false , force, path_span
378+ path[ 0 ] . ident , scope_set , parent_scope, false , force, path_span
376379 ) ;
377380 if let Err ( Determinacy :: Undetermined ) = binding {
378381 return Err ( Determinacy :: Undetermined ) ;
379382 }
380383
381384 if trace {
385+ let kind = kind. expect ( "macro kind must be specified if tracing is enabled" ) ;
382386 parent_scope. module . single_segment_macro_resolutions . borrow_mut ( )
383387 . push ( ( path[ 0 ] . ident , kind, parent_scope. clone ( ) , binding. ok ( ) ) ) ;
384388 }
@@ -452,7 +456,7 @@ impl<'a> Resolver<'a> {
452456 let mut result = Err ( Determinacy :: Determined ) ;
453457 for derive in & parent_scope. derives {
454458 let parent_scope = ParentScope { derives : Vec :: new ( ) , ..* parent_scope } ;
455- match this. resolve_macro_path ( derive, MacroKind :: Derive ,
459+ match this. resolve_macro_path ( derive, Some ( MacroKind :: Derive ) ,
456460 & parent_scope, true , force) {
457461 Ok ( ( Some ( ext) , _) ) => if ext. helper_attrs . contains ( & ident. name ) {
458462 let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ,
0 commit comments