@@ -581,10 +581,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
581
581
exp_found : Option < ty:: error:: ExpectedFound < Ty < ' tcx > > > ,
582
582
) {
583
583
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) ;
585
586
if ty. is_suggestable ( ) {
586
587
// 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) ) ;
588
589
}
589
590
if let Some ( ty:: error:: ExpectedFound { found, .. } ) = exp_found {
590
591
if ty. is_box ( ) && ty. boxed_ty ( ) == found {
@@ -599,11 +600,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
599
600
}
600
601
}
601
602
}
603
+ ObligationCauseCode :: Pattern { origin_expr : false , span : Some ( span) , .. } => {
604
+ err. span_label ( span, "expected due to this" ) ;
605
+ }
602
606
ObligationCauseCode :: MatchExpressionArm ( box MatchExpressionArmCause {
603
607
source,
604
608
ref prior_arms,
605
609
last_ty,
606
- discrim_hir_id ,
610
+ scrut_hir_id ,
607
611
..
608
612
} ) => match source {
609
613
hir:: MatchSource :: IfLetDesugar { .. } => {
@@ -612,16 +616,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
612
616
}
613
617
hir:: MatchSource :: TryDesugar => {
614
618
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 {
617
621
let arg_expr = args. first ( ) . expect ( "try desugaring call w/out arg" ) ;
618
622
self . in_progress_tables
619
623
. and_then ( |tables| tables. borrow ( ) . expr_ty_opt ( arg_expr) )
620
624
} else {
621
- bug ! ( "try desugaring w/out call expr as discriminant " ) ;
625
+ bug ! ( "try desugaring w/out call expr as scrutinee " ) ;
622
626
} ;
623
627
624
- match discrim_ty {
628
+ match scrut_ty {
625
629
Some ( ty) if expected == ty => {
626
630
let source_map = self . tcx . sess . source_map ( ) ;
627
631
err. span_suggestion (
0 commit comments