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