@@ -39,8 +39,8 @@ use crate::late::{
39
39
} ;
40
40
use crate :: ty:: fast_reject:: SimplifiedType ;
41
41
use 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,
44
44
} ;
45
45
46
46
type Res = def:: Res < ast:: NodeId > ;
@@ -2459,45 +2459,30 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
2459
2459
}
2460
2460
}
2461
2461
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
+
2462
2478
if let RibKind :: MacroDefinition ( def) = rib. kind
2463
2479
&& def == self . r . macro_def ( ctxt)
2464
2480
{
2465
2481
// If an invocation of this macro created `ident`, give up on `ident`
2466
2482
// and switch to `ident`'s source from the macro definition.
2467
2483
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
- }
2493
2484
}
2494
2485
}
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
- }
2501
2486
} else {
2502
2487
// Search in module.
2503
2488
let mod_path = & path[ ..path. len ( ) - 1 ] ;
0 commit comments