@@ -443,6 +443,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
443
443
) ;
444
444
}
445
445
}
446
+ // Try Levenshtein algorithm.
447
+ let typo_sugg = self . lookup_typo_candidate ( path, ns, is_expected) ;
446
448
if path. len ( ) == 1 && self . self_type_is_available ( ) {
447
449
if let Some ( candidate) = self . lookup_assoc_candidate ( ident, ns, is_expected) {
448
450
let self_is_available = self . self_value_is_available ( path[ 0 ] . ident . span ) ;
@@ -452,18 +454,19 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
452
454
err. span_suggestion (
453
455
span,
454
456
"you might have meant to use the available field" ,
455
- format ! ( "self.{}" , path_str ) ,
457
+ format ! ( "self.{path_str}" ) ,
456
458
Applicability :: MachineApplicable ,
457
459
) ;
458
460
} else {
459
461
err. span_label ( span, "a field by this name exists in `Self`" ) ;
460
462
}
463
+ self . r . add_typo_suggestion ( & mut err, typo_sugg, ident_span) ;
461
464
}
462
465
AssocSuggestion :: MethodWithSelf if self_is_available => {
463
466
err. span_suggestion (
464
467
span,
465
468
"you might have meant to call the method" ,
466
- format ! ( "self.{}" , path_str ) ,
469
+ format ! ( "self.{path_str}" ) ,
467
470
Applicability :: MachineApplicable ,
468
471
) ;
469
472
}
@@ -474,7 +477,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
474
477
err. span_suggestion (
475
478
span,
476
479
& format ! ( "you might have meant to {}" , candidate. action( ) ) ,
477
- format ! ( "Self::{}" , path_str ) ,
480
+ format ! ( "Self::{path_str}" ) ,
478
481
Applicability :: MachineApplicable ,
479
482
) ;
480
483
}
@@ -493,16 +496,14 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
493
496
494
497
err. span_suggestion (
495
498
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 })" ) ,
498
501
Applicability :: MachineApplicable ,
499
502
) ;
500
503
return ( err, candidates) ;
501
504
}
502
505
}
503
506
504
- // Try Levenshtein algorithm.
505
- let typo_sugg = self . lookup_typo_candidate ( path, ns, is_expected) ;
506
507
// Try context-dependent help if relaxed lookup didn't work.
507
508
if let Some ( res) = res {
508
509
if self . smart_resolve_context_dependent_help (
0 commit comments