Skip to content

Commit

Permalink
layout computation: eagerly error for unexpected unsized fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Sep 16, 2024
1 parent 06eaeed commit d1d77b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub fn create_ecx<'tcx>(
config: &MiriConfig,
) -> InterpResult<'tcx, InterpCx<'tcx, MiriMachine<'tcx>>> {
let param_env = ty::ParamEnv::reveal_all();
let layout_cx = LayoutCx { tcx, param_env };
let layout_cx = LayoutCx::new(tcx, param_env);
let mut ecx =
InterpCx::new(tcx, rustc_span::DUMMY_SP, param_env, MiriMachine::new(config, layout_cx));

Expand Down
11 changes: 5 additions & 6 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rustc_middle::{
query::TyCtxtAt,
ty::{
self,
layout::{LayoutCx, LayoutError, LayoutOf, TyAndLayout},
layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf, TyAndLayout},
Instance, Ty, TyCtxt,
},
};
Expand Down Expand Up @@ -382,7 +382,7 @@ pub struct PrimitiveLayouts<'tcx> {

impl<'tcx> PrimitiveLayouts<'tcx> {
fn new(layout_cx: LayoutCx<'tcx>) -> Result<Self, &'tcx LayoutError<'tcx>> {
let tcx = layout_cx.tcx;
let tcx = layout_cx.tcx();
let mut_raw_ptr = Ty::new_mut_ptr(tcx, tcx.types.unit);
let const_raw_ptr = Ty::new_imm_ptr(tcx, tcx.types.unit);
Ok(Self {
Expand Down Expand Up @@ -597,13 +597,12 @@ pub struct MiriMachine<'tcx> {

impl<'tcx> MiriMachine<'tcx> {
pub(crate) fn new(config: &MiriConfig, layout_cx: LayoutCx<'tcx>) -> Self {
let tcx = layout_cx.tcx;
let tcx = layout_cx.tcx();
let local_crates = helpers::get_local_crates(tcx);
let layouts =
PrimitiveLayouts::new(layout_cx).expect("Couldn't get layouts of primitive types");
let profiler = config.measureme_out.as_ref().map(|out| {
let crate_name = layout_cx
.tcx
let crate_name = tcx
.sess
.opts
.crate_name
Expand Down Expand Up @@ -701,7 +700,7 @@ impl<'tcx> MiriMachine<'tcx> {
clock: Clock::new(config.isolated_op == IsolatedOp::Allow),
#[cfg(unix)]
native_lib: config.native_lib.as_ref().map(|lib_file_path| {
let target_triple = layout_cx.tcx.sess.opts.target_triple.triple();
let target_triple = tcx.sess.opts.target_triple.triple();
// Check if host target == the session target.
if env!("TARGET") != target_triple {
panic!(
Expand Down

0 comments on commit d1d77b8

Please sign in to comment.