@@ -81,7 +81,7 @@ use std::mem::replace;
81
81
use rustc_data_structures:: sync:: Lrc ;
82
82
83
83
use resolve_imports:: { ImportDirective , ImportDirectiveSubclass , NameResolution , ImportResolver } ;
84
- use macros:: { InvocationData , LegacyBinding } ;
84
+ use macros:: { InvocationData , LegacyBinding , LegacyScope } ;
85
85
86
86
// NB: This module needs to be declared first so diagnostics are
87
87
// registered before they are used.
@@ -1010,8 +1010,9 @@ pub struct ModuleData<'a> {
1010
1010
normal_ancestor_id : DefId ,
1011
1011
1012
1012
resolutions : RefCell < FxHashMap < ( Ident , Namespace ) , & ' a RefCell < NameResolution < ' a > > > > ,
1013
- legacy_macro_resolutions : RefCell < Vec < ( Mark , Ident , MacroKind , Option < Def > ) > > ,
1013
+ legacy_macro_resolutions : RefCell < Vec < ( Ident , MacroKind , Mark , LegacyScope < ' a > , Option < Def > ) > > ,
1014
1014
macro_resolutions : RefCell < Vec < ( Box < [ Ident ] > , Span ) > > ,
1015
+ builtin_attrs : RefCell < Vec < ( Ident , Mark , LegacyScope < ' a > ) > > ,
1015
1016
1016
1017
// Macro invocations that can expand into items in this module.
1017
1018
unresolved_invocations : RefCell < FxHashSet < Mark > > ,
@@ -1050,6 +1051,7 @@ impl<'a> ModuleData<'a> {
1050
1051
resolutions : RefCell :: new ( FxHashMap ( ) ) ,
1051
1052
legacy_macro_resolutions : RefCell :: new ( Vec :: new ( ) ) ,
1052
1053
macro_resolutions : RefCell :: new ( Vec :: new ( ) ) ,
1054
+ builtin_attrs : RefCell :: new ( Vec :: new ( ) ) ,
1053
1055
unresolved_invocations : RefCell :: new ( FxHashSet ( ) ) ,
1054
1056
no_implicit_prelude : false ,
1055
1057
glob_importers : RefCell :: new ( Vec :: new ( ) ) ,
@@ -1268,6 +1270,7 @@ impl<'a> NameBinding<'a> {
1268
1270
fn macro_kind ( & self ) -> Option < MacroKind > {
1269
1271
match self . def_ignoring_ambiguity ( ) {
1270
1272
Def :: Macro ( _, kind) => Some ( kind) ,
1273
+ Def :: NonMacroAttr ( ..) => Some ( MacroKind :: Attr ) ,
1271
1274
_ => None ,
1272
1275
}
1273
1276
}
@@ -1276,19 +1279,18 @@ impl<'a> NameBinding<'a> {
1276
1279
if self . is_extern_crate ( ) { "extern crate" } else { self . def ( ) . kind_name ( ) }
1277
1280
}
1278
1281
1279
- // Suppose that we resolved macro invocation with `invoc_id ` to binding `binding` at some
1280
- // expansion round `max(invoc_id , binding)` when they both emerged from macros.
1282
+ // Suppose that we resolved macro invocation with `invoc_parent_expansion ` to binding `binding`
1283
+ // at some expansion round `max(invoc , binding)` when they both emerged from macros.
1281
1284
// Then this function returns `true` if `self` may emerge from a macro *after* that
1282
1285
// in some later round and screw up our previously found resolution.
1283
1286
// See more detailed explanation in
1284
1287
// https://github.com/rust-lang/rust/pull/53778#issuecomment-419224049
1285
- fn may_appear_after ( & self , invoc_id : Mark , binding : & NameBinding ) -> bool {
1286
- // self > max(invoc_id , binding) => !(self <= invoc_id || self <= binding)
1288
+ fn may_appear_after ( & self , invoc_parent_expansion : Mark , binding : & NameBinding ) -> bool {
1289
+ // self > max(invoc , binding) => !(self <= invoc || self <= binding)
1287
1290
// Expansions are partially ordered, so "may appear after" is an inversion of
1288
1291
// "certainly appears before or simultaneously" and includes unordered cases.
1289
1292
let self_parent_expansion = self . expansion ;
1290
1293
let other_parent_expansion = binding. expansion ;
1291
- let invoc_parent_expansion = invoc_id. parent ( ) ;
1292
1294
let certainly_before_other_or_simultaneously =
1293
1295
other_parent_expansion. is_descendant_of ( self_parent_expansion) ;
1294
1296
let certainly_before_invoc_or_simultaneously =
@@ -3493,16 +3495,16 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3493
3495
path_span : Span ,
3494
3496
crate_lint : CrateLint ,
3495
3497
) -> PathResult < ' a > {
3496
- self . resolve_path_with_invoc_id ( base_module, path, opt_ns, Mark :: root ( ) ,
3497
- record_used, path_span, crate_lint)
3498
+ self . resolve_path_with_parent_expansion ( base_module, path, opt_ns, Mark :: root ( ) ,
3499
+ record_used, path_span, crate_lint)
3498
3500
}
3499
3501
3500
- fn resolve_path_with_invoc_id (
3502
+ fn resolve_path_with_parent_expansion (
3501
3503
& mut self ,
3502
3504
base_module : Option < ModuleOrUniformRoot < ' a > > ,
3503
3505
path : & [ Ident ] ,
3504
3506
opt_ns : Option < Namespace > , // `None` indicates a module path
3505
- invoc_id : Mark ,
3507
+ parent_expansion : Mark ,
3506
3508
record_used : bool ,
3507
3509
path_span : Span ,
3508
3510
crate_lint : CrateLint ,
@@ -3595,8 +3597,8 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
3595
3597
self . resolve_ident_in_module ( module, ident, ns, record_used, path_span)
3596
3598
} else if opt_ns == Some ( MacroNS ) {
3597
3599
assert ! ( ns == TypeNS ) ;
3598
- self . resolve_lexical_macro_path_segment ( ident, ns, invoc_id , record_used ,
3599
- record_used, false , path_span)
3600
+ self . resolve_lexical_macro_path_segment ( ident, ns, None , parent_expansion ,
3601
+ record_used, record_used , path_span)
3600
3602
. map ( |( binding, _) | binding)
3601
3603
} else {
3602
3604
let record_used_id =
0 commit comments