@@ -546,40 +546,55 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
546
546
}
547
547
}
548
548
InferSourceKind :: FullyQualifiedMethodCall { receiver, successor, args, def_id } => {
549
- let mut printer = fmt_printer ( self , Namespace :: ValueNS ) ;
550
- printer. print_def_path ( def_id, args) . unwrap ( ) ;
551
- let def_path = printer. into_buffer ( ) ;
552
-
553
- // We only care about whether we have to add `&` or `&mut ` for now.
554
- // This is the case if the last adjustment is a borrow and the
555
- // first adjustment was not a builtin deref.
556
- let adjustment = match typeck_results. expr_adjustments ( receiver) {
557
- [
558
- Adjustment { kind : Adjust :: Deref ( None ) , target : _ } ,
559
- ..,
560
- Adjustment { kind : Adjust :: Borrow ( AutoBorrow :: Ref ( ..) ) , target : _ } ,
561
- ] => "" ,
562
- [
563
- ..,
564
- Adjustment { kind : Adjust :: Borrow ( AutoBorrow :: Ref ( _, mut_) ) , target : _ } ,
565
- ] => hir:: Mutability :: from ( * mut_) . ref_prefix_str ( ) ,
566
- _ => "" ,
567
- } ;
549
+ let placeholder = Some ( self . next_ty_var ( TypeVariableOrigin {
550
+ span : rustc_span:: DUMMY_SP ,
551
+ kind : TypeVariableOriginKind :: MiscVariable ,
552
+ } ) ) ;
553
+ if let Some ( args) = args. make_suggestable ( self . infcx . tcx , true , placeholder) {
554
+ let mut printer = fmt_printer ( self , Namespace :: ValueNS ) ;
555
+ printer. print_def_path ( def_id, args) . unwrap ( ) ;
556
+ let def_path = printer. into_buffer ( ) ;
557
+
558
+ // We only care about whether we have to add `&` or `&mut ` for now.
559
+ // This is the case if the last adjustment is a borrow and the
560
+ // first adjustment was not a builtin deref.
561
+ let adjustment = match typeck_results. expr_adjustments ( receiver) {
562
+ [
563
+ Adjustment { kind : Adjust :: Deref ( None ) , target : _ } ,
564
+ ..,
565
+ Adjustment { kind : Adjust :: Borrow ( AutoBorrow :: Ref ( ..) ) , target : _ } ,
566
+ ] => "" ,
567
+ [
568
+ ..,
569
+ Adjustment {
570
+ kind : Adjust :: Borrow ( AutoBorrow :: Ref ( _, mut_) ) ,
571
+ target : _,
572
+ } ,
573
+ ] => hir:: Mutability :: from ( * mut_) . ref_prefix_str ( ) ,
574
+ _ => "" ,
575
+ } ;
568
576
569
- multi_suggestions. push ( SourceKindMultiSuggestion :: new_fully_qualified (
570
- receiver. span ,
571
- def_path,
572
- adjustment,
573
- successor,
574
- ) ) ;
577
+ multi_suggestions. push ( SourceKindMultiSuggestion :: new_fully_qualified (
578
+ receiver. span ,
579
+ def_path,
580
+ adjustment,
581
+ successor,
582
+ ) ) ;
583
+ }
575
584
}
576
585
InferSourceKind :: ClosureReturn { ty, data, should_wrap_expr } => {
577
- let ty_info = ty_to_string ( self , ty, None ) ;
578
- multi_suggestions. push ( SourceKindMultiSuggestion :: new_closure_return (
579
- ty_info,
580
- data,
581
- should_wrap_expr,
582
- ) ) ;
586
+ let placeholder = Some ( self . next_ty_var ( TypeVariableOrigin {
587
+ span : rustc_span:: DUMMY_SP ,
588
+ kind : TypeVariableOriginKind :: MiscVariable ,
589
+ } ) ) ;
590
+ if let Some ( ty) = ty. make_suggestable ( self . infcx . tcx , true , placeholder) {
591
+ let ty_info = ty_to_string ( self , ty, None ) ;
592
+ multi_suggestions. push ( SourceKindMultiSuggestion :: new_closure_return (
593
+ ty_info,
594
+ data,
595
+ should_wrap_expr,
596
+ ) ) ;
597
+ }
583
598
}
584
599
}
585
600
match error_code {
0 commit comments