Skip to content

Commit 35ea63b

Browse files
committed
Simplify implementation.
1 parent 9fd16d6 commit 35ea63b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
177177
sym::offset_of => {
178178
let tp_ty = instance.args.type_at(0);
179179

180-
let u32_layout = self.layout_of(self.tcx.types.u32)?;
181-
let variant = self.read_scalar(&args[0])?.to_bits(u32_layout.size)? as u32;
182-
let field = self.read_scalar(&args[1])?.to_bits(u32_layout.size)? as usize;
180+
let variant = self.read_scalar(&args[0])?.to_u32()?;
181+
let field = self.read_scalar(&args[1])?.to_u32()? as usize;
183182

184183
let layout = self.layout_of(tp_ty)?;
185184
let cx = ty::layout::LayoutCx::new(*self.tcx, self.typing_env);

0 commit comments

Comments
 (0)