Skip to content

Commit

Permalink
Use clearer name for integer bit width helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 8, 2018
1 parent eb18d39 commit 6cfda07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/librustc_mir/build/expr/as_rvalue.rs
Expand Up @@ -381,7 +381,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {

// Helper to get a `-1` value of the appropriate type
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
let bits = self.hir.type_bit_size(ty);
let bits = self.hir.integer_bit_width(ty);
let n = (!0u128) >> (128 - bits);
let literal = Literal::Value {
value: self.hir.tcx().mk_const(ty::Const {
Expand All @@ -396,7 +396,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
// Helper to get the minimum value of the appropriate type
fn minval_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
assert!(ty.is_signed());
let bits = self.hir.type_bit_size(ty);
let bits = self.hir.integer_bit_width(ty);
let n = 1 << (bits - 1);
let literal = Literal::Value {
value: self.hir.tcx().mk_const(ty::Const {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/hair/cx/mod.rs
Expand Up @@ -149,7 +149,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
}
}

pub fn type_bit_size(
pub fn integer_bit_width(
&self,
ty: Ty,
) -> u64 {
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
};

let clamp = |n| {
let size = self.type_bit_size(ty);
let size = self.integer_bit_width(ty);
trace!("clamp {} with size {} and amt {}", n, size, 128 - size);
let amt = 128 - size;
let result = (n << amt) >> amt;
Expand Down

0 comments on commit 6cfda07

Please sign in to comment.