@@ -107,11 +107,11 @@ struct FindPathCtx<'db> {
107107/// Attempts to find a path to refer to the given `item` visible from the `from` ModuleId
108108fn find_path_inner ( ctx : & FindPathCtx < ' _ > , item : ItemInNs , max_len : usize ) -> Option < ModPath > {
109109 // - 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 ) ;
115115 }
116116
117117 let may_be_in_scope = match ctx. prefix {
@@ -226,15 +226,15 @@ fn find_path_for_module(
226226 }
227227
228228 // - 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+ } ) ;
238238 }
239239
240240 // - if the module is in the prelude, return it by that path
@@ -604,29 +604,29 @@ fn find_local_import_locations(
604604 & def_map[ module. local_id ]
605605 } ;
606606
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
629614 }
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) ;
630630 }
631631 }
632632
0 commit comments