about summary refs log tree commit diff
path: root/src/librustc_mir/borrow_check
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2018-12-11 19:56:59 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-01-01 20:05:02 +0100
commitb903cb9d6001bf6c199f15ffc0c61fdad802f328 (patch)
tree02ae3b3547307e44694660ed5780ea10d7e28100 /src/librustc_mir/borrow_check
parentcae164753f557f668cb75610abda4f790981e5e6 (diff)
downloadrust-b903cb9d6001bf6c199f15ffc0c61fdad802f328.tar.gz
rust-b903cb9d6001bf6c199f15ffc0c61fdad802f328.zip
Move the `Unevaluated` constant arm upwards in the type structure
Diffstat (limited to 'src/librustc_mir/borrow_check')
-rw-r--r--src/librustc_mir/borrow_check/error_reporting.rs5
-rw-r--r--src/librustc_mir/borrow_check/mutability_errors.rs4
-rw-r--r--src/librustc_mir/borrow_check/nll/renumber.rs2
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs15
-rw-r--r--src/librustc_mir/borrow_check/places_conflict.rs2
5 files changed, 18 insertions, 10 deletions
diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs
index 6a5b5d172bb..ab5a16a4744 100644
--- a/src/librustc_mir/borrow_check/error_reporting.rs
+++ b/src/librustc_mir/borrow_check/error_reporting.rs
@@ -1380,7 +1380,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
         );
         if let TerminatorKind::Call {
             func: Operand::Constant(box Constant {
-                literal: ty::Const { ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), ..  }, ..  },
+                literal: ty::LazyConst::Evaluated(ty::Const {
+                    ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), ..  },
+                    ..
+                }),
                 ..
             }),
             args,
diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs
index 0be8ecffcdf..63bf6faed40 100644
--- a/src/librustc_mir/borrow_check/mutability_errors.rs
+++ b/src/librustc_mir/borrow_check/mutability_errors.rs
@@ -468,13 +468,13 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
                             Terminator {
                                 kind: TerminatorKind::Call {
                                     func: Operand::Constant(box Constant {
-                                        literal: Const {
+                                        literal: ty::LazyConst::Evaluated(Const {
                                             ty: &TyS {
                                                 sty: TyKind::FnDef(id, substs),
                                                 ..
                                             },
                                             ..
-                                        },
+                                        }),
                                         ..
                                     }),
                                     ..
diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs
index 55af7399aab..5c24da7621b 100644
--- a/src/librustc_mir/borrow_check/nll/renumber.rs
+++ b/src/librustc_mir/borrow_check/nll/renumber.rs
@@ -88,7 +88,7 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> {
         debug!("visit_region: region={:?}", region);
     }
 
-    fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _location: Location) {
+    fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _location: Location) {
         *constant = self.renumber_regions(&*constant);
     }
 
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 796a2f79f75..3681c3d74eb 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -382,6 +382,11 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
             constant, location
         );
 
+        let literal = match constant.literal {
+            ty::LazyConst::Evaluated(lit) => lit,
+            ty::LazyConst::Unevaluated(..) => return,
+        };
+
         // FIXME(#46702) -- We need some way to get the predicates
         // associated with the "pre-evaluated" form of the
         // constant. For example, consider that the constant
@@ -390,7 +395,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
         // constraints on `'a` and `'b`. These constraints
         // would be lost if we just look at the normalized
         // value.
-        if let ty::FnDef(def_id, substs) = constant.literal.ty.sty {
+        if let ty::FnDef(def_id, substs) = literal.ty.sty {
             let tcx = self.tcx();
             let type_checker = &mut self.cx;
 
@@ -411,10 +416,10 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
             );
         }
 
-        debug!("sanitize_constant: expected_ty={:?}", constant.literal.ty);
+        debug!("sanitize_constant: expected_ty={:?}", literal.ty);
 
         if let Err(terr) = self.cx.eq_types(
-            constant.literal.ty,
+            literal.ty,
             constant.ty,
             location.to_locations(),
             ConstraintCategory::Boring,
@@ -424,7 +429,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
                 constant,
                 "constant {:?} should have type {:?} but has {:?} ({:?})",
                 constant,
-                constant.literal.ty,
+                literal.ty,
                 constant.ty,
                 terr,
             );
@@ -563,7 +568,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
             ProjectionElem::Subslice { from, to } => PlaceTy::Ty {
                 ty: match base_ty.sty {
                     ty::Array(inner, size) => {
-                        let size = size.unwrap_usize(tcx);
+                        let size = size.unwrap_evaluated().unwrap_usize(tcx);
                         let min_size = (from as u64) + (to as u64);
                         if let Some(rest_size) = size.checked_sub(min_size) {
                             tcx.mk_array(inner, rest_size)
diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs
index ac7182abb36..88c27a869c0 100644
--- a/src/librustc_mir/borrow_check/places_conflict.rs
+++ b/src/librustc_mir/borrow_check/places_conflict.rs
@@ -388,7 +388,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
         (Place::Promoted(p1), Place::Promoted(p2)) => {
             if p1.0 == p2.0 {
                 if let ty::Array(_, size) = p1.1.sty {
-                    if size.unwrap_usize(tcx) == 0 {
+                    if size.unwrap_evaluated().unwrap_usize(tcx) == 0 {
                         // Ignore conflicts with promoted [T; 0].
                         debug!("place_element_conflict: IGNORE-LEN-0-PROMOTED");
                         return Overlap::Disjoint;