@@ -11,7 +11,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1111 pub fn check_match (
1212 & self ,
1313 expr : & ' tcx hir:: Expr < ' tcx > ,
14- discrim : & ' tcx hir:: Expr < ' tcx > ,
14+ scrut : & ' tcx hir:: Expr < ' tcx > ,
1515 arms : & ' tcx [ hir:: Arm < ' tcx > ] ,
1616 expected : Expectation < ' tcx > ,
1717 match_src : hir:: MatchSource ,
@@ -27,7 +27,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2727 } ;
2828
2929 // Type check the descriminant and get its type.
30- let discrim_ty = if force_scrutinee_bool {
30+ let scrut_ty = if force_scrutinee_bool {
3131 // Here we want to ensure:
3232 //
3333 // 1. That default match bindings are *not* accepted in the condition of an
@@ -36,9 +36,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3636 // 2. By expecting `bool` for `expr` we get nice diagnostics for e.g. `if x = y { .. }`.
3737 //
3838 // FIXME(60707): Consider removing hack with principled solution.
39- self . check_expr_has_type_or_error ( discrim , self . tcx . types . bool , |_| { } )
39+ self . check_expr_has_type_or_error ( scrut , self . tcx . types . bool , |_| { } )
4040 } else {
41- self . demand_discriminant_type ( arms, discrim )
41+ self . demand_scrutinee_type ( arms, scrut )
4242 } ;
4343
4444 // If there are no arms, that is a diverging match; a special case.
@@ -51,7 +51,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5151
5252 // Otherwise, we have to union together the types that the
5353 // arms produce and so forth.
54- let discrim_diverges = self . diverges . get ( ) ;
54+ let scrut_diverges = self . diverges . get ( ) ;
5555 self . diverges . set ( Diverges :: Maybe ) ;
5656
5757 // rust-lang/rust#55810: Typecheck patterns first (via eager
@@ -61,7 +61,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6161 . map ( |arm| {
6262 let mut all_pats_diverge = Diverges :: WarnedAlways ;
6363 self . diverges . set ( Diverges :: Maybe ) ;
64- self . check_pat_top ( & arm. pat , discrim_ty , Some ( discrim . span ) ) ;
64+ self . check_pat_top ( & arm. pat , scrut_ty , Some ( scrut . span ) , true ) ;
6565 all_pats_diverge &= self . diverges . get ( ) ;
6666
6767 // As discussed with @eddyb, this is for disabling unreachable_code
@@ -157,7 +157,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
157157 source : match_src,
158158 prior_arms : other_arms. clone ( ) ,
159159 last_ty : prior_arm_ty. unwrap ( ) ,
160- discrim_hir_id : discrim . hir_id ,
160+ scrut_hir_id : scrut . hir_id ,
161161 } ) ,
162162 ) ,
163163 } ;
@@ -186,8 +186,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
186186 } ;
187187 }
188188
189- // We won't diverge unless the discriminant or all arms diverge.
190- self . diverges . set ( discrim_diverges | all_arms_diverge) ;
189+ // We won't diverge unless the scrutinee or all arms diverge.
190+ self . diverges . set ( scrut_diverges | all_arms_diverge) ;
191191
192192 coercion. complete ( self )
193193 }
@@ -388,14 +388,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
388388 )
389389 }
390390
391- fn demand_discriminant_type (
391+ fn demand_scrutinee_type (
392392 & self ,
393393 arms : & ' tcx [ hir:: Arm < ' tcx > ] ,
394- discrim : & ' tcx hir:: Expr < ' tcx > ,
394+ scrut : & ' tcx hir:: Expr < ' tcx > ,
395395 ) -> Ty < ' tcx > {
396396 // Not entirely obvious: if matches may create ref bindings, we want to
397- // use the *precise* type of the discriminant , *not* some supertype, as
398- // the "discriminant type" (issue #23116).
397+ // use the *precise* type of the scrutinee , *not* some supertype, as
398+ // the "scrutinee type" (issue #23116).
399399 //
400400 // arielb1 [writes here in this comment thread][c] that there
401401 // is certainly *some* potential danger, e.g., for an example
@@ -454,17 +454,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
454454 } ) ;
455455
456456 if let Some ( m) = contains_ref_bindings {
457- self . check_expr_with_needs ( discrim , Needs :: maybe_mut_place ( m) )
457+ self . check_expr_with_needs ( scrut , Needs :: maybe_mut_place ( m) )
458458 } else {
459459 // ...but otherwise we want to use any supertype of the
460- // discriminant . This is sort of a workaround, see note (*) in
460+ // scrutinee . This is sort of a workaround, see note (*) in
461461 // `check_pat` for some details.
462- let discrim_ty = self . next_ty_var ( TypeVariableOrigin {
462+ let scrut_ty = self . next_ty_var ( TypeVariableOrigin {
463463 kind : TypeVariableOriginKind :: TypeInference ,
464- span : discrim . span ,
464+ span : scrut . span ,
465465 } ) ;
466- self . check_expr_has_type_or_error ( discrim , discrim_ty , |_| { } ) ;
467- discrim_ty
466+ self . check_expr_has_type_or_error ( scrut , scrut_ty , |_| { } ) ;
467+ scrut_ty
468468 }
469469 }
470470}
0 commit comments