@@ -581,10 +581,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
581581 exp_found : Option < ty:: error:: ExpectedFound < Ty < ' tcx > > > ,
582582 ) {
583583 match cause. code {
584- ObligationCauseCode :: MatchExpressionArmPattern { span, ty } => {
584+ ObligationCauseCode :: Pattern { origin_expr : true , span : Some ( span) , root_ty } => {
585+ let ty = self . resolve_vars_if_possible ( & root_ty) ;
585586 if ty. is_suggestable ( ) {
586587 // don't show type `_`
587- err. span_label ( span, format ! ( "this match expression has type `{}`" , ty) ) ;
588+ err. span_label ( span, format ! ( "this expression has type `{}`" , ty) ) ;
588589 }
589590 if let Some ( ty:: error:: ExpectedFound { found, .. } ) = exp_found {
590591 if ty. is_box ( ) && ty. boxed_ty ( ) == found {
@@ -599,11 +600,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
599600 }
600601 }
601602 }
603+ ObligationCauseCode :: Pattern { origin_expr : false , span : Some ( span) , .. } => {
604+ err. span_label ( span, "expected due to this" ) ;
605+ }
602606 ObligationCauseCode :: MatchExpressionArm ( box MatchExpressionArmCause {
603607 source,
604608 ref prior_arms,
605609 last_ty,
606- discrim_hir_id ,
610+ scrut_hir_id ,
607611 ..
608612 } ) => match source {
609613 hir:: MatchSource :: IfLetDesugar { .. } => {
@@ -612,16 +616,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
612616 }
613617 hir:: MatchSource :: TryDesugar => {
614618 if let Some ( ty:: error:: ExpectedFound { expected, .. } ) = exp_found {
615- let discrim_expr = self . tcx . hir ( ) . expect_expr ( discrim_hir_id ) ;
616- let discrim_ty = if let hir:: ExprKind :: Call ( _, args) = & discrim_expr . kind {
619+ let scrut_expr = self . tcx . hir ( ) . expect_expr ( scrut_hir_id ) ;
620+ let scrut_ty = if let hir:: ExprKind :: Call ( _, args) = & scrut_expr . kind {
617621 let arg_expr = args. first ( ) . expect ( "try desugaring call w/out arg" ) ;
618622 self . in_progress_tables
619623 . and_then ( |tables| tables. borrow ( ) . expr_ty_opt ( arg_expr) )
620624 } else {
621- bug ! ( "try desugaring w/out call expr as discriminant " ) ;
625+ bug ! ( "try desugaring w/out call expr as scrutinee " ) ;
622626 } ;
623627
624- match discrim_ty {
628+ match scrut_ty {
625629 Some ( ty) if expected == ty => {
626630 let source_map = self . tcx . sess . source_map ( ) ;
627631 err. span_suggestion (
0 commit comments