use ptr_null where appropriate
This commit is contained in:
parent
fbbca59de7
commit
b7fec6b17f
@ -130,7 +130,7 @@ impl MemoryExtra {
|
||||
// This should be all-zero, pointer-sized.
|
||||
let layout = this.layout_of(this.tcx.types.usize)?;
|
||||
let place = this.allocate(layout, MiriMemoryKind::Machine.into());
|
||||
this.write_scalar(Scalar::from_machine_usize(0, &*this.tcx), place.into())?;
|
||||
this.write_scalar(Scalar::from_machine_usize(0, this), place.into())?;
|
||||
Self::add_extern_static(this, "__cxa_thread_atexit_impl", place.ptr);
|
||||
// "environ"
|
||||
Self::add_extern_static(this, "environ", this.machine.env_vars.environ.unwrap().ptr);
|
||||
|
@ -337,14 +337,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
// This is memory backing an extern static, hence `Machine`, not `Env`.
|
||||
let layout = this.layout_of(this.tcx.types.usize)?;
|
||||
let place = this.allocate(layout, MiriMemoryKind::Machine.into());
|
||||
this.write_scalar(Scalar::from_machine_usize(0, &*this.tcx), place.into())?;
|
||||
this.machine.env_vars.environ = Some(place);
|
||||
}
|
||||
|
||||
// Collect all the pointers to each variable in a vector.
|
||||
let mut vars: Vec<Scalar<Tag>> = this.machine.env_vars.map.values().map(|&ptr| ptr.into()).collect();
|
||||
// Add the trailing null pointer.
|
||||
vars.push(Scalar::from_machine_usize(0, this));
|
||||
vars.push(Scalar::ptr_null(this));
|
||||
// Make an array with all these pointers inside Miri.
|
||||
let tcx = this.tcx;
|
||||
let vars_layout =
|
||||
|
@ -860,7 +860,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
}
|
||||
Err(e) => {
|
||||
this.set_last_error_from_io_error(e)?;
|
||||
Ok(Scalar::from_machine_usize(0, this))
|
||||
Ok(Scalar::ptr_null(this))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ use std::iter;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc::mir;
|
||||
use rustc::mir::interpret::{InterpResult, PointerArithmetic};
|
||||
use rustc::ty;
|
||||
use rustc::ty::layout::{Align, LayoutOf};
|
||||
use rustc_apfloat::Float;
|
||||
|
Loading…
x
Reference in New Issue
Block a user