about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2019-11-08 23:11:51 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2019-11-12 20:50:45 +0100
commit7378c25f2593086a496e66e638c305ded2e39e7a (patch)
tree0e5845094a1880ed5246eadca1e19824e1d6c944
parent028c83cdf6d6d0054bafaaf85af39bca393a104c (diff)
downloadrust-7378c25f2593086a496e66e638c305ded2e39e7a.tar.gz
rust-7378c25f2593086a496e66e638c305ded2e39e7a.zip
Rename in librustc_mir.
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs4
-rw-r--r--src/librustc_mir/const_eval.rs8
-rw-r--r--src/librustc_mir/hair/constant.rs2
-rw-r--r--src/librustc_mir/hair/cx/expr.rs8
-rw-r--r--src/librustc_mir/hair/pattern/_match.rs40
-rw-r--r--src/librustc_mir/hair/pattern/mod.rs7
-rw-r--r--src/librustc_mir/interpret/intrinsics.rs4
-rw-r--r--src/librustc_mir/interpret/operand.rs22
-rw-r--r--src/librustc_mir/monomorphize/collector.rs8
-rw-r--r--src/librustc_mir/transform/check_consts/qualifs.rs3
-rw-r--r--src/librustc_mir/transform/promote_consts.rs3
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs3
12 files changed, 66 insertions, 46 deletions
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
index 37fc0b09e5b..cdfbca65e7e 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -27,7 +27,7 @@ use rustc::infer::canonical::QueryRegionConstraints;
 use rustc::infer::outlives::env::RegionBoundPairs;
 use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime, NLLRegionVariableOrigin};
 use rustc::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
-use rustc::mir::interpret::{ConstValue, PanicInfo};
+use rustc::mir::interpret::PanicInfo;
 use rustc::mir::tcx::PlaceTy;
 use rustc::mir::visit::{PlaceContext, Visitor, NonMutatingUseContext};
 use rustc::mir::*;
@@ -309,7 +309,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
                 );
             }
         } else {
-            if let ConstValue::Unevaluated(def_id, substs) = constant.literal.val {
+            if let ty::ConstKind::Unevaluated(def_id, substs) = constant.literal.val {
                 if let Err(terr) = self.cx.fully_perform_op(
                     location.to_locations(),
                     ConstraintCategory::Boring,
diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs
index 707ad151182..326953d9f30 100644
--- a/src/librustc_mir/const_eval.rs
+++ b/src/librustc_mir/const_eval.rs
@@ -128,7 +128,7 @@ fn op_to_const<'tcx>(
             }
         },
     };
-    ecx.tcx.mk_const(ty::Const { val, ty: op.layout.ty })
+    ecx.tcx.mk_const(ty::Const { val: ty::ConstKind::Value(val), ty: op.layout.ty })
 }
 
 // Returns a pointer to where the result lives
@@ -519,7 +519,7 @@ pub fn const_caller_location<'tcx>(
     intern_const_alloc_recursive(&mut ecx, None, loc_place).unwrap();
     let loc_const = ty::Const {
         ty: loc_ty,
-        val: ConstValue::Scalar(loc_place.ptr.into()),
+        val: ty::ConstKind::Value(ConstValue::Scalar(loc_place.ptr.into())),
     };
 
     tcx.mk_const(loc_const)
@@ -580,10 +580,10 @@ fn validate_and_turn_into_const<'tcx>(
         if tcx.is_static(def_id) || cid.promoted.is_some() {
             let ptr = mplace.ptr.to_ptr()?;
             Ok(tcx.mk_const(ty::Const {
-                val: ConstValue::ByRef {
+                val: ty::ConstKind::Value(ConstValue::ByRef {
                     alloc: ecx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id),
                     offset: ptr.offset,
-                },
+                }),
                 ty: mplace.layout.ty,
             }))
         } else {
diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs
index b9e75a576ca..1abdcde10ab 100644
--- a/src/librustc_mir/hair/constant.rs
+++ b/src/librustc_mir/hair/constant.rs
@@ -56,7 +56,7 @@ crate fn lit_to_const<'tcx>(
         LitKind::Char(c) => ConstValue::Scalar(Scalar::from_char(c)),
         LitKind::Err(_) => unreachable!(),
     };
