Skip to content

Commit 7234992

Browse files
committed
Simplify implementation.
1 parent a1e15b2 commit 7234992

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
@@ -206,9 +206,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
206206
sym::offset_of => {
207207
let tp_ty = instance.args.type_at(0);
208208

209-
let u32_layout = self.layout_of(self.tcx.types.u32)?;
210-
let variant = self.read_scalar(&args[0])?.to_bits(u32_layout.size)? as u32;
211-
let field = self.read_scalar(&args[1])?.to_bits(u32_layout.size)? as usize;
209+
let variant = self.read_scalar(&args[0])?.to_u32()?;
210+
let field = self.read_scalar(&args[1])?.to_u32()? as usize;
212211

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

0 commit comments

Comments
 (0)