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