@@ -1325,11 +1325,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1325
1325
} )
1326
1326
}
1327
1327
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
-
1333
1328
candidates
1334
1329
}
1335
1330
@@ -1794,7 +1789,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1794
1789
& import_suggestions,
1795
1790
Instead :: Yes ,
1796
1791
FoundUse :: Yes ,
1797
- DiagMode :: Import { append : single_nested } ,
1792
+ DiagMode :: Import { append : single_nested, unresolved_import : false } ,
1798
1793
vec ! [ ] ,
1799
1794
"" ,
1800
1795
) ;
@@ -2751,6 +2746,8 @@ pub(crate) enum DiagMode {
2751
2746
Pattern ,
2752
2747
/// The binding is part of a use statement
2753
2748
Import {
2749
+ /// `true` means diagnostics is for unresolved import
2750
+ unresolved_import : bool ,
2754
2751
/// `true` mean add the tips afterward for case `use a::{b,c}`,
2755
2752
/// rather than replacing within.
2756
2753
append : bool ,
@@ -2801,6 +2798,7 @@ fn show_candidates(
2801
2798
return false ;
2802
2799
}
2803
2800
2801
+ let mut showed = false ;
2804
2802
let mut accessible_path_strings: Vec < PathString < ' _ > > = Vec :: new ( ) ;
2805
2803
let mut inaccessible_path_strings: Vec < PathString < ' _ > > = Vec :: new ( ) ;
2806
2804
@@ -2959,8 +2957,11 @@ fn show_candidates(
2959
2957
append_candidates ( & mut msg, accessible_path_strings) ;
2960
2958
err. help ( msg) ;
2961
2959
}
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
+ {
2964
2965
let prefix =
2965
2966
if let DiagMode :: Pattern = mode { "you might have meant to match on " } else { "" } ;
2966
2967
if let [ ( name, descr, source_span, note, _) ] = & inaccessible_path_strings[ ..] {
@@ -3023,10 +3024,9 @@ fn show_candidates(
3023
3024
3024
3025
err. span_note ( multi_span, msg) ;
3025
3026
}
3026
- true
3027
- } else {
3028
- false
3027
+ showed = true ;
3029
3028
}
3029
+ showed
3030
3030
}
3031
3031
3032
3032
#[ derive( Debug ) ]
0 commit comments