@@ -107,11 +107,11 @@ struct FindPathCtx<'db> {
107
107
/// Attempts to find a path to refer to the given `item` visible from the `from` ModuleId
108
108
fn find_path_inner ( ctx : & FindPathCtx < ' _ > , item : ItemInNs , max_len : usize ) -> Option < ModPath > {
109
109
// - if the item is a module, jump straight to module search
110
- if !ctx. is_std_item {
111
- if let ItemInNs :: Types ( ModuleDefId :: ModuleId ( module_id) ) = item {
112
- return find_path_for_module ( ctx , & mut FxHashSet :: default ( ) , module_id , true , max_len )
113
- . map ( |choice| choice . path ) ;
114
- }
110
+ if !ctx. is_std_item
111
+ && let ItemInNs :: Types ( ModuleDefId :: ModuleId ( module_id) ) = item
112
+ {
113
+ return find_path_for_module ( ctx , & mut FxHashSet :: default ( ) , module_id , true , max_len )
114
+ . map ( |choice| choice . path ) ;
115
115
}
116
116
117
117
let may_be_in_scope = match ctx. prefix {
@@ -226,15 +226,15 @@ fn find_path_for_module(
226
226
}
227
227
228
228
// - if the module can be referenced as self, super or crate, do that
229
- if let Some ( kind) = is_kw_kind_relative_to_from ( ctx. from_def_map , module_id, ctx. from ) {
230
- if ctx. prefix != PrefixKind :: ByCrate || kind == PathKind :: Crate {
231
- return Some ( Choice {
232
- path : ModPath :: from_segments ( kind , None ) ,
233
- path_text_len : path_kind_len ( kind) ,
234
- stability : Stable ,
235
- prefer_due_to_prelude : false ,
236
- } ) ;
237
- }
229
+ if let Some ( kind) = is_kw_kind_relative_to_from ( ctx. from_def_map , module_id, ctx. from )
230
+ && ( ctx. prefix != PrefixKind :: ByCrate || kind == PathKind :: Crate )
231
+ {
232
+ return Some ( Choice {
233
+ path : ModPath :: from_segments ( kind, None ) ,
234
+ path_text_len : path_kind_len ( kind ) ,
235
+ stability : Stable ,
236
+ prefer_due_to_prelude : false ,
237
+ } ) ;
238
238
}
239
239
240
240
// - if the module is in the prelude, return it by that path
@@ -604,29 +604,29 @@ fn find_local_import_locations(
604
604
& def_map[ module. local_id ]
605
605
} ;
606
606
607
- if let Some ( ( name, vis, declared) ) = data. scope . name_of ( item) {
608
- if vis. is_visible_from ( db, from) {
609
- let is_pub_or_explicit = match vis {
610
- Visibility :: Module ( _, VisibilityExplicitness :: Explicit ) => {
611
- cov_mark:: hit!( explicit_private_imports) ;
612
- true
613
- }
614
- Visibility :: Module ( _, VisibilityExplicitness :: Implicit ) => {
615
- cov_mark:: hit!( discount_private_imports) ;
616
- false
617
- }
618
- Visibility :: PubCrate ( _) => true ,
619
- Visibility :: Public => true ,
620
- } ;
621
-
622
- // Ignore private imports unless they are explicit. these could be used if we are
623
- // in a submodule of this module, but that's usually not
624
- // what the user wants; and if this module can import
625
- // the item and we're a submodule of it, so can we.
626
- // Also this keeps the cached data smaller.
627
- if declared || is_pub_or_explicit {
628
- cb ( visited_modules, name, module) ;
607
+ if let Some ( ( name, vis, declared) ) = data. scope . name_of ( item)
608
+ && vis. is_visible_from ( db, from)
609
+ {
610
+ let is_pub_or_explicit = match vis {
611
+ Visibility :: Module ( _, VisibilityExplicitness :: Explicit ) => {
612
+ cov_mark:: hit!( explicit_private_imports) ;
613
+ true
629
614
}
615
+ Visibility :: Module ( _, VisibilityExplicitness :: Implicit ) => {
616
+ cov_mark:: hit!( discount_private_imports) ;
617
+ false
618
+ }
619
+ Visibility :: PubCrate ( _) => true ,
620
+ Visibility :: Public => true ,
621
+ } ;
622
+
623
+ // Ignore private imports unless they are explicit. these could be used if we are
624
+ // in a submodule of this module, but that's usually not
625
+ // what the user wants; and if this module can import
626
+ // the item and we're a submodule of it, so can we.
627
+ // Also this keeps the cached data smaller.
628
+ if declared || is_pub_or_explicit {
629
+ cb ( visited_modules, name, module) ;
630
630
}
631
631
}
632
632
0 commit comments