Skip to content

Commit 6c21a03

Browse files
committed
Refactor after miri api changes
1 parent 732d638 commit 6c21a03

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/librustc/mir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use std::slice;
3535
use std::vec::IntoIter;
3636
use std::{iter, mem, option, u32};
3737
use syntax::ast::{self, Name};
38-
use syntax::attr::SignedInt;
3938
use syntax::symbol::InternedString;
4039
use syntax_pos::{Span, DUMMY_SP};
4140
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,33 +461,36 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
461461
.collect()
462462
}
463463
ty::TyChar if exhaustive_integer_patterns => {
464+
value_constructors = true;
464465
let endpoint = |c: char| {
465-
ty::Const::from_bits(cx.tcx, c as u128, cx.tcx.types.char)
466+
let ty = ty::ParamEnv::empty().and(cx.tcx.types.char);
467+
ty::Const::from_bits(cx.tcx, c as u128, ty)
466468
};
467-
value_constructors = true;
468469
vec![
469470
// The valid Unicode Scalar Value ranges.
470471
ConstantRange(endpoint('\u{0000}'), endpoint('\u{D7FF}'), RangeEnd::Included),
471472
ConstantRange(endpoint('\u{E000}'), endpoint('\u{10FFFF}'), RangeEnd::Included),
472473
]
473474
}
474475
ty::TyInt(ity) if exhaustive_integer_patterns => {
476+
value_constructors = true;
475477
// FIXME(49937): refactor these bit manipulations into interpret.
476478
let bits = Integer::from_attr(cx.tcx, SignedInt(ity)).size().bits() as u128;
477479
let min = 1u128 << (bits - 1);
478480
let max = (1u128 << (bits - 1)) - 1;
479-
value_constructors = true;
480-
vec![ConstantRange(ty::Const::from_bits(cx.tcx, min as u128, pcx.ty),
481-
ty::Const::from_bits(cx.tcx, max as u128, pcx.ty),
481+
let ty = ty::ParamEnv::empty().and(pcx.ty);
482+
vec![ConstantRange(ty::Const::from_bits(cx.tcx, min as u128, ty),
483+
ty::Const::from_bits(cx.tcx, max as u128, ty),
482484
RangeEnd::Included)]
483485
}
484486
ty::TyUint(uty) if exhaustive_integer_patterns => {
487+
value_constructors = true;
485488
// FIXME(49937): refactor these bit manipulations into interpret.
486489
let bits = Integer::from_attr(cx.tcx, UnsignedInt(uty)).size().bits() as u128;
487490
let max = !0u128 >> (128 - bits);
488-
value_constructors = true;
489-
vec![ConstantRange(ty::Const::from_bits(cx.tcx, 0, pcx.ty),
490-
ty::Const::from_bits(cx.tcx, max, pcx.ty),
491+
let ty = ty::ParamEnv::empty().and(pcx.ty);
492+
vec![ConstantRange(ty::Const::from_bits(cx.tcx, 0, ty),
493+
ty::Const::from_bits(cx.tcx, max, ty),
491494
RangeEnd::Included)]
492495
}
493496
_ => {
@@ -623,8 +626,9 @@ impl<'tcx> IntRange<'tcx> {
623626
ConstantRange(lo, hi, end) => {
624627
assert_eq!(lo.ty, hi.ty);
625628
let ty = lo.ty;
626-
if let Some(lo) = lo.assert_bits(ty) {
627-
if let Some(hi) = hi.assert_bits(ty) {
629+
let env_ty = ty::ParamEnv::empty().and(ty);
630+
if let Some(lo) = lo.assert_bits(tcx, env_ty) {
631+
if let Some(hi) = hi.assert_bits(tcx, env_ty) {
628632
// Perform a shift if the underlying types are signed,
629633
// which makes the interval arithmetic simpler.
630634
let bias = IntRange::signed_bias(tcx, ty);
@@ -642,7 +646,7 @@ impl<'tcx> IntRange<'tcx> {
642646
}
643647
ConstantValue(val) => {
644648
let ty = val.ty;
645-
if let Some(val) = val.assert_bits(ty) {
649+
if let Some(val) = val.assert_bits(tcx, ty::ParamEnv::empty().and(ty)) {
646650
let bias = IntRange::signed_bias(tcx, ty);
647651
let val = val ^ bias;
648652
Some(IntRange { range: val..=val, ty })
@@ -707,6 +711,7 @@ fn ranges_subtract_pattern<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
707711
remaining_ranges.into_iter().map(|r| {
708712
let (lo, hi) = r.into_inner();
709713
let bias = IntRange::signed_bias(cx.tcx, ty);
714+
let ty = ty::ParamEnv::empty().and(ty);
710715
ConstantRange(ty::Const::from_bits(cx.tcx, lo ^ bias, ty),
711716
ty::Const::from_bits(cx.tcx, hi ^ bias, ty),
712717
RangeEnd::Included)

0 commit comments

Comments
 (0)