@@ -563,8 +563,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
563
563
} ;
564
564
565
565
let suggest_confusable = |err : & mut Diagnostic | {
566
- let call_name = call_ident?;
567
- let callee_ty = callee_ty?;
566
+ let Some ( call_name) = call_ident else {
567
+ return ;
568
+ } ;
569
+ let Some ( callee_ty) = callee_ty else {
570
+ return ;
571
+ } ;
568
572
let input_types: Vec < Ty < ' _ > > = provided_arg_tys. iter ( ) . map ( |( ty, _) | * ty) . collect ( ) ;
569
573
// Check for other methods in the following order
570
574
// - methods marked as `rustc_confusables` with the provided arguments
@@ -573,13 +577,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
573
577
// - methods with short levenshtein distance
574
578
575
579
// Look for commonly confusable method names considering arguments.
576
- if let Some ( name ) = self . confusable_method_name (
580
+ if let Some ( _name ) = self . confusable_method_name (
577
581
err,
578
582
callee_ty. peel_refs ( ) ,
579
583
call_name,
580
584
Some ( input_types. clone ( ) ) ,
581
585
) {
582
- return Some ( name ) ;
586
+ return ;
583
587
}
584
588
// Look for method names with short levenshtein distance, considering arguments.
585
589
if let Some ( ( assoc, fn_sig) ) = similar_assoc ( call_name)
@@ -595,13 +599,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
595
599
assoc. name ,
596
600
Applicability :: MaybeIncorrect ,
597
601
) ;
598
- return Some ( assoc . name ) ;
602
+ return ;
599
603
}
600
604
// Look for commonly confusable method names disregarding arguments.
601
- if let Some ( name ) =
605
+ if let Some ( _name ) =
602
606
self . confusable_method_name ( err, callee_ty. peel_refs ( ) , call_name, None )
603
607
{
604
- return Some ( name ) ;
608
+ return ;
605
609
}
606
610
// Look for similarly named methods with levenshtein distance with the right
607
611
// number of arguments.
@@ -615,7 +619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
615
619
assoc. name,
616
620
) ,
617
621
) ;
618
- return Some ( assoc . name ) ;
622
+ return ;
619
623
}
620
624
// Fallthrough: look for similarly named methods with levenshtein distance.
621
625
if let Some ( ( assoc, _) ) = similar_assoc ( call_name) {
@@ -627,9 +631,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
627
631
assoc. name,
628
632
) ,
629
633
) ;
630
- return Some ( assoc . name ) ;
634
+ return ;
631
635
}
632
- None
633
636
} ;
634
637
// A "softer" version of the `demand_compatible`, which checks types without persisting them,
635
638
// and treats error types differently
0 commit comments