Skip to content

Commit cb933ef

Browse files
committed
rebase fallout
1 parent 089c403 commit cb933ef

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

src/librustc/ty/context.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,12 +1745,7 @@ impl<'a, 'tcx> Lift<'tcx> for Goal<'a> {
17451745
if tcx.interners.arena.in_arena(*self as *const _) {
17461746
return Some(unsafe { mem::transmute(*self) });
17471747
}
1748-
// Also try in the global tcx if we're not that.
1749-
if !tcx.is_global() {
1750-
self.lift_to_tcx(tcx.global_tcx())
1751-
} else {
1752-
None
1753-
}
1748+
Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self)))
17541749
}
17551750
}
17561751

src/librustc_mir/build/matches/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
658658
}
659659
}
660660

661-
(&TestKind::Range(range), &PatternKind::Constant { ref value }) => {
661+
(&TestKind::Range(range), &PatternKind::Constant { value }) => {
662662
if self.const_range_contains(range, value) == Some(false) {
663663
// `value` is not contained in the testing range,
664664
// so `value` can be matched only if this test fails.
@@ -787,7 +787,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
787787
fn const_range_contains(
788788
&self,
789789
range: PatternRange<'tcx>,
790-
value: &'tcx ty::Const<'tcx>,
790+
value: ty::Const<'tcx>,
791791
) -> Option<bool> {
792792
use std::cmp::Ordering::*;
793793

@@ -807,9 +807,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
807807
fn values_not_contained_in_range(
808808
&self,
809809
range: PatternRange<'tcx>,
810-
indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>,
810+
indices: &FxHashMap<ty::Const<'tcx>, usize>,
811811
) -> Option<bool> {
812-
for val in indices.keys() {
812+
for &val in indices.keys() {
813813
if self.const_range_contains(range, val)? {
814814
return Some(false);
815815
}

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'a, 'tcx> LiteralExpander<'a, 'tcx> {
223223
assert_eq!(t, u);
224224
ConstValue::ScalarPair(
225225
Scalar::Ptr(p),
226-
n.val.try_to_scalar().unwrap(),
226+
n.map_evaluated(|val| val.val.try_to_scalar()).unwrap(),
227227
)
228228
},
229229
// fat pointers stay the same
@@ -251,11 +251,10 @@ impl<'a, 'tcx> PatternFolder<'tcx> for LiteralExpander<'a, 'tcx> {
251251
subpattern: Pattern {
252252
ty: rty,
253253
span: pat.span,
254-
kind: box PatternKind::Constant { value: Const::from_const_value(
255-
self.tcx,
256-
self.fold_const_value_deref(*val, rty, crty),
257-
rty,
258-
) },
254+
kind: box PatternKind::Constant { value: Const {
255+
val: self.fold_const_value_deref(val, rty, crty),
256+
ty: rty,
257+
} },
259258
}
260259
}
261260
}
@@ -1396,7 +1395,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>,
13961395
fn slice_pat_covered_by_const<'tcx>(
13971396
tcx: TyCtxt<'_, 'tcx, '_>,
13981397
_span: Span,
1399-
const_val: &ty::Const<'tcx>,
1398+
const_val: ty::Const<'tcx>,
14001399
prefix: &[Pattern<'tcx>],
14011400
slice: &Option<Pattern<'tcx>>,
14021401
suffix: &[Pattern<'tcx>]
@@ -1751,12 +1750,27 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
17511750
// necessarily point to memory, they are usually just integers. The only time
17521751
// they should be pointing to memory is when they are subslices of nonzero
17531752
// slices
1754-
let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty {
1755-
ty::TyKind::Array(t, n) => (value.to_ptr(), n.unwrap_usize(cx.tcx), t),
1753+
let (opt_ptr, n, ty) = match value.ty.sty {
1754+
ty::TyKind::Array(t, n) => {
1755+
match value.val {
1756+
ConstValue::ByRef(id, alloc, offset) => (
1757+
Some((Pointer::new(id, offset), alloc)),
1758+
n.unwrap_usize(cx.tcx),
1759+
t,
1760+
),
1761+
_ => span_bug!(
1762+
pat.span,
1763+
"array pattern is {:?}", value,
1764+
),
1765+
}
1766+
},
17561767
ty::TyKind::Slice(t) => {
17571768
match value.val {
17581769
ConstValue::ScalarPair(ptr, n) => (
1759-
ptr.to_ptr().ok(),
1770+
ptr.to_ptr().ok().map(|ptr| (
1771+
ptr,
1772+
cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id),
1773+
)),
17601774
n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64,
17611775
t,
17621776
),

0 commit comments

Comments
 (0)