@@ -240,7 +240,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
240240 return self . report_conflict ( ident, ns, new_binding, old_binding) ;
241241 }
242242
243- let container = match old_binding. parent_module . unwrap ( ) . kind {
243+ let container = match old_binding. parent_module . unwrap ( ) . expect_local ( ) . kind {
244244 // Avoid using TyCtxt::def_kind_descr in the resolver, because it
245245 // indirectly *calls* the resolver, and would cause a query cycle.
246246 ModuleKind :: Def ( kind, def_id, _, _) => kind. descr ( def_id) ,
@@ -2597,7 +2597,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
25972597 let module = module. to_module ( ) ;
25982598 current_module. is_ancestor_of ( module) && current_module != module
25992599 } )
2600- . flat_map ( |( _, module) | module. kind . name ( ) ) ,
2600+ . flat_map ( |( _, module) | module. name ( ) ) ,
26012601 )
26022602 . chain (
26032603 self . extern_module_map
@@ -2607,7 +2607,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
26072607 let module = module. to_module ( ) ;
26082608 current_module. is_ancestor_of ( module) && current_module != module
26092609 } )
2610- . flat_map ( |( _, module) | module. kind . name ( ) ) ,
2610+ . flat_map ( |( _, module) | module. name ( ) ) ,
26112611 )
26122612 . filter ( |c| !c. to_string ( ) . is_empty ( ) )
26132613 . collect :: < Vec < _ > > ( ) ;
@@ -2631,8 +2631,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
26312631 ) -> ( String , String , Option < Suggestion > ) {
26322632 let is_last = failed_segment_idx == path. len ( ) - 1 ;
26332633 let ns = if is_last { opt_ns. unwrap_or ( TypeNS ) } else { TypeNS } ;
2634- let module_res = match module {
2635- Some ( ModuleOrUniformRoot :: Module ( module) ) => module. res ( ) ,
2634+ let module_def_id = match module {
2635+ Some ( ModuleOrUniformRoot :: Module ( module) ) => module. opt_def_id ( ) ,
26362636 _ => None ,
26372637 } ;
26382638 let scope = match & path[ ..failed_segment_idx] {
@@ -2647,7 +2647,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
26472647 } ;
26482648 let message = format ! ( "cannot find `{ident}` in {scope}" ) ;
26492649
2650- if module_res == self . graph_root . res ( ) {
2650+ if module_def_id == Some ( CRATE_DEF_ID . to_def_id ( ) ) {
26512651 let is_mod = |res| matches ! ( res, Res :: Def ( DefKind :: Mod , _) ) ;
26522652 let mut candidates = self . lookup_import_candidates ( ident, TypeNS , parent_scope, is_mod) ;
26532653 candidates
@@ -3145,7 +3145,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
31453145 if !kinds. contains ( MacroKinds :: BANG ) {
31463146 return None ;
31473147 }
3148- let module_name = crate_module. kind . name ( ) . unwrap_or ( kw:: Crate ) ;
3148+ let module_name = crate_module. name ( ) . unwrap_or ( kw:: Crate ) ;
31493149 let import_snippet = match import. kind {
31503150 ImportKind :: Single { source, target, .. } if source != target => {
31513151 format ! ( "{source} as {target}" )
@@ -3290,20 +3290,23 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
32903290 return cached;
32913291 }
32923292 visited. insert ( parent_module, false ) ;
3293- let m = r. expect_module ( parent_module) ;
32943293 let mut res = false ;
3295- for importer in m. glob_importers . borrow ( ) . iter ( ) {
3296- if let Some ( next_parent_module) = importer. parent_scope . module . opt_def_id ( ) {
3297- if next_parent_module == module
3298- || comes_from_same_module_for_glob (
3299- r,
3300- next_parent_module,
3301- module,
3302- visited,
3303- )
3294+ let m = r. expect_module ( parent_module) ;
3295+ if m. is_local ( ) {
3296+ for importer in m. glob_importers . borrow ( ) . iter ( ) {
3297+ if let Some ( next_parent_module) = importer. parent_scope . module . opt_def_id ( )
33043298 {
3305- res = true ;
3306- break ;
3299+ if next_parent_module == module
3300+ || comes_from_same_module_for_glob (
3301+ r,
3302+ next_parent_module,
3303+ module,
3304+ visited,
3305+ )
3306+ {
3307+ res = true ;
3308+ break ;
3309+ }
33073310 }
33083311 }
33093312 }
0 commit comments