-    Ok(tcx.mk_const(ty::Const { val: lit, ty }))
+    Ok(tcx.mk_const(ty::Const { val: ty::ConstKind::Value(lit), ty }))
 }
 
 fn parse_float<'tcx>(
diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs
index 2ff690b7ccc..92c9c702c7a 100644
--- a/src/librustc_mir/hair/cx/expr.rs
+++ b/src/librustc_mir/hair/cx/expr.rs
@@ -5,7 +5,7 @@ use crate::hair::cx::to_ref::ToRef;
 use crate::hair::util::UserAnnotatedTyHelpers;
 use rustc_index::vec::Idx;
 use rustc::hir::def::{CtorOf, Res, DefKind, CtorKind};
-use rustc::mir::interpret::{GlobalId, ErrorHandled, ConstValue};
+use rustc::mir::interpret::{GlobalId, ErrorHandled};
 use rustc::ty::{self, AdtKind, Ty};
 use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability, PointerCast};
 use rustc::ty::subst::{InternalSubsts, SubstsRef};
@@ -692,7 +692,7 @@ fn make_mirror_unadjusted<'a, 'tcx>(
                             // and not the beginning of discriminants (which is always `0`)
                             let substs = InternalSubsts::identity_for_item(cx.tcx(), did);
                             let lhs = mk_const(cx.tcx().mk_const(ty::Const {
-                                val: ConstValue::Unevaluated(did, substs),
+                                val: ty::ConstKind::Unevaluated(did, substs),
                                 ty: var_ty,
                             }));
                             let bin = ExprKind::Binary {
@@ -914,7 +914,7 @@ fn convert_path_expr<'a, 'tcx>(
             let local_def_id = cx.tcx.hir().local_def_id(hir_id);
             let index = generics.param_def_id_to_index[&local_def_id];
             let name = cx.tcx.hir().name(hir_id);
-            let val = ConstValue::Param(ty::ParamConst::new(index, name));
+            let val = ty::ConstKind::Param(ty::ParamConst::new(index, name));
             ExprKind::Literal {
                 literal: cx.tcx.mk_const(
                     ty::Const {
@@ -932,7 +932,7 @@ fn convert_path_expr<'a, 'tcx>(
             debug!("convert_path_expr: (const) user_ty={:?}", user_ty);
             ExprKind::Literal {
                 literal: cx.tcx.mk_const(ty::Const {
-                    val: ConstValue::Unevaluated(def_id, substs),
+                    val: ty::ConstKind::Unevaluated(def_id, substs),
                     ty: cx.tables().node_type(expr.hir_id),
                 }),
                 user_ty,
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs
index 982330baf9c..9a1fbf71e6f 100644
--- a/src/librustc_mir/hair/pattern/_match.rs
+++ b/src/librustc_mir/hair/pattern/_match.rs
@@ -313,7 +313,10 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
             (
                 &ty::Ref(_, rty, _),
                 &PatKind::Constant {
-                    value: Const { val, ty: ty::TyS { kind: ty::Ref(_, crty, _), .. } },
+                    value: Const {
+                        val: ty::ConstKind::Value(val),
+                        ty: ty::TyS { kind: ty::Ref(_, crty, _), .. }
+                    },
                 },
             ) => Pat {
                 ty: pat.ty,
@@ -324,13 +327,21 @@ impl PatternFolder<'tcx> for LiteralExpander<'tcx> {
                         span: pat.span,
                         kind: box PatKind::Constant {
                             value: self.tcx.mk_const(Const {
-                                val: self.fold_const_value_deref(*val, rty, crty),
+                                val: ty::ConstKind::Value(self.fold_const_value_deref(*val, rty, crty)),
                                 ty: rty,
                             }),
                         },
                     },
                 },
             },
+
+            (
+                &ty::Ref(_, rty, _),
+                &PatKind::Constant {
+                    value: Const { val, ty: ty::TyS { kind: ty::Ref(_, crty, _), .. } },
+                },
+            ) => bug!("cannot deref {:#?}, {} -> {}", val, crty, rty),
+
             (_, &PatKind::Binding { subpattern: Some(ref s), .. }) => s.fold_with(self),
             _ => pat.super_fold_with(self),
         }
@@ -1245,7 +1256,7 @@ impl<'tcx> IntRange<'tcx> {
     ) -> Option<IntRange<'tcx>> {
         if let Some((target_size, bias)) = Self::integral_size_and_signed_bias(tcx, value.ty) {
             let ty = value.ty;
-            let val = if let ConstValue::Scalar(Scalar::Raw { data, size }) = value.val {
+            let val = if let ty::ConstKind::Value(ConstValue::Scalar(Scalar::Raw { data, size })) = value.val {
                 // For this specific pattern we can skip a lot of effort and go
                 // straight to the result, after doing a bit of checking. (We
                 // could remove this branch and just use the next branch, which
@@ -1781,7 +1792,19 @@ fn slice_pat_covered_by_const<'tcx>(
     suffix: &[Pat<'tcx>],
     param_env: ty::ParamEnv<'tcx>,
 ) -> Result<bool, ErrorReported> {
-    let data: &[u8] = match (const_val.val, &const_val.ty.kind) {
+    let const_val_val = if let ty::ConstKind::Value(val) = const_val.val {
+        val
+    } else {
+        bug!(
+            "slice_pat_covered_by_const: {:#?}, {:#?}, {:#?}, {:#?}",
+            const_val,
+            prefix,
+            slice,
+            suffix,
+        )
+    };
+
+    let data: &[u8] = match (const_val_val, &const_val.ty.kind) {
         (ConstValue::ByRef { offset, alloc, .. }, ty::Array(t, n)) => {
             assert_eq!(*t, tcx.types.u8);
             let n = n.eval_usize(tcx, param_env);
@@ -2054,7 +2077,8 @@ fn split_grouped_constructors<'p, 'tcx>(
                                     max_fixed_len =
                                         cmp::max(max_fixed_len, n.eval_usize(tcx, param_env))
                                 }
-                                (ConstValue::Slice { start, end, .. }, ty::Slice(_)) => {
+                                (ty::ConstKind::Value(ConstValue::Slice { start, end, .. }),
+                                 ty::Slice(_)) => {
                                     max_fixed_len = cmp::max(max_fixed_len, (end - start) as u64)
                                 }
                                 _ => {}
@@ -2253,17 +2277,17 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
             // is when they are subslices of nonzero slices.
             let (alloc, offset, n, ty) = match value.ty.kind {
                 ty::Array(t, n) => match value.val {
-                    ConstValue::ByRef { offset, alloc, .. } => {
+                    ty::ConstKind::Value(ConstValue::ByRef { offset, alloc, .. }) => {
                         (alloc, offset, n.eval_usize(cx.tcx, cx.param_env), t)
                     }
                     _ => span_bug!(pat.span, "array pattern is {:?}", value,),
                 },
                 ty::Slice(t) => {
                     match value.val {
-                        ConstValue::Slice { data, start, end } => {
+                        ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => {
                             (data, Size::from_bytes(start as u64), (end - start) as u64, t)
                         }
-                        ConstValue::ByRef { .. } => {
+                        ty::ConstKind::Value(ConstValue::ByRef { .. }) => {
                             // FIXME(oli-obk): implement `deref` for `ConstValue`
                             return None;
                         }
diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs
index f613f6f4b99..3d97ed6bf9b 100644
--- a/src/librustc_mir/hair/pattern/mod.rs
+++ b/src/librustc_mir/hair/pattern/mod.rs
@@ -1197,9 +1197,10 @@ pub fn compare_const_vals<'tcx>(
 
     if let ty::Str = ty.kind {
         match (a.val, b.val) {
-            (ConstValue::Slice { .. }, ConstValue::Slice { .. }) => {
-                let a_bytes = get_slice_bytes(&tcx, a.val);
-                let b_bytes = get_slice_bytes(&tcx, b.val);
+            (ty::ConstKind::Value(a_val @ ConstValue::Slice { .. }),
+             ty::ConstKind::Value(b_val @ ConstValue::Slice { .. })) => {
+                let a_bytes = get_slice_bytes(&tcx, a_val);
+                let b_bytes = get_slice_bytes(&tcx, b_val);
                 return from_bool(a_bytes == b_bytes);
             }
             _ => (),
diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs
index 39f10d8e604..b48cac082e3 100644
--- a/src/librustc_mir/interpret/intrinsics.rs
+++ b/src/librustc_mir/interpret/intrinsics.rs
@@ -54,11 +54,11 @@ crate fn eval_nullary_intrinsic<'tcx>(
         "type_name" => {
             let alloc = type_name::alloc_type_name(tcx, tp_ty);
             tcx.mk_const(ty::Const {
-                val: ConstValue::Slice {
+                val: ty::ConstKind::Value(ConstValue::Slice {
                     data: alloc,
                     start: 0,
                     end: alloc.len(),
-                },
+                }),
                 ty: tcx.mk_static_str(),
             })
         },
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs
index 79762b87b0a..4d2ccdc20da 100644
--- a/src/librustc_mir/interpret/operand.rs
+++ b/src/librustc_mir/interpret/operand.rs
@@ -545,23 +545,27 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             Scalar::Raw { data, size } => Scalar::Raw { data, size },
         };
         // Early-return cases.
-        match val.val {
-            ConstValue::Param(_) =>
+        let val_val = match val.val {
+            ty::ConstKind::Param(_) =>
                 throw_inval!(TooGeneric),
-            ConstValue::Unevaluated(def_id, substs) => {
+            ty::ConstKind::Unevaluated(def_id, substs) => {
                 let instance = self.resolve(def_id, substs)?;
                 return Ok(OpTy::from(self.const_eval_raw(GlobalId {
                     instance,
                     promoted: None,
                 })?));
             }
-            _ => {}
-        }
+            ty::ConstKind::Infer(..) |
+            ty::ConstKind::Bound(..) |
+            ty::ConstKind::Placeholder(..) =>
+                bug!("eval_const_to_op: Unexpected ConstKind {:?}", val),
+            ty::ConstKind::Value(val_val) => val_val,
+        };
         // Other cases need layout.
         let layout = from_known_layout(layout, || {
             self.layout_of(val.ty)
         })?;
-        let op = match val.val {
+        let op = match val_val {
             ConstValue::ByRef { alloc, offset } => {
                 let id = self.tcx.alloc_map.lock().create_memory_alloc(alloc);
                 // We rely on mutability being set correctly in that allocation to prevent writes
@@ -583,12 +587,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
                     self,
                 ))
             }
-            ConstValue::Param(..) |
-            ConstValue::Infer(..) |
-            ConstValue::Bound(..) |
-            ConstValue::Placeholder(..) |
-            ConstValue::Unevaluated(..) =>
-                bug!("eval_const_to_op: Unexpected ConstValue {:?}", val),
         };
         Ok(OpTy { op, layout })
     }
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs
index 49cdd914234..49f27a8117e 100644
--- a/src/librustc_mir/monomorphize/collector.rs
+++ b/src/librustc_mir/monomorphize/collector.rs
@@ -1284,15 +1284,15 @@ fn collect_const<'tcx>(
     );
 
     match substituted_constant.val {
-        ConstValue::Scalar(Scalar::Ptr(ptr)) =>
+        ty::ConstKind::Value(ConstValue::Scalar(Scalar::Ptr(ptr))) =>
             collect_miri(tcx, ptr.alloc_id, output),
-        ConstValue::Slice { data: alloc, start: _, end: _ } |
-        ConstValue::ByRef { alloc, .. } => {
+        ty::ConstKind::Value(ConstValue::Slice { data: alloc, start: _, end: _ }) |
+        ty::ConstKind::Value(ConstValue::ByRef { alloc, .. }) => {
             for &((), id) in alloc.relocations().values() {
                 collect_miri(tcx, id, output);
             }
         }
-        ConstValue::Unevaluated(def_id, substs) => {
+        ty::ConstKind::Unevaluated(def_id, substs) => {
             let instance = ty::Instance::resolve(tcx,
                                                 param_env,
                                                 def_id,
diff --git a/src/librustc_mir/transform/check_consts/qualifs.rs b/src/librustc_mir/transform/check_consts/qualifs.rs
index 496a5679067..595ef2aad49 100644
--- a/src/librustc_mir/transform/check_consts/qualifs.rs
+++ b/src/librustc_mir/transform/check_consts/qualifs.rs
@@ -1,7 +1,6 @@
 //! A copy of the `Qualif` trait in `qualify_consts.rs` that is suitable for the new validator.
 
 use rustc::mir::*;
-use rustc::mir::interpret::ConstValue;
 use rustc::ty::{self, Ty};
 use syntax_pos::DUMMY_SP;
 
@@ -118,7 +117,7 @@ pub trait Qualif {
             Operand::Move(ref place) => Self::in_place(cx, per_local, place.as_ref()),
 
             Operand::Constant(ref constant) => {
-                if let ConstValue::Unevaluated(def_id, _) = constant.literal.val {
+                if let ty::ConstKind::Unevaluated(def_id, _) = constant.literal.val {
                     // Don't peek inside trait associated constants.
                     if cx.tcx.trait_of_item(def_id).is_some() {
                         Self::in_any_value_of_ty(cx, constant.literal.ty)
diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs
index 48a58f1d0ee..a7f48162f9b 100644
--- a/src/librustc_mir/transform/promote_consts.rs
+++ b/src/librustc_mir/transform/promote_consts.rs
@@ -14,7 +14,6 @@
 
 use rustc::hir::def_id::DefId;
 use rustc::mir::*;
-use rustc::mir::interpret::ConstValue;
 use rustc::mir::visit::{PlaceContext, MutatingUseContext, MutVisitor, Visitor};
 use rustc::mir::traversal::ReversePostorder;
 use rustc::ty::{self, List, TyCtxt, TypeFoldable};
@@ -584,7 +583,7 @@ impl<'tcx> Validator<'_, 'tcx> {
             Operand::Move(place) => self.validate_place(place.as_ref()),
 
             Operand::Constant(constant) => {
-                if let ConstValue::Unevaluated(def_id, _) = constant.literal.val {
+                if let ty::ConstKind::Unevaluated(def_id, _) = constant.literal.val {
                     if self.tcx.trait_of_item(def_id).is_some() {
                         // Don't peek inside trait associated constants.
                         // (see below what we do for other consts, for now)
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index 39720af4cb5..0373fbc55f7 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -14,7 +14,6 @@ use rustc::ty::{self, TyCtxt, Ty, TypeFoldable};
 use rustc::ty::cast::CastTy;
 use rustc::ty::query::Providers;
 use rustc::mir::*;
-use rustc::mir::interpret::ConstValue;
 use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext, NonMutatingUseContext};
 use rustc::middle::lang_items;
 use rustc::session::config::nightly_options;
@@ -251,7 +250,7 @@ trait Qualif {
             Operand::Move(ref place) => Self::in_place(cx, place.as_ref()),
 
             Operand::Constant(ref constant) => {
-                if let ConstValue::Unevaluated(def_id, _) = constant.literal.val {
+                if let ty::ConstKind::Unevaluated(def_id, _) = constant.literal.val {
                     // Don't peek inside trait associated constants.
                     if cx.tcx.trait_of_item(def_id).is_some() {
                         Self::in_any_value_of_ty(cx, constant.literal.ty).unwrap_or(false)