about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Schneider <github35764891676564198441@oli-obk.de>2018-05-24 11:28:35 +0200
committerOliver Schneider <github35764891676564198441@oli-obk.de>2018-05-24 20:49:38 +0200
commit569ae80a0aed5d5fdcde30706017a3122e5f7c5e (patch)
tree38b7fcda6cc76d8c454a0dbd0483cd578ec7dd4c
parent1f9fa5373899decb96e5456c2395a5576948a0b3 (diff)
downloadrust-569ae80a0aed5d5fdcde30706017a3122e5f7c5e.tar.gz
rust-569ae80a0aed5d5fdcde30706017a3122e5f7c5e.zip
Wrongly named a closure `clamp` when it was doing truncation
-rw-r--r--src/librustc_mir/hair/cx/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs
index d0965957f8b..149cea76a47 100644
--- a/src/librustc_mir/hair/cx/mod.rs
+++ b/src/librustc_mir/hair/cx/mod.rs
@@ -155,14 +155,14 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
             })
         };
 
-        let clamp = |n| {
+        let trunc = |n| {
             let gcx = self.tcx.global_tcx();
             let param_ty = self.param_env.and(gcx.lift(&ty).unwrap());
             let bit_width = gcx.layout_of(param_ty).unwrap().size.bits();
-            trace!("clamp {} with size {} and amt {}", n, bit_width, 128 - bit_width);
+            trace!("trunc {} with size {} and amt {}", n, bit_width, 128 - bit_width);
             let amt = 128 - bit_width;
             let result = (n << amt) >> amt;
-            trace!("clamp result: {}", result);
+            trace!("trunc result: {}", result);
             ConstValue::Scalar(Scalar::Bits {
                 bits: result,
                 defined: bit_width as u8,
@@ -193,9 +193,9 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
             LitKind::Int(n, _) if neg => {
                 let n = n as i128;
                 let n = n.overflowing_neg().0;
-                clamp(n as u128)
+                trunc(n as u128)
             },
-            LitKind::Int(n, _) => clamp(n),
+            LitKind::Int(n, _) => trunc(n),
             LitKind::Float(n, fty) => {
                 parse_float(n, fty)
             }