@@ -55,7 +55,8 @@ use crate::hir::def_id::DefId;
5555use crate :: hir:: Node ;
5656use crate :: infer:: opaque_types;
5757use crate :: middle:: region;
58- use crate :: traits:: { ObligationCause , ObligationCauseCode } ;
58+ use crate :: traits:: { IfExpressionCause , MatchExpressionArmCause , ObligationCause } ;
59+ use crate :: traits:: { ObligationCauseCode } ;
5960use crate :: ty:: error:: TypeError ;
6061use crate :: ty:: { self , subst:: { Subst , SubstsRef } , Region , Ty , TyCtxt , TypeFoldable } ;
6162use errors:: { Applicability , DiagnosticBuilder , DiagnosticStyledString } ;
@@ -624,13 +625,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
624625 }
625626 }
626627 }
627- ObligationCauseCode :: MatchExpressionArm {
628+ ObligationCauseCode :: MatchExpressionArm ( box MatchExpressionArmCause {
628629 source,
629630 ref prior_arms,
630631 last_ty,
631632 discrim_hir_id,
632633 ..
633- } => match source {
634+ } ) => match source {
634635 hir:: MatchSource :: IfLetDesugar { .. } => {
635636 let msg = "`if let` arms have incompatible types" ;
636637 err. span_label ( cause. span , msg) ;
@@ -681,7 +682,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
681682 }
682683 }
683684 } ,
684- ObligationCauseCode :: IfExpression { then, outer, semicolon } => {
685+ ObligationCauseCode :: IfExpression ( box IfExpressionCause { then, outer, semicolon } ) => {
685686 err. span_label ( then, "expected because of this" ) ;
686687 outer. map ( |sp| err. span_label ( sp, "if and else have incompatible types" ) ) ;
687688 if let Some ( sp) = semicolon {
@@ -1622,13 +1623,15 @@ impl<'tcx> ObligationCause<'tcx> {
16221623 use crate :: traits:: ObligationCauseCode :: * ;
16231624 match self . code {
16241625 CompareImplMethodObligation { .. } => Error0308 ( "method not compatible with trait" ) ,
1625- MatchExpressionArm { source, .. } => Error0308 ( match source {
1626- hir:: MatchSource :: IfLetDesugar { .. } => "`if let` arms have incompatible types" ,
1627- hir:: MatchSource :: TryDesugar => {
1628- "try expression alternatives have incompatible types"
1629- }
1630- _ => "match arms have incompatible types" ,
1631- } ) ,
1626+ MatchExpressionArm ( box MatchExpressionArmCause { source, .. } ) =>
1627+ Error0308 ( match source {
1628+ hir:: MatchSource :: IfLetDesugar { .. } =>
1629+ "`if let` arms have incompatible types" ,
1630+ hir:: MatchSource :: TryDesugar => {
1631+ "try expression alternatives have incompatible types"
1632+ }
1633+ _ => "match arms have incompatible types" ,
1634+ } ) ,
16321635 IfExpression { .. } => Error0308 ( "if and else have incompatible types" ) ,
16331636 IfExpressionWithNoElse => Error0317 ( "if may be missing an else clause" ) ,
16341637 MainFunctionType => Error0580 ( "main function has wrong type" ) ,
@@ -1656,7 +1659,7 @@ impl<'tcx> ObligationCause<'tcx> {
16561659 match self . code {
16571660 CompareImplMethodObligation { .. } => "method type is compatible with trait" ,
16581661 ExprAssignable => "expression is assignable" ,
1659- MatchExpressionArm { source, .. } => match source {
1662+ MatchExpressionArm ( box MatchExpressionArmCause { source, .. } ) => match source {
16601663 hir:: MatchSource :: IfLetDesugar { .. } => "`if let` arms have compatible types" ,
16611664 _ => "match arms have compatible types" ,
16621665 } ,
0 commit comments