Rename ConstVal::to_u128 to to_raw_bits

This commit is contained in:
Oliver Schneider 2018-01-25 14:56:34 +01:00
parent 2f2c90e733
commit 3b8d2e0016
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
8 changed files with 9 additions and 9 deletions

View file

@ -39,7 +39,7 @@ pub struct ByteArray<'tcx> {
impl<'tcx> serialize::UseSpecializedDecodable for ByteArray<'tcx> {}
impl<'tcx> ConstVal<'tcx> {
pub fn to_u128(&self) -> Option<u128> {
pub fn to_raw_bits(&self) -> Option<u128> {
match *self {
ConstVal::Value(Value::ByVal(PrimVal::Bytes(b))) => {
Some(b)
@ -48,7 +48,7 @@ impl<'tcx> ConstVal<'tcx> {
}
}
pub fn unwrap_u64(&self) -> u64 {
match self.to_u128() {
match self.to_raw_bits() {
Some(val) => {
assert_eq!(val as u64 as u128, val);
val as u64

View file

@ -913,7 +913,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
// Always promote `[T; 0]` (even when e.g. borrowed mutably).
let promotable = match expr_ty.sty {
ty::TyArray(_, len) if len.val.to_u128() == Some(0) => true,
ty::TyArray(_, len) if len.val.to_raw_bits() == Some(0) => true,
_ => promotable,
};

View file

@ -262,7 +262,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
}))
},
TyArray(ty, len) => {
match len.val.to_u128() {
match len.val.to_raw_bits() {
// If the array is definitely non-empty, it's uninhabited if
// the type of its elements is uninhabited.
Some(n) if n != 0 => ty.uninhabited_from(visited, tcx),

View file

@ -127,7 +127,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
indices.entry(value)
.or_insert_with(|| {
options.push(value.val.to_u128().expect("switching on int"));
options.push(value.val.to_raw_bits().expect("switching on int"));
options.len() - 1
});
true

View file

@ -446,7 +446,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
}))
}).collect()
}
ty::TyArray(ref sub_ty, len) if len.val.to_u128().is_some() => {
ty::TyArray(ref sub_ty, len) if len.val.to_raw_bits().is_some() => {
let len = len.val.unwrap_u64();
if len != 0 && cx.is_uninhabited(sub_ty) {
vec![]

View file

@ -41,7 +41,7 @@ impl MirPass for SimplifyBranches {
TerminatorKind::SwitchInt { discr: Operand::Constant(box Constant {
literal: Literal::Value { ref value }, ..
}), ref values, ref targets, .. } => {
if let Some(constint) = value.val.to_u128() {
if let Some(constint) = value.val.to_raw_bits() {
let (otherwise, targets) = targets.split_last().unwrap();
let mut ret = TerminatorKind::Goto { target: *otherwise };
for (&v, t) in values.iter().zip(targets.iter()) {

View file

@ -804,7 +804,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
self.complete_drop(Some(DropFlagMode::Deep), succ, unwind)
}
ty::TyArray(ety, size) => self.open_drop_for_array(
ety, size.val.to_u128().map(|i| i as u64)),
ety, size.val.to_raw_bits().map(|i| i as u64)),
ty::TySlice(ety) => self.open_drop_for_array(ety, None),
_ => bug!("open drop from non-ADT `{:?}`", ty)

View file

@ -4040,7 +4040,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
};
if let Ok(count) = count {
let zero_or_one = count.val.to_u128().map_or(false, |count| count <= 1);
let zero_or_one = count.val.to_raw_bits().map_or(false, |count| count <= 1);
if !zero_or_one {
// For [foo, ..n] where n > 1, `foo` must have
// Copy type: