From 3b8d2e0016884fdc56e3e2208235606d999990a8 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 25 Jan 2018 14:56:34 +0100 Subject: [PATCH] Rename ConstVal::to_u128 to to_raw_bits --- src/librustc/middle/const_val.rs | 4 ++-- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/ty/inhabitedness/mod.rs | 2 +- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/const_eval/_match.rs | 2 +- src/librustc_mir/transform/simplify_branches.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustc/middle/const_val.rs b/src/librustc/middle/const_val.rs index 35c51c0c206b..a40147aa2a1f 100644 --- a/src/librustc/middle/const_val.rs +++ b/src/librustc/middle/const_val.rs @@ -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 { + pub fn to_raw_bits(&self) -> Option { 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 diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 1c60ae36cd33..30d63b8443e3 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -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, }; diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index bfaa661b2432..3e653cf126a8 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -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), diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 3b9fbc5c867a..4a5d9e228815 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -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 diff --git a/src/librustc_mir/const_eval/_match.rs b/src/librustc_mir/const_eval/_match.rs index 0f1eaf92ff12..3b9bbc0ba8b4 100644 --- a/src/librustc_mir/const_eval/_match.rs +++ b/src/librustc_mir/const_eval/_match.rs @@ -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![] diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index e39f5412355b..9dd48952208a 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -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()) { diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 2ad1580f75dc..fbdeb3334abd 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -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) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f5303979f9c3..56f2b30190f1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -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: