Skip to content

Commit 63dc0e4

Browse files
committed
discriminant -> scrutinee
1 parent f8d2cce commit 63dc0e4

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

src/librustc/infer/error_reporting/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
607607
source,
608608
ref prior_arms,
609609
last_ty,
610-
discrim_hir_id,
610+
scrut_hir_id,
611611
..
612612
}) => match source {
613613
hir::MatchSource::IfLetDesugar { .. } => {
@@ -616,16 +616,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
616616
}
617617
hir::MatchSource::TryDesugar => {
618618
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
619-
let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id);
620-
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 {
621621
let arg_expr = args.first().expect("try desugaring call w/out arg");
622622
self.in_progress_tables
623623
.and_then(|tables| tables.borrow().expr_ty_opt(arg_expr))
624624
} else {
625-
bug!("try desugaring w/out call expr as discriminant");
625+
bug!("try desugaring w/out call expr as scrutinee");
626626
};
627627

628-
match discrim_ty {
628+
match scrut_ty {
629629
Some(ty) if expected == ty => {
630630
let source_map = self.tcx.sess.source_map();
631631
err.span_suggestion(

src/librustc/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub struct MatchExpressionArmCause<'tcx> {
315315
pub source: hir::MatchSource,
316316
pub prior_arms: Vec<Span>,
317317
pub last_ty: Ty<'tcx>,
318-
pub discrim_hir_id: hir::HirId,
318+
pub scrut_hir_id: hir::HirId,
319319
}
320320

321321
#[derive(Clone, Debug, PartialEq, Eq, Hash)]

src/librustc/traits/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,14 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
511511
source,
512512
ref prior_arms,
513513
last_ty,
514-
discrim_hir_id,
514+
scrut_hir_id,
515515
}) => tcx.lift(&last_ty).map(|last_ty| {
516516
super::MatchExpressionArm(box super::MatchExpressionArmCause {
517517
arm_span,
518518
source,
519519
prior_arms: prior_arms.clone(),
520520
last_ty,
521-
discrim_hir_id,
521+
scrut_hir_id,
522522
})
523523
}),
524524
super::Pattern { span, root_ty, origin_expr } => {

src/librustc_typeck/check/_match.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -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), true);
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

Comments
 (0)