@@ -367,7 +367,7 @@ enum UseStarResult<'db> {
367367 /// The path was not found, considering only the `use *` imports.
368368 PathNotFound ,
369369 /// Item is not visible in the current module, considering only the `use *` imports.
370- ItemNotVisible ( ModuleItemId < ' db > , Vec < ModuleId < ' db > > ) ,
370+ ItemNotVisible ( Option < ModuleItemId < ' db > > , Vec < ModuleId < ' db > > ) ,
371371}
372372
373373/// A trait for things that can be interpreted as a path of segments.
@@ -775,7 +775,9 @@ impl<'db> Resolver<'db> {
775775 ) -> UseStarResult < ' db > {
776776 let mut item_info = None ;
777777 let mut module_items_found: OrderedHashSet < ModuleItemId < ' _ > > = OrderedHashSet :: default ( ) ;
778- let mut other_containing_modules = vec ! [ ] ;
778+ let mut non_pub_module_items_found: OrderedHashSet < ModuleItemId < ' _ > > =
779+ OrderedHashSet :: default ( ) ;
780+ let mut non_pub_containing_modules = vec ! [ ] ;
779781 for ( item_module_id, info) in self . db . module_imported_modules ( ( ) , module_id) . iter ( ) {
780782 // Not checking the main module to prevent cycles.
781783 if * item_module_id == module_id {
@@ -790,34 +792,21 @@ impl<'db> Resolver<'db> {
790792 item_info = Some ( inner_item_info. clone ( ) ) ;
791793 module_items_found. insert ( inner_item_info. item_id ) ;
792794 } else {
793- other_containing_modules. push ( * item_module_id) ;
795+ non_pub_containing_modules. push ( * item_module_id) ;
796+ non_pub_module_items_found. insert ( inner_item_info. item_id ) ;
794797 }
795798 }
796799 }
797800 if module_items_found. len ( ) > 1 {
798- return UseStarResult :: AmbiguousPath ( module_items_found. iter ( ) . cloned ( ) . collect ( ) ) ;
801+ return UseStarResult :: AmbiguousPath ( module_items_found. into_iter ( ) . collect ( ) ) ;
799802 }
800803 match item_info {
801804 Some ( item_info) => UseStarResult :: UniquePathFound ( item_info) ,
802- None => {
803- for item_module_id in & other_containing_modules {
804- if let Some ( inner_item_info) =
805- self . resolve_item_in_module_or_expanded_macro ( * item_module_id, ident)
806- {
807- item_info = Some ( inner_item_info. clone ( ) ) ;
808- module_items_found. insert ( inner_item_info. item_id ) ;
809- }
810- }
811- if let Some ( item_info) = item_info {
812- if module_items_found. len ( ) > 1 {
813- UseStarResult :: AmbiguousPath ( module_items_found. iter ( ) . cloned ( ) . collect ( ) )
814- } else {
815- UseStarResult :: ItemNotVisible ( item_info. item_id , other_containing_modules)
816- }
817- } else {
818- UseStarResult :: PathNotFound
819- }
820- }
805+ None => match non_pub_module_items_found. into_iter ( ) . exactly_one ( ) {
806+ Ok ( item) => UseStarResult :: ItemNotVisible ( Some ( item) , non_pub_containing_modules) ,
807+ Err ( err) if err. len ( ) == 0 => UseStarResult :: PathNotFound ,
808+ Err ( _) => UseStarResult :: ItemNotVisible ( None , non_pub_containing_modules) ,
809+ } ,
821810 }
822811 }
823812
@@ -1699,7 +1688,7 @@ enum ResolvedBase<'db> {
16991688 /// The base module is ambiguous.
17001689 Ambiguous ( Vec < ModuleItemId < ' db > > ) ,
17011690 /// The base module is inaccessible.
1702- ItemNotVisible ( ModuleItemId < ' db > , Vec < ModuleId < ' db > > ) ,
1691+ ItemNotVisible ( Option < ModuleItemId < ' db > > , Vec < ModuleId < ' db > > ) ,
17031692}
17041693
17051694/// The callbacks to be used by `resolve_path_inner`.
@@ -2623,7 +2612,7 @@ impl<'db, 'a> Resolution<'db, 'a> {
26232612 ) {
26242613 self . diagnostics . report (
26252614 identifier. stable_ptr ( self . resolver . db ) ,
2626- ItemNotVisible ( item_info. item_id , vec ! [ ] ) ,
2615+ ItemNotVisible ( Some ( item_info. item_id ) , vec ! [ ] ) ,
26272616 ) ;
26282617 }
26292618
0 commit comments