Skip to content

Commit 569ae80

Browse files
committed
Wrongly named a closure clamp when it was doing truncation
1 parent 1f9fa53 commit 569ae80

File tree

1 file changed

+5
-5
lines changed
  • src/librustc_mir/hair/cx

1 file changed

+5
-5
lines changed

src/librustc_mir/hair/cx/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
155155
})
156156
};
157157

158-
let clamp = |n| {
158+
let trunc = |n| {
159159
let gcx = self.tcx.global_tcx();
160160
let param_ty = self.param_env.and(gcx.lift(&ty).unwrap());
161161
let bit_width = gcx.layout_of(param_ty).unwrap().size.bits();
162-
trace!("clamp {} with size {} and amt {}", n, bit_width, 128 - bit_width);
162+
trace!("trunc {} with size {} and amt {}", n, bit_width, 128 - bit_width);
163163
let amt = 128 - bit_width;
164164
let result = (n << amt) >> amt;
165-
trace!("clamp result: {}", result);
165+
trace!("trunc result: {}", result);
166166
ConstValue::Scalar(Scalar::Bits {
167167
bits: result,
168168
defined: bit_width as u8,
@@ -193,9 +193,9 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
193193
LitKind::Int(n, _) if neg => {
194194
let n = n as i128;
195195
let n = n.overflowing_neg().0;
196-
clamp(n as u128)
196+
trunc(n as u128)
197197
},
198-
LitKind::Int(n, _) => clamp(n),
198+
LitKind::Int(n, _) => trunc(n),
199199
LitKind::Float(n, fty) => {
200200
parse_float(n, fty)
201201
}

0 commit comments

Comments
 (0)