@@ -220,7 +220,7 @@ impl<'a> base::Resolver for Resolver<'a> {
220
220
} ;
221
221
222
222
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) ?;
224
224
225
225
let span = invoc. span ( ) ;
226
226
invoc. expansion_data . mark . set_expn_info ( ext. expn_info ( span, fast_print_path ( path) ) ) ;
@@ -269,10 +269,10 @@ impl<'a> Resolver<'a> {
269
269
path : & ast:: Path ,
270
270
kind : MacroKind ,
271
271
parent_scope : & ParentScope < ' a > ,
272
- trace : bool ,
273
272
force : bool ,
274
273
) -> 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) {
276
276
Ok ( ( Some ( ext) , res) ) => ( ext, res) ,
277
277
// Use dummy syntax extensions for unresolved macros for better recovery.
278
278
Ok ( ( None , res) ) => ( self . dummy_ext ( kind) , res) ,
@@ -334,7 +334,7 @@ impl<'a> Resolver<'a> {
334
334
pub fn resolve_macro_path (
335
335
& mut self ,
336
336
path : & ast:: Path ,
337
- kind : MacroKind ,
337
+ kind : Option < MacroKind > ,
338
338
parent_scope : & ParentScope < ' a > ,
339
339
trace : bool ,
340
340
force : bool ,
@@ -343,7 +343,7 @@ impl<'a> Resolver<'a> {
343
343
let mut path = Segment :: from_path ( path) ;
344
344
345
345
// Possibly apply the macro helper hack
346
- if kind == MacroKind :: Bang && path. len ( ) == 1 &&
346
+ if kind == Some ( MacroKind :: Bang ) && path. len ( ) == 1 &&
347
347
path[ 0 ] . ident . span . ctxt ( ) . outer_expn_info ( )
348
348
. map_or ( false , |info| info. local_inner_macros ) {
349
349
let root = Ident :: new ( kw:: DollarCrate , path[ 0 ] . ident . span ) ;
@@ -364,21 +364,25 @@ impl<'a> Resolver<'a> {
364
364
} ;
365
365
366
366
if trace {
367
+ let kind = kind. expect ( "macro kind must be specified if tracing is enabled" ) ;
367
368
parent_scope. module . multi_segment_macro_resolutions . borrow_mut ( )
368
369
. push ( ( path, path_span, kind, parent_scope. clone ( ) , res. ok ( ) ) ) ;
369
370
}
370
371
371
372
self . prohibit_imported_non_macro_attrs ( None , res. ok ( ) , path_span) ;
372
373
res
373
374
} 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 ) ;
374
377
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
376
379
) ;
377
380
if let Err ( Determinacy :: Undetermined ) = binding {
378
381
return Err ( Determinacy :: Undetermined ) ;
379
382
}
380
383
381
384
if trace {
385
+ let kind = kind. expect ( "macro kind must be specified if tracing is enabled" ) ;
382
386
parent_scope. module . single_segment_macro_resolutions . borrow_mut ( )
383
387
. push ( ( path[ 0 ] . ident , kind, parent_scope. clone ( ) , binding. ok ( ) ) ) ;
384
388
}
@@ -452,7 +456,7 @@ impl<'a> Resolver<'a> {
452
456
let mut result = Err ( Determinacy :: Determined ) ;
453
457
for derive in & parent_scope. derives {
454
458
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 ) ,
456
460
& parent_scope, true , force) {
457
461
Ok ( ( Some ( ext) , _) ) => if ext. helper_attrs . contains ( & ident. name ) {
458
462
let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ,
0 commit comments