@@ -443,6 +443,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
443443 ) ;
444444 }
445445 }
446+ // Try Levenshtein algorithm.
447+ let typo_sugg = self . lookup_typo_candidate ( path, ns, is_expected) ;
446448 if path. len ( ) == 1 && self . self_type_is_available ( ) {
447449 if let Some ( candidate) = self . lookup_assoc_candidate ( ident, ns, is_expected) {
448450 let self_is_available = self . self_value_is_available ( path[ 0 ] . ident . span ) ;
@@ -452,18 +454,19 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
452454 err. span_suggestion (
453455 span,
454456 "you might have meant to use the available field" ,
455- format ! ( "self.{}" , path_str ) ,
457+ format ! ( "self.{path_str}" ) ,
456458 Applicability :: MachineApplicable ,
457459 ) ;
458460 } else {
459461 err. span_label ( span, "a field by this name exists in `Self`" ) ;
460462 }
463+ self . r . add_typo_suggestion ( & mut err, typo_sugg, ident_span) ;
461464 }
462465 AssocSuggestion :: MethodWithSelf if self_is_available => {
463466 err. span_suggestion (
464467 span,
465468 "you might have meant to call the method" ,
466- format ! ( "self.{}" , path_str ) ,
469+ format ! ( "self.{path_str}" ) ,
467470 Applicability :: MachineApplicable ,
468471 ) ;
469472 }
@@ -474,7 +477,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
474477 err. span_suggestion (
475478 span,
476479 & format ! ( "you might have meant to {}" , candidate. action( ) ) ,
477- format ! ( "Self::{}" , path_str ) ,
480+ format ! ( "Self::{path_str}" ) ,
478481 Applicability :: MachineApplicable ,
479482 ) ;
480483 }
@@ -493,16 +496,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
493496
494497 err. span_suggestion (
495498 call_span,
496- & format ! ( "try calling `{}` as a method" , ident ) ,
497- format ! ( "self.{}({})" , path_str , args_snippet ) ,
499+ & format ! ( "try calling `{ident }` as a method" ) ,
500+ format ! ( "self.{path_str }({args_snippet })" ) ,
498501 Applicability :: MachineApplicable ,
499502 ) ;
500503 return ( err, candidates) ;
501504 }
502505 }
503506
504- // Try Levenshtein algorithm.
505- let typo_sugg = self . lookup_typo_candidate ( path, ns, is_expected) ;
506507 // Try context-dependent help if relaxed lookup didn't work.
507508 if let Some ( res) = res {
508509 if self . smart_resolve_context_dependent_help (
0 commit comments