@@ -3597,7 +3597,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
3597
3597
& self ,
3598
3598
obligation : & PredicateObligation < ' tcx > ,
3599
3599
err : & mut Diag < ' _ > ,
3600
- trait_ref : & ty:: PolyTraitRef < ' tcx > ,
3600
+ trait_ref : ty:: PolyTraitRef < ' tcx > ,
3601
3601
) {
3602
3602
let rhs_span = match obligation. cause . code ( ) {
3603
3603
ObligationCauseCode :: BinOp { rhs_span : Some ( span) , rhs_is_lit, .. } if * rhs_is_lit => {
@@ -4592,7 +4592,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
4592
4592
& self ,
4593
4593
obligation : & PredicateObligation < ' tcx > ,
4594
4594
err : & mut Diag < ' _ > ,
4595
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
4595
+ trait_pred : ty:: PolyTraitPredicate < ' tcx > ,
4596
4596
) {
4597
4597
if ObligationCauseCode :: QuestionMark != * obligation. cause . code ( ) . peel_derives ( ) {
4598
4598
return ;
@@ -4602,10 +4602,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
4602
4602
if let hir:: Node :: Item ( item) = node
4603
4603
&& let hir:: ItemKind :: Fn ( sig, _, body_id) = item. kind
4604
4604
&& let hir:: FnRetTy :: DefaultReturn ( ret_span) = sig. decl . output
4605
- && self . tcx . is_diagnostic_item ( sym:: FromResidual , trait_ref. def_id ( ) )
4606
- && let ty:: Tuple ( l) = trait_ref. skip_binder ( ) . args . type_at ( 0 ) . kind ( )
4607
- && l. len ( ) == 0
4608
- && let ty:: Adt ( def, _) = trait_ref. skip_binder ( ) . args . type_at ( 1 ) . kind ( )
4605
+ && self . tcx . is_diagnostic_item ( sym:: FromResidual , trait_pred. def_id ( ) )
4606
+ && trait_pred. skip_binder ( ) . trait_ref . args . type_at ( 0 ) . is_unit ( )
4607
+ && let ty:: Adt ( def, _) = trait_pred. skip_binder ( ) . trait_ref . args . type_at ( 1 ) . kind ( )
4609
4608
&& self . tcx . is_diagnostic_item ( sym:: Result , def. did ( ) )
4610
4609
{
4611
4610
let body = self . tcx . hir ( ) . body ( body_id) ;
@@ -4863,14 +4862,13 @@ impl<'a, 'hir> hir::intravisit::Visitor<'hir> for ReplaceImplTraitVisitor<'a> {
4863
4862
pub ( super ) fn get_explanation_based_on_obligation < ' tcx > (
4864
4863
tcx : TyCtxt < ' tcx > ,
4865
4864
obligation : & PredicateObligation < ' tcx > ,
4866
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
4867
- trait_predicate : & ty:: PolyTraitPredicate < ' tcx > ,
4865
+ trait_predicate : ty:: PolyTraitPredicate < ' tcx > ,
4868
4866
pre_message : String ,
4869
4867
) -> String {
4870
4868
if let ObligationCauseCode :: MainFunctionType = obligation. cause . code ( ) {
4871
4869
"consider using `()`, or a `Result`" . to_owned ( )
4872
4870
} else {
4873
- let ty_desc = match trait_ref . skip_binder ( ) . self_ty ( ) . kind ( ) {
4871
+ let ty_desc = match trait_predicate . self_ty ( ) . skip_binder ( ) . kind ( ) {
4874
4872
ty:: FnDef ( _, _) => Some ( "fn item" ) ,
4875
4873
ty:: Closure ( _, _) => Some ( "closure" ) ,
4876
4874
_ => None ,
@@ -4895,7 +4893,7 @@ pub(super) fn get_explanation_based_on_obligation<'tcx>(
4895
4893
format ! (
4896
4894
"{pre_message}the trait `{}` is not implemented for{desc} `{}`{post}" ,
4897
4895
trait_predicate. print_modifiers_and_trait_path( ) ,
4898
- tcx. short_ty_string( trait_ref . skip_binder ( ) . self_ty ( ) , & mut None ) ,
4896
+ tcx. short_ty_string( trait_predicate . self_ty ( ) . skip_binder ( ) , & mut None ) ,
4899
4897
)
4900
4898
} else {
4901
4899
// "the trait bound `T: !Send` is not satisfied" reads better than "`!Send` is
0 commit comments