@@ -77,6 +77,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
7777 parent : Module < ' ra > ,
7878 ident : Ident ,
7979 ns : Namespace ,
80+ child_index : u32 ,
8081 res : Res ,
8182 vis : Visibility < DefId > ,
8283 span : Span ,
@@ -86,10 +87,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
8687 // Even if underscore names cannot be looked up, we still need to add them to modules,
8788 // because they can be fetched by glob imports from those modules, and bring traits
8889 // into scope both directly and through glob imports.
89- let key = BindingKey :: new_disambiguated ( ident, ns, || {
90- parent. underscore_disambiguator . update_unchecked ( |d| d + 1 ) ;
91- parent. underscore_disambiguator . get ( )
92- } ) ;
90+ let key = BindingKey :: new_disambiguated ( ident, ns, || child_index + 1 ) ; // 0 indicates no underscore
9391 if self
9492 . resolution_or_default ( parent, key)
9593 . borrow_mut_unchecked ( )
@@ -233,9 +231,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
233231 }
234232
235233 pub ( crate ) fn build_reduced_graph_external ( & self , module : Module < ' ra > ) {
236- for child in self . tcx . module_children ( module. def_id ( ) ) {
234+ for ( i , child) in self . tcx . module_children ( module. def_id ( ) ) . into_iter ( ) . enumerate ( ) {
237235 let parent_scope = ParentScope :: module ( module, self . arenas ) ;
238- self . build_reduced_graph_for_external_crate_res ( child, parent_scope)
236+ self . build_reduced_graph_for_external_crate_res (
237+ child,
238+ parent_scope,
239+ i. try_into ( ) . unwrap ( ) ,
240+ )
239241 }
240242 }
241243
@@ -244,6 +246,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
244246 & self ,
245247 child : & ModChild ,
246248 parent_scope : ParentScope < ' ra > ,
249+ child_index : u32 ,
247250 ) {
248251 let parent = parent_scope. module ;
249252 let ModChild { ident, res, vis, ref reexport_chain } = * child;
@@ -272,7 +275,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
272275 _,
273276 )
274277 | Res :: PrimTy ( ..)
275- | Res :: ToolMod => self . define_extern ( parent, ident, TypeNS , res, vis, span, expansion) ,
278+ | Res :: ToolMod => {
279+ self . define_extern ( parent, ident, TypeNS , child_index, res, vis, span, expansion)
280+ }
276281 Res :: Def (
277282 DefKind :: Fn
278283 | DefKind :: AssocFn
@@ -281,9 +286,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
281286 | DefKind :: AssocConst
282287 | DefKind :: Ctor ( ..) ,
283288 _,
284- ) => self . define_extern ( parent, ident, ValueNS , res, vis, span, expansion) ,
289+ ) => self . define_extern ( parent, ident, ValueNS , child_index , res, vis, span, expansion) ,
285290 Res :: Def ( DefKind :: Macro ( ..) , _) | Res :: NonMacroAttr ( ..) => {
286- self . define_extern ( parent, ident, MacroNS , res, vis, span, expansion)
291+ self . define_extern ( parent, ident, MacroNS , child_index , res, vis, span, expansion)
287292 }
288293 Res :: Def (
289294 DefKind :: TyParam
0 commit comments