@@ -39,8 +39,8 @@ use crate::late::{
3939} ;
4040use crate :: ty:: fast_reject:: SimplifiedType ;
4141use crate :: {
42- Module , ModuleKind , ModuleOrUniformRoot , PathResult , PathSource , Resolver , Segment , errors ,
43- path_names_to_string,
42+ Module , ModuleKind , ModuleOrUniformRoot , PathResult , PathSource , Resolver , ScopeSet , Segment ,
43+ errors , path_names_to_string,
4444} ;
4545
4646type Res = def:: Res < ast:: NodeId > ;
@@ -2459,45 +2459,30 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
24592459 }
24602460 }
24612461
2462+ if let RibKind :: Module ( module) = rib. kind
2463+ && let ModuleKind :: Block = module. kind
2464+ {
2465+ self . r . add_module_candidates ( module, & mut names, & filter_fn, Some ( ctxt) ) ;
2466+ } else if let RibKind :: Module ( module) = rib. kind {
2467+ // Encountered a module item, abandon ribs and look into that module and preludes.
2468+ self . r . add_scope_set_candidates (
2469+ & mut names,
2470+ ScopeSet :: Late ( ns, module, None ) ,
2471+ & self . parent_scope ,
2472+ ctxt,
2473+ filter_fn,
2474+ ) ;
2475+ break ;
2476+ }
2477+
24622478 if let RibKind :: MacroDefinition ( def) = rib. kind
24632479 && def == self . r . macro_def ( ctxt)
24642480 {
24652481 // If an invocation of this macro created `ident`, give up on `ident`
24662482 // and switch to `ident`'s source from the macro definition.
24672483 ctxt. remove_mark ( ) ;
2468- continue ;
2469- }
2470-
2471- // Items in scope
2472- if let RibKind :: Module ( module) = rib. kind {
2473- // Items from this module
2474- self . r . add_module_candidates ( module, & mut names, & filter_fn, Some ( ctxt) ) ;
2475-
2476- if let ModuleKind :: Block = module. kind {
2477- // We can see through blocks
2478- } else {
2479- // Items from the prelude
2480- if !module. no_implicit_prelude {
2481- names. extend ( self . r . extern_prelude . keys ( ) . flat_map ( |ident| {
2482- let res = Res :: Def ( DefKind :: Mod , CRATE_DEF_ID . to_def_id ( ) ) ;
2483- filter_fn ( res)
2484- . then_some ( TypoSuggestion :: typo_from_ident ( ident. 0 , res) )
2485- } ) ) ;
2486-
2487- if let Some ( prelude) = self . r . prelude {
2488- self . r . add_module_candidates ( prelude, & mut names, & filter_fn, None ) ;
2489- }
2490- }
2491- break ;
2492- }
24932484 }
24942485 }
2495- // Add primitive types to the mix
2496- if filter_fn ( Res :: PrimTy ( PrimTy :: Bool ) ) {
2497- names. extend ( PrimTy :: ALL . iter ( ) . map ( |prim_ty| {
2498- TypoSuggestion :: typo_from_name ( prim_ty. name ( ) , Res :: PrimTy ( * prim_ty) )
2499- } ) )
2500- }
25012486 } else {
25022487 // Search in module.
25032488 let mod_path = & path[ ..path. len ( ) - 1 ] ;
0 commit comments