@@ -840,44 +840,42 @@ impl<'a> Resolver<'a> {
840840 suggestion : Option < TypoSuggestion > ,
841841 span : Span ,
842842 ) -> bool {
843- if let Some ( suggestion) = suggestion {
843+ let suggestion = match suggestion {
844+ None => return false ,
844845 // We shouldn't suggest underscore.
845- if suggestion. candidate == kw:: Underscore {
846- return false ;
847- }
848-
849- let msg = format ! (
850- "{} {} with a similar name exists" ,
851- suggestion. res. article( ) ,
852- suggestion. res. descr( )
853- ) ;
854- err. span_suggestion (
855- span,
856- & msg,
857- suggestion. candidate . to_string ( ) ,
858- Applicability :: MaybeIncorrect ,
859- ) ;
860- let def_span = suggestion. res . opt_def_id ( ) . and_then ( |def_id| match def_id. krate {
861- LOCAL_CRATE => self . opt_span ( def_id) ,
862- _ => Some (
863- self . session
864- . source_map ( )
865- . guess_head_span ( self . cstore ( ) . get_span_untracked ( def_id, self . session ) ) ,
846+ Some ( suggestion) if suggestion. candidate == kw:: Underscore => return false ,
847+ Some ( suggestion) => suggestion,
848+ } ;
849+ let msg = format ! (
850+ "{} {} with a similar name exists" ,
851+ suggestion. res. article( ) ,
852+ suggestion. res. descr( )
853+ ) ;
854+ err. span_suggestion (
855+ span,
856+ & msg,
857+ suggestion. candidate . to_string ( ) ,
858+ Applicability :: MaybeIncorrect ,
859+ ) ;
860+ let def_span = suggestion. res . opt_def_id ( ) . and_then ( |def_id| match def_id. krate {
861+ LOCAL_CRATE => self . opt_span ( def_id) ,
862+ _ => Some (
863+ self . session
864+ . source_map ( )
865+ . guess_head_span ( self . cstore ( ) . get_span_untracked ( def_id, self . session ) ) ,
866+ ) ,
867+ } ) ;
868+ if let Some ( span) = def_span {
869+ err. span_label (
870+ self . session . source_map ( ) . guess_head_span ( span) ,
871+ & format ! (
872+ "similarly named {} `{}` defined here" ,
873+ suggestion. res. descr( ) ,
874+ suggestion. candidate. as_str( ) ,
866875 ) ,
867- } ) ;
868- if let Some ( span) = def_span {
869- err. span_label (
870- self . session . source_map ( ) . guess_head_span ( span) ,
871- & format ! (
872- "similarly named {} `{}` defined here" ,
873- suggestion. res. descr( ) ,
874- suggestion. candidate. as_str( ) ,
875- ) ,
876- ) ;
877- }
878- return true ;
876+ ) ;
879877 }
880- false
878+ true
881879 }
882880
883881 fn binding_description ( & self , b : & NameBinding < ' _ > , ident : Ident , from_prelude : bool ) -> String {
0 commit comments