@@ -1198,28 +1198,28 @@ pub struct Resolver<'ra, 'tcx> {
11981198 // FIXME: Remove interior mutability when speculative resolution produces these as outputs.
11991199 single_segment_macro_resolutions :
12001200 RefCell < Vec < ( Ident , MacroKind , ParentScope < ' ra > , Option < NameBinding < ' ra > > , Option < Span > ) > > ,
1201- multi_segment_macro_resolutions :
1202- RefCell < Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > > ,
1203- builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > ,
1204- /// `derive(Copy)` marks items they are applied to so they are treated specially later.
1205- /// Derive macros cannot modify the item themselves and have to store the markers in the global
1206- /// context, so they attach the markers to derive container IDs using this resolver table.
1207- containers_deriving_copy : FxHashSet < LocalExpnId > ,
1208- /// Parent scopes in which the macros were invoked.
1209- /// FIXME: `derives` are missing in these parent scopes and need to be taken from elsewhere.
1210- invocation_parent_scopes : FxHashMap < LocalExpnId , ParentScope < ' ra > > ,
1211- /// `macro_rules` scopes *produced* by expanding the macro invocations,
1212- /// include all the `macro_rules` items and other invocations generated by them.
1213- output_macro_rules_scopes : FxHashMap < LocalExpnId , MacroRulesScopeRef < ' ra > > ,
1214- /// `macro_rules` scopes produced by `macro_rules` item definitions.
1215- macro_rules_scopes : FxHashMap < LocalDefId , MacroRulesScopeRef < ' ra > > ,
1216- /// Helper attributes that are in scope for the given expansion.
1217- helper_attrs : FxHashMap < LocalExpnId , Vec < ( Ident , NameBinding < ' ra > ) > > ,
1218- /// Ready or in-progress results of resolving paths inside the `#[derive(...)]` attribute
1219- /// with the given `ExpnId`.
1220- derive_data : FxHashMap < LocalExpnId , DeriveData > ,
1221-
1222- /// Avoid duplicated errors for "name already defined".
1201+ multi_segment_macro_resolutions :
1202+ RefCell < Vec < ( Vec < Segment > , Span , MacroKind , ParentScope < ' ra > , Option < Res > , Namespace ) > > ,
1203+ builtin_attrs : Vec < ( Ident , ParentScope < ' ra > ) > ,
1204+ /// `derive(Copy)` marks items they are applied to so they are treated specially later.
1205+ /// Derive macros cannot modify the item themselves and have to store the markers in the global
1206+ /// context, so they attach the markers to derive container IDs using this resolver table.
1207+ containers_deriving_copy : FxHashSet < LocalExpnId > ,
1208+ /// Parent scopes in which the macros were invoked.
1209+ /// FIXME: `derives` are missing in these parent scopes and need to be taken from elsewhere.
1210+ invocation_parent_scopes : FxHashMap < LocalExpnId , ParentScope < ' ra > > ,
1211+ /// `macro_rules` scopes *produced* by expanding the macro invocations,
1212+ /// include all the `macro_rules` items and other invocations generated by them.
1213+ output_macro_rules_scopes : FxHashMap < LocalExpnId , MacroRulesScopeRef < ' ra > > ,
1214+ /// `macro_rules` scopes produced by `macro_rules` item definitions.
1215+ macro_rules_scopes : FxHashMap < LocalDefId , MacroRulesScopeRef < ' ra > > ,
1216+ /// Helper attributes that are in scope for the given expansion.
1217+ helper_attrs : FxHashMap < LocalExpnId , Vec < ( Ident , NameBinding < ' ra > ) > > ,
1218+ /// Ready or in-progress results of resolving paths inside the `#[derive(...)]` attribute
1219+ /// with the given `ExpnId`.
1220+ derive_data : FxHashMap < LocalExpnId , DeriveData > ,
1221+
1222+ /// Avoid duplicated errors for "name already defined".
12231223 name_already_seen : FxHashMap < Symbol , Span > ,
12241224
12251225 potentially_unused_imports : Vec < Import < ' ra > > = Vec :: new ( ) ,
@@ -2226,16 +2226,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22262226 // Some non-controversial subset of ambiguities "modularized macro name" vs "macro_rules"
22272227 // is disambiguated to mitigate regressions from macro modularization.
22282228 // Scoping for `macro_rules` behaves like scoping for `let` at module level, in general.
2229- match (
2230- self . binding_parent_modules . get ( & macro_rules) ,
2231- self . binding_parent_modules . get ( & modularized) ,
2232- ) {
2233- ( Some ( macro_rules) , Some ( modularized) ) => {
2234- macro_rules. nearest_parent_mod ( ) == modularized. nearest_parent_mod ( )
2235- && modularized. is_ancestor_of ( * macro_rules)
2236- }
2237- _ => false ,
2238- }
2229+ //
2230+ // panic on index should be impossible, the only name_bindings passed in should be from
2231+ // `resolve_ident_in_scope_set` which will always refer to a local binding from an
2232+ // import or macro definition
2233+ let macro_rules = & self . binding_parent_modules [ & macro_rules] ;
2234+ let modularized = & self . binding_parent_modules [ & modularized] ;
2235+ macro_rules. nearest_parent_mod ( ) == modularized. nearest_parent_mod ( )
2236+ && modularized. is_ancestor_of ( * macro_rules)
22392237 }
22402238
22412239 fn extern_prelude_get_item < ' r > (
0 commit comments