@@ -460,7 +460,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
460
460
return ( err, Vec :: new ( ) ) ;
461
461
}
462
462
463
- let ( found, candidates) = self . try_lookup_name_relaxed (
463
+ let ( found, mut candidates) = self . try_lookup_name_relaxed (
464
464
& mut err,
465
465
source,
466
466
path,
@@ -473,13 +473,18 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
473
473
return ( err, candidates) ;
474
474
}
475
475
476
- let mut fallback = self . suggest_trait_and_bounds ( & mut err, source, res, span, & base_error) ;
476
+ let trait_fallback =
477
+ self . suggest_trait_and_bounds ( & mut err, source, res, span, & base_error) ;
477
478
478
479
// if we have suggested using pattern matching, then don't add needless suggestions
479
480
// for typos.
480
- fallback |= self . suggest_typo ( & mut err, source, path, following_seg, span, & base_error) ;
481
-
482
- if fallback {
481
+ let ( typo_fallback, suggested_shadowed) =
482
+ self . suggest_typo ( & mut err, source, path, following_seg, span, & base_error) ;
483
+ if suggested_shadowed {
484
+ // if there is already a shadowed name, don'suggest candidates for importing
485
+ candidates. clear ( ) ;
486
+ }
487
+ if trait_fallback || typo_fallback {
483
488
// Fallback label.
484
489
err. span_label ( base_error. span , base_error. fallback_label ) ;
485
490
}
@@ -867,7 +872,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
867
872
following_seg : Option < & Segment > ,
868
873
span : Span ,
869
874
base_error : & BaseError ,
870
- ) -> bool {
875
+ ) -> ( bool , bool ) {
871
876
let is_expected = & |res| source. is_expected ( res) ;
872
877
let ident_span = path. last ( ) . map_or ( span, |ident| ident. ident . span ) ;
873
878
let typo_sugg =
@@ -889,7 +894,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
889
894
sugg_span,
890
895
format ! ( "you might have meant to refer to this {}" , res. descr( ) ) ,
891
896
) ;
892
- return true ;
897
+ return ( true , true ) ;
893
898
}
894
899
let mut fallback = false ;
895
900
let typo_sugg = typo_sugg. to_opt_suggestion ( ) ;
@@ -915,7 +920,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
915
920
fallback = !self . let_binding_suggestion ( err, ident_span) ;
916
921
}
917
922
}
918
- fallback
923
+ ( fallback, false )
919
924
}
920
925
921
926
fn err_code_special_cases (
0 commit comments