Skip to content

Commit 6cfda07

Browse files
committed
Use clearer name for integer bit width helper function
1 parent eb18d39 commit 6cfda07

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
381381

382382
// Helper to get a `-1` value of the appropriate type
383383
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
384-
let bits = self.hir.type_bit_size(ty);
384+
let bits = self.hir.integer_bit_width(ty);
385385
let n = (!0u128) >> (128 - bits);
386386
let literal = Literal::Value {
387387
value: self.hir.tcx().mk_const(ty::Const {
@@ -396,7 +396,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
396396
// Helper to get the minimum value of the appropriate type
397397
fn minval_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
398398
assert!(ty.is_signed());
399-
let bits = self.hir.type_bit_size(ty);
399+
let bits = self.hir.integer_bit_width(ty);
400400
let n = 1 << (bits - 1);
401401
let literal = Literal::Value {
402402
value: self.hir.tcx().mk_const(ty::Const {

src/librustc_mir/hair/cx/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
149149
}
150150
}
151151

152-
pub fn type_bit_size(
152+
pub fn integer_bit_width(
153153
&self,
154154
ty: Ty,
155155
) -> u64 {
@@ -179,7 +179,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
179179
};
180180

181181
let clamp = |n| {
182-
let size = self.type_bit_size(ty);
182+
let size = self.integer_bit_width(ty);
183183
trace!("clamp {} with size {} and amt {}", n, size, 128 - size);
184184
let amt = 128 - size;
185185
let result = (n << amt) >> amt;

0 commit comments

Comments
 (0)