]> git.lizzy.rs Git - rust.git/commitdiff
Rename `amt` variables to `shift`
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Thu, 24 May 2018 12:20:45 +0000 (14:20 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Thu, 24 May 2018 18:49:38 +0000 (20:49 +0200)
src/librustc/mir/mod.rs
src/librustc/ty/sty.rs
src/librustc/ty/util.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/mod.rs

index 2fcb0255cc8f67a9e47a358caee14d7dcc8d6d47..e44b1dc886b5b345c264f8618b6331997c608bed 100644 (file)
@@ -1910,8 +1910,8 @@ pub fn print_miri_value<W: Write>(value: Value, ty: Ty, f: &mut W) -> fmt::Resul
                  let ty = tcx.lift_to_global(&ty).unwrap();
                  tcx.layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size.bits()
             });
-            let amt = 128 - bit_width;
-            write!(f, "{:?}{}", ((bits as i128) << amt) >> amt, i)
+            let shift = 128 - bit_width;
+            write!(f, "{:?}{}", ((bits as i128) << shift) >> shift, i)
         },
         (Value::Scalar(Scalar::Bits { bits, .. }), &TyChar) =>
             write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()),
index 524687f6ba70ae8df22dde8c31bd139c448b39cb..3347d47a4e81ec3d320fe9bdfb4d11413aaf85f6 100644 (file)
@@ -1827,8 +1827,8 @@ pub fn from_bits(
         let size = tcx.layout_of(ty).unwrap_or_else(|e| {
             panic!("could not compute layout for {:?}: {:?}", ty, e)
         }).size;
-        let amt = 128 - size.bits();
-        let truncated = (bits << amt) >> amt;
+        let shift = 128 - size.bits();
+        let truncated = (bits << shift) >> shift;
         assert_eq!(truncated, bits, "from_bits called with untruncated value");
         Self::from_scalar(tcx, Scalar::Bits { bits, defined: size.bits() as u8 }, ty.value)
     }
index e3db4972edc78ab0f4764b568d05653a54f3d1b3..9b7443f97ef1ffcda9b5d5477603575b65dfedad 100644 (file)
@@ -68,14 +68,14 @@ pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Sel
         };
 
         let bit_size = int.size().bits();
-        let amt = 128 - bit_size;
+        let shift = 128 - bit_size;
         if signed {
             let sext = |u| {
                 let i = u as i128;
-                (i << amt) >> amt
+                (i << shift) >> shift
             };
             let min = sext(1_u128 << (bit_size - 1));
-            let max = i128::max_value() >> amt;
+            let max = i128::max_value() >> shift;
             let val = sext(self.val);
             assert!(n < (i128::max_value() as u128));
             let n = n as i128;
@@ -87,13 +87,13 @@ pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Sel
             };
             // zero the upper bits
             let val = val as u128;
-            let val = (val << amt) >> amt;
+            let val = (val << shift) >> shift;
             (Self {
                 val: val as u128,
                 ty: self.ty,
             }, oflo)
         } else {
-            let max = u128::max_value() >> amt;
+            let max = u128::max_value() >> shift;
             let val = self.val;
             let oflo = val > max - n;
             let val = if oflo {
index e1ee4ebd70b3d7ff9aa9e9345b0328adee749a0b..8ff1738394e1b12e03737440e47024096f3a8b50 100644 (file)
@@ -158,9 +158,9 @@ pub fn const_eval_literal(
         let trunc = |n| {
             let param_ty = self.param_env.and(self.tcx.lift_to_global(&ty).unwrap());
             let bit_width = self.tcx.layout_of(param_ty).unwrap().size.bits();
-            trace!("trunc {} with size {} and amt {}", n, bit_width, 128 - bit_width);
-            let amt = 128 - bit_width;
-            let result = (n << amt) >> amt;
+            trace!("trunc {} with size {} and shift {}", n, bit_width, 128 - bit_width);
+            let shift = 128 - bit_width;
+            let result = (n << shift) >> shift;
             trace!("trunc result: {}", result);
             ConstValue::Scalar(Scalar::Bits {
                 bits: result,
index 983d777ef9b129fa2d7bc48b0eb7fa2401f2e1b3..9f6e376d3062afa417efc1088a607619133f2ee0 100644 (file)
@@ -930,17 +930,17 @@ pub fn read_discriminant_value(
                     let i = raw_discr.to_bits(discr.size)? as i128;
                     // going from layout tag type to typeck discriminant type
                     // requires first sign extending with the layout discriminant
-                    let amt = 128 - discr.size.bits();
-                    let sexted = (i << amt) >> amt;
+                    let shift = 128 - discr.size.bits();
+                    let sexted = (i << shift) >> shift;
                     // and then zeroing with the typeck discriminant type
                     let discr_ty = ty
                         .ty_adt_def().expect("tagged layout corresponds to adt")
                         .repr
                         .discr_type();
                     let discr_ty = layout::Integer::from_attr(self.tcx.tcx, discr_ty);
-                    let amt = 128 - discr_ty.size().bits();
+                    let shift = 128 - discr_ty.size().bits();
                     let truncatee = sexted as u128;
-                    (truncatee << amt) >> amt
+                    (truncatee << shift) >> shift
                 } else {
                     raw_discr.to_bits(discr.size)?
                 }
@@ -1005,8 +1005,8 @@ pub fn write_discriminant_value(
                 // their computation, but the in-memory tag is the smallest possible
                 // representation
                 let size = tag.value.size(self.tcx.tcx).bits();
-                let amt = 128 - size;
-                let discr_val = (discr_val << amt) >> amt;
+                let shift = 128 - size;
+                let discr_val = (discr_val << shift) >> shift;
 
                 let (discr_dest, tag) = self.place_field(dest, mir::Field::new(0), layout)?;
                 self.write_scalar(discr_dest, Scalar::Bits {
index d39bae5e8dbbaa1ca4ecc17539f5b6039af025a3..b5b4ac6df6b5e00caef78f555e1f8ec56d294556 100644 (file)
@@ -43,17 +43,17 @@ pub fn sign_extend<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, value: u128, ty: Ty<'t
     let size = layout.size.bits();
     assert!(layout.abi.is_signed());
     // sign extend
-    let amt = 128 - size;
+    let shift = 128 - size;
     // shift the unsigned value to the left
     // and back to the right as signed (essentially fills with FF on the left)
-    Ok((((value << amt) as i128) >> amt) as u128)
+    Ok((((value << shift) as i128) >> shift) as u128)
 }
 
 pub fn truncate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, value: u128, ty: Ty<'tcx>) -> EvalResult<'tcx, u128> {
     let param_env = ParamEnv::empty();
     let layout = tcx.layout_of(param_env.and(ty)).map_err(|layout| EvalErrorKind::Layout(layout))?;
     let size = layout.size.bits();
-    let amt = 128 - size;
+    let shift = 128 - size;
     // truncate (shift left to drop out leftover values, shift right to fill with zeroes)
-    Ok((value << amt) >> amt)
+    Ok((value << shift) >> shift)
 }