@@ -1325,11 +1325,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
13251325 } )
13261326 }
13271327
1328- // If only some candidates are accessible, take just them
1329- if !candidates. iter ( ) . all ( |v : & ImportSuggestion | !v. accessible ) {
1330- candidates. retain ( |x| x. accessible )
1331- }
1332-
13331328 candidates
13341329 }
13351330
@@ -1794,7 +1789,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17941789 & import_suggestions,
17951790 Instead :: Yes ,
17961791 FoundUse :: Yes ,
1797- DiagMode :: Import { append : single_nested } ,
1792+ DiagMode :: Import { append : single_nested, unresolved_import : false } ,
17981793 vec ! [ ] ,
17991794 "" ,
18001795 ) ;
@@ -2751,6 +2746,8 @@ pub(crate) enum DiagMode {
27512746 Pattern ,
27522747 /// The binding is part of a use statement
27532748 Import {
2749+ /// `true` means diagnostics is for unresolved import
2750+ unresolved_import : bool ,
27542751 /// `true` mean add the tips afterward for case `use a::{b,c}`,
27552752 /// rather than replacing within.
27562753 append : bool ,
@@ -2801,6 +2798,7 @@ fn show_candidates(
28012798 return false ;
28022799 }
28032800
2801+ let mut showed = false ;
28042802 let mut accessible_path_strings: Vec < PathString < ' _ > > = Vec :: new ( ) ;
28052803 let mut inaccessible_path_strings: Vec < PathString < ' _ > > = Vec :: new ( ) ;
28062804
@@ -2959,8 +2957,11 @@ fn show_candidates(
29592957 append_candidates ( & mut msg, accessible_path_strings) ;
29602958 err. help ( msg) ;
29612959 }
2962- true
2963- } else if !( inaccessible_path_strings. is_empty ( ) || matches ! ( mode, DiagMode :: Import { .. } ) ) {
2960+ showed = true ;
2961+ }
2962+ if !inaccessible_path_strings. is_empty ( )
2963+ && ( !matches ! ( mode, DiagMode :: Import { unresolved_import: false , .. } ) )
2964+ {
29642965 let prefix =
29652966 if let DiagMode :: Pattern = mode { "you might have meant to match on " } else { "" } ;
29662967 if let [ ( name, descr, source_span, note, _) ] = & inaccessible_path_strings[ ..] {
@@ -3023,10 +3024,9 @@ fn show_candidates(
30233024
30243025 err. span_note ( multi_span, msg) ;
30253026 }
3026- true
3027- } else {
3028- false
3027+ showed = true ;
30293028 }
3029+ showed
30303030}
30313031
30323032#[ derive( Debug ) ]
0 commit comments