@@ -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) ,
@@ -1757,15 +1757,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17571757 }
17581758 return ;
17591759 }
1760- if Some ( parent_nearest) == scope. opt_def_id ( ) {
1760+ if Some ( parent_nearest) == scope. kind . opt_def_id ( ) {
17611761 err. subdiagnostic ( MacroDefinedLater { span : unused_ident. span } ) ;
17621762 err. subdiagnostic ( MacroSuggMovePosition { span : ident. span , ident } ) ;
17631763 return ;
17641764 }
17651765 }
17661766
17671767 if ident. name == kw:: Default
1768- && let ModuleKind :: Def ( DefKind :: Enum , def_id, _, _) = parent_scope. module . kind
1768+ && let ModuleKind :: Def ( DefKind :: Enum , def_id, _, _) = parent_scope. module . kind ( )
17691769 {
17701770 let span = self . def_span ( def_id) ;
17711771 let source_map = self . tcx . sess . source_map ( ) ;
@@ -1894,7 +1894,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18941894 ident. name,
18951895 ) ;
18961896 let sugg_span =
1897- if let ModuleKind :: Def ( DefKind :: Enum , id, _, _) = parent_scope. module . kind {
1897+ if let ModuleKind :: Def ( DefKind :: Enum , id, _, _) = parent_scope. module . kind ( ) {
18981898 let span = self . def_span ( id) ;
18991899 if span. from_expansion ( ) {
19001900 None
@@ -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+ . 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
@@ -3128,7 +3128,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
31283128 return None ;
31293129 } ;
31303130
3131- while let Some ( parent) = crate_module. parent {
3131+ while let Some ( parent) = crate_module. parent ( ) {
31323132 crate_module = parent;
31333133 }
31343134
@@ -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,22 @@ 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+ if let Some ( m) = r. expect_module ( parent_module) . as_local ( ) {
3295+ for importer in m. glob_importers . borrow ( ) . iter ( ) {
3296+ if let Some ( next_parent_module) = importer. parent_scope . module . opt_def_id ( )
33043297 {
3305- res = true ;
3306- break ;
3298+ if next_parent_module == module
3299+ || comes_from_same_module_for_glob (
3300+ r,
3301+ next_parent_module,
3302+ module,
3303+ visited,
3304+ )
3305+ {
3306+ res = true ;
3307+ break ;
3308+ }
33073309 }
33083310 }
33093311 }
0 commit comments