Skip to content

Commit bd73150

Browse files
committed
Use precomputed layouts.
1 parent a40ff56 commit bd73150

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/shims/windows/foreign_items.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
112112

113113
// Querying system information
114114
"GetSystemInfo" => {
115-
use crate::rustc_middle::ty::{layout::LayoutOf, TyKind, UintTy};
116-
117115
let [system_info] =
118116
this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
119117
let system_info = this.deref_operand(system_info)?;
@@ -123,16 +121,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
123121
iter::repeat(0u8).take(system_info.layout.size.bytes() as usize),
124122
)?;
125123
// Set selected fields.
126-
let word_ty = this.tcx.mk_ty(TyKind::Uint(UintTy::U16));
127-
let dword_ty = this.tcx.mk_ty(TyKind::Uint(UintTy::U32));
128-
let usize_ty = this.tcx.mk_ty(TyKind::Uint(UintTy::Usize));
129-
let word_layout = this.layout_of(word_ty)?;
130-
let dword_layout = this.layout_of(dword_ty)?;
131-
let usize_layout = this.layout_of(usize_ty)?;
124+
let word_layout = this.machine.layouts.u16;
125+
let dword_layout = this.machine.layouts.u32;
126+
let usize_layout = this.machine.layouts.usize;
132127

133128
// Using `mplace_field` is error-prone, see: https://github.com/rust-lang/miri/issues/2136.
134129
// Pointer fields have different sizes on different targets.
135-
// To avoid all these issue we calculate the offsets dynamically.
130+
// To avoid all these issue we calculate the offsets ourselves.
136131
let field_sizes = [
137132
word_layout.size, // 0, wProcessorArchitecture : WORD
138133
word_layout.size, // 1, wReserved : WORD

0 commit comments

Comments
 (0)