@@ -407,11 +407,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
407
407
& self ,
408
408
self_source : SelfSource < ' tcx > ,
409
409
method_name : Ident ,
410
- unsatisfied_predicates : & [ (
411
- ty:: Predicate < ' tcx > ,
412
- Option < ty:: Predicate < ' tcx > > ,
413
- Option < ObligationCause < ' tcx > > ,
414
- ) ] ,
415
410
ty : Ty < ' tcx > ,
416
411
err : & mut Diag < ' _ > ,
417
412
) {
@@ -487,7 +482,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
487
482
}
488
483
489
484
// If the shadowed binding has an itializer expression,
490
- // use the initializer expression'ty to try to find the method again.
485
+ // use the initializer expression's ty to try to find the method again.
491
486
// For example like: `let mut x = Vec::new();`,
492
487
// `Vec::new()` is the itializer expression.
493
488
if let Some ( self_ty) = self . fcx . node_ty_opt ( binding. init_hir_id )
@@ -576,34 +571,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
576
571
span. push_span_label ( sugg_let. span ,
577
572
format ! ( "`{rcvr_name}` of type `{self_ty}` that has method `{method_name}` defined earlier here" ) ) ;
578
573
579
- // Don't show generic arguments when the method can't be found in any implementation (#81576).
580
- let mut ty_str = None ;
581
- if let ty:: Adt ( _, generics) = ty. kind ( ) {
582
- if generics. len ( ) > 0 {
583
- let mut autoderef = self . autoderef ( DUMMY_SP , ty) . silence_errors ( ) ;
584
- let candidate_found = autoderef. any ( |( ty, _) | {
585
- if let ty:: Adt ( adt_def, _) = ty. kind ( ) {
586
- self . tcx . inherent_impls ( adt_def. did ( ) ) . into_iter ( ) . any (
587
- |def_id| {
588
- self . associated_value ( * def_id, method_name) . is_some ( )
589
- } ,
590
- )
591
- } else {
592
- false
593
- }
594
- } ) ;
595
- let has_deref = autoderef. step_count ( ) > 0 ;
596
- if !candidate_found && !has_deref && unsatisfied_predicates. is_empty ( ) {
597
- let t = with_forced_trimmed_paths ! ( ty. to_string( ) ) ;
598
- if let Some ( ( path_string, _) ) = t. split_once ( '<' ) {
599
- ty_str = Some ( path_string. to_string ( ) ) ;
600
- }
601
- }
602
- }
603
- }
604
-
605
- let ty =
606
- ty_str. unwrap_or_else ( || self . tcx . short_string ( ty, err. long_ty_path ( ) ) ) ;
574
+ let ty = self . tcx . short_string ( ty, err. long_ty_path ( ) ) ;
607
575
span. push_span_label (
608
576
self . tcx . hir_span ( recv_id) ,
609
577
format ! ( "earlier `{rcvr_name}` shadowed here with type `{ty}`" ) ,
@@ -720,11 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
720
688
721
689
if is_method {
722
690
self . suggest_use_shadowed_binding_with_method (
723
- source,
724
- item_ident,
725
- & unsatisfied_predicates,
726
- rcvr_ty,
727
- & mut err,
691
+ source, item_ident, rcvr_ty, & mut err,
728
692
) ;
729
693
}
730
694
0 commit comments