Skip to content

Commit 40950b2

Browse files
committed
fix nits
1 parent b174b78 commit 40950b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc_mir/interpret/cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
7777
TyChar if v as u8 as u128 == v => Ok(PrimVal::Bytes(v)),
7878
TyChar => Err(EvalError::InvalidChar(v)),
7979

80-
// No alignment check needed for raw pointers
81-
TyRawPtr(_) => Ok(PrimVal::Bytes(v % (1 << (self.memory.pointer_size()*8)))),
80+
// No alignment check needed for raw pointers. But we have to truncate to target ptr size.
81+
TyRawPtr(_) => Ok(PrimVal::Bytes(v % (1u128 << self.memory.layout.pointer_size.bits()))),
8282

8383
_ => Err(EvalError::Unimplemented(format!("int to {:?} cast", ty))),
8484
}

0 commit comments

Comments
 (0)