]> git.lizzy.rs Git - rust.git/commitdiff
discriminant -> scrutinee
authorMazdak Farrokhzad <twingoow@gmail.com>
Mon, 30 Dec 2019 11:48:48 +0000 (12:48 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Mon, 30 Dec 2019 13:28:40 +0000 (14:28 +0100)
src/librustc/infer/error_reporting/mod.rs
src/librustc/traits/mod.rs
src/librustc/traits/structural_impls.rs
src/librustc_typeck/check/_match.rs

index 7254bb52d7039f6c866d84554e975987a6c908fa..b3a79c0883358895c38b36484d36d500bad2a7d0 100644 (file)
@@ -607,7 +607,7 @@ fn note_error_origin(
                 source,
                 ref prior_arms,
                 last_ty,
-                discrim_hir_id,
+                scrut_hir_id,
                 ..
             }) => match source {
                 hir::MatchSource::IfLetDesugar { .. } => {
@@ -616,16 +616,16 @@ fn note_error_origin(
                 }
                 hir::MatchSource::TryDesugar => {
                     if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
-                        let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id);
-                        let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.kind {
+                        let scrut_expr = self.tcx.hir().expect_expr(scrut_hir_id);
+                        let scrut_ty = if let hir::ExprKind::Call(_, args) = &scrut_expr.kind {
                             let arg_expr = args.first().expect("try desugaring call w/out arg");
                             self.in_progress_tables
                                 .and_then(|tables| tables.borrow().expr_ty_opt(arg_expr))
                         } else {
-                            bug!("try desugaring w/out call expr as discriminant");
+                            bug!("try desugaring w/out call expr as scrutinee");
                         };
 
-                        match discrim_ty {
+                        match scrut_ty {
                             Some(ty) if expected == ty => {
                                 let source_map = self.tcx.sess.source_map();
                                 err.span_suggestion(
index f726a52946ed81effee12be5e8676c91d5d9544b..fe373e02e10f368cbdfb96a3df20b391f60e6b30 100644 (file)
@@ -315,7 +315,7 @@ pub struct MatchExpressionArmCause<'tcx> {
     pub source: hir::MatchSource,
     pub prior_arms: Vec<Span>,
     pub last_ty: Ty<'tcx>,
-    pub discrim_hir_id: hir::HirId,
+    pub scrut_hir_id: hir::HirId,
 }
 
 #[derive(Clone, Debug, PartialEq, Eq, Hash)]
index 7b14ada8469a909d6309cf3b703565b2d001eb50..c439f20d640024d4784c1ec58b6ba85470ea643a 100644 (file)
@@ -511,14 +511,14 @@ fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
                 source,
                 ref prior_arms,
                 last_ty,
-                discrim_hir_id,
+                scrut_hir_id,
             }) => tcx.lift(&last_ty).map(|last_ty| {
                 super::MatchExpressionArm(box super::MatchExpressionArmCause {
                     arm_span,
                     source,
                     prior_arms: prior_arms.clone(),
                     last_ty,
-                    discrim_hir_id,
+                    scrut_hir_id,
                 })
             }),
             super::Pattern { span, root_ty, origin_expr } => {
index e4cf54f629c599b526bd8978abab0fbf794e004d..841dd226b40583166b06679d04abb21459c68a21 100644 (file)
@@ -11,7 +11,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     pub fn check_match(
         &self,
         expr: &'tcx hir::Expr<'tcx>,
-        discrim: &'tcx hir::Expr<'tcx>,
+        scrut: &'tcx hir::Expr<'tcx>,
         arms: &'tcx [hir::Arm<'tcx>],
         expected: Expectation<'tcx>,
         match_src: hir::MatchSource,
@@ -27,7 +27,7 @@ pub fn check_match(
         };
 
         // Type check the descriminant and get its type.
-        let discrim_ty = if force_scrutinee_bool {
+        let scrut_ty = if force_scrutinee_bool {
             // Here we want to ensure:
             //
             // 1. That default match bindings are *not* accepted in the condition of an
@@ -36,9 +36,9 @@ pub fn check_match(
             // 2. By expecting `bool` for `expr` we get nice diagnostics for e.g. `if x = y { .. }`.
             //
             // FIXME(60707): Consider removing hack with principled solution.
-            self.check_expr_has_type_or_error(discrim, self.tcx.types.bool, |_| {})
+            self.check_expr_has_type_or_error(scrut, self.tcx.types.bool, |_| {})
         } else {
-            self.demand_discriminant_type(arms, discrim)
+            self.demand_scrutinee_type(arms, scrut)
         };
 
         // If there are no arms, that is a diverging match; a special case.
@@ -51,7 +51,7 @@ pub fn check_match(
 
         // Otherwise, we have to union together the types that the
         // arms produce and so forth.
-        let discrim_diverges = self.diverges.get();
+        let scrut_diverges = self.diverges.get();
         self.diverges.set(Diverges::Maybe);
 
         // rust-lang/rust#55810: Typecheck patterns first (via eager
@@ -61,7 +61,7 @@ pub fn check_match(
             .map(|arm| {
                 let mut all_pats_diverge = Diverges::WarnedAlways;
                 self.diverges.set(Diverges::Maybe);
-                self.check_pat_top(&arm.pat, discrim_ty, Some(discrim.span), true);
+                self.check_pat_top(&arm.pat, scrut_ty, Some(scrut.span), true);
                 all_pats_diverge &= self.diverges.get();
 
                 // As discussed with @eddyb, this is for disabling unreachable_code
@@ -157,7 +157,7 @@ pub fn check_match(
                             source: match_src,
                             prior_arms: other_arms.clone(),
                             last_ty: prior_arm_ty.unwrap(),
-                            discrim_hir_id: discrim.hir_id,
+                            scrut_hir_id: scrut.hir_id,
                         }),
                     ),
                 };
@@ -186,8 +186,8 @@ pub fn check_match(
             };
         }
 
-        // We won't diverge unless the discriminant or all arms diverge.
-        self.diverges.set(discrim_diverges | all_arms_diverge);
+        // We won't diverge unless the scrutinee or all arms diverge.
+        self.diverges.set(scrut_diverges | all_arms_diverge);
 
         coercion.complete(self)
     }
@@ -388,14 +388,14 @@ fn if_cause(
         )
     }
 
-    fn demand_discriminant_type(
+    fn demand_scrutinee_type(
         &self,
         arms: &'tcx [hir::Arm<'tcx>],
-        discrim: &'tcx hir::Expr<'tcx>,
+        scrut: &'tcx hir::Expr<'tcx>,
     ) -> Ty<'tcx> {
         // Not entirely obvious: if matches may create ref bindings, we want to
-        // use the *precise* type of the discriminant, *not* some supertype, as
-        // the "discriminant type" (issue #23116).
+        // use the *precise* type of the scrutinee, *not* some supertype, as
+        // the "scrutinee type" (issue #23116).
         //
         // arielb1 [writes here in this comment thread][c] that there
         // is certainly *some* potential danger, e.g., for an example
@@ -454,17 +454,17 @@ fn demand_discriminant_type(
             });
 
         if let Some(m) = contains_ref_bindings {
-            self.check_expr_with_needs(discrim, Needs::maybe_mut_place(m))
+            self.check_expr_with_needs(scrut, Needs::maybe_mut_place(m))
         } else {
             // ...but otherwise we want to use any supertype of the
-            // discriminant. This is sort of a workaround, see note (*) in
+            // scrutinee. This is sort of a workaround, see note (*) in
             // `check_pat` for some details.
-            let discrim_ty = self.next_ty_var(TypeVariableOrigin {
+            let scrut_ty = self.next_ty_var(TypeVariableOrigin {
                 kind: TypeVariableOriginKind::TypeInference,
-                span: discrim.span,
+                span: scrut.span,
             });
-            self.check_expr_has_type_or_error(discrim, discrim_ty, |_| {});
-            discrim_ty
+            self.check_expr_has_type_or_error(scrut, scrut_ty, |_| {});
+            scrut_ty
         }
     }
 }