]> git.lizzy.rs Git - rust.git/commitdiff
rebase fallout
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 15 Dec 2018 10:29:52 +0000 (11:29 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 1 Jan 2019 19:05:02 +0000 (20:05 +0100)
src/librustc/ty/context.rs
src/librustc_mir/build/matches/test.rs
src/librustc_mir/hair/pattern/_match.rs

index 108fcc1bd3f21023aff4e79c6bb118b174432c38..dfeab9715cc01dfa5281c7426554297328295d61 100644 (file)
@@ -1745,12 +1745,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Goal<'tcx
         if tcx.interners.arena.in_arena(*self as *const _) {
             return Some(unsafe { mem::transmute(*self) });
         }
-        // Also try in the global tcx if we're not that.
-        if !tcx.is_global() {
-            self.lift_to_tcx(tcx.global_tcx())
-        } else {
-            None
-        }
+        Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self)))
     }
 }
 
index 3d960a2dd288abbc4bc1d72d961d4be2f90438b8..aae3de68aaae08996e1c853bd2532b5291374d66 100644 (file)
@@ -658,7 +658,7 @@ pub fn sort_candidate<'pat>(&mut self,
                 }
             }
 
-            (&TestKind::Range(range), &PatternKind::Constant { ref value }) => {
+            (&TestKind::Range(range), &PatternKind::Constant { value }) => {
                 if self.const_range_contains(range, value) == Some(false) {
                     // `value` is not contained in the testing range,
                     // so `value` can be matched only if this test fails.
@@ -787,7 +787,7 @@ fn error_simplifyable<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> !
     fn const_range_contains(
         &self,
         range: PatternRange<'tcx>,
-        value: &'tcx ty::Const<'tcx>,
+        value: ty::Const<'tcx>,
     ) -> Option<bool> {
         use std::cmp::Ordering::*;
 
@@ -807,9 +807,9 @@ fn const_range_contains(
     fn values_not_contained_in_range(
         &self,
         range: PatternRange<'tcx>,
-        indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>,
+        indices: &FxHashMap<ty::Const<'tcx>, usize>,
     ) -> Option<bool> {
-        for val in indices.keys() {
+        for &val in indices.keys() {
             if self.const_range_contains(range, val)? {
                 return Some(false);
             }
index dc7331a2cd92dc5f7afc8df19656fa806aaca2ff..b25d47b390175ba7790049a1cef72ecf1803234a 100644 (file)
@@ -223,7 +223,7 @@ fn fold_const_value_deref(
                 assert_eq!(t, u);
                 ConstValue::ScalarPair(
                     Scalar::Ptr(p),
-                    n.val.try_to_scalar().unwrap(),
+                    n.map_evaluated(|val| val.val.try_to_scalar()).unwrap(),
                 )
             },
             // fat pointers stay the same
@@ -251,11 +251,10 @@ fn fold_pattern(&mut self, pat: &Pattern<'tcx>) -> Pattern<'tcx> {
                         subpattern: Pattern {
                             ty: rty,
                             span: pat.span,
-                            kind: box PatternKind::Constant { value: Const::from_const_value(
-                                self.tcx,
-                                self.fold_const_value_deref(*val, rty, crty),
-                                rty,
-                            ) },
+                            kind: box PatternKind::Constant { value: Const {
+                                val: self.fold_const_value_deref(val, rty, crty),
+                                ty: rty,
+                            } },
                         }
                     }
                 }
@@ -1396,7 +1395,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
 fn slice_pat_covered_by_const<'tcx>(
     tcx: TyCtxt<'_, 'tcx, '_>,
     _span: Span,
-    const_val: &ty::Const<'tcx>,
+    const_val: ty::Const<'tcx>,
     prefix: &[Pattern<'tcx>],
     slice: &Option<Pattern<'tcx>>,
     suffix: &[Pattern<'tcx>]
@@ -1751,12 +1750,27 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
                     // necessarily point to memory, they are usually just integers. The only time
                     // they should be pointing to memory is when they are subslices of nonzero
                     // slices
-                    let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty {
-                        ty::TyKind::Array(t, n) => (value.to_ptr(), n.unwrap_usize(cx.tcx), t),
+                    let (opt_ptr, n, ty) = match value.ty.sty {
+                        ty::TyKind::Array(t, n) => {
+                            match value.val {
+                                ConstValue::ByRef(id, alloc, offset) => (
+                                    Some((Pointer::new(id, offset), alloc)),
+                                    n.unwrap_usize(cx.tcx),
+                                    t,
+                                ),
+                                _ => span_bug!(
+                                    pat.span,
+                                    "array pattern is {:?}", value,
+                                ),
+                            }
+                        },
                         ty::TyKind::Slice(t) => {
                             match value.val {
                                 ConstValue::ScalarPair(ptr, n) => (
-                                    ptr.to_ptr().ok(),
+                                    ptr.to_ptr().ok().map(|ptr| (
+                                        ptr,
+                                        cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id),
+                                    )),
                                     n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64,
                                     t,
                                 ),