Skip to content

Commit b7fec6b

Browse files
committed
use ptr_null where appropriate
1 parent fbbca59 commit b7fec6b

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

src/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl MemoryExtra {
130130
// This should be all-zero, pointer-sized.
131131
let layout = this.layout_of(this.tcx.types.usize)?;
132132
let place = this.allocate(layout, MiriMemoryKind::Machine.into());
133-
this.write_scalar(Scalar::from_machine_usize(0, &*this.tcx), place.into())?;
133+
this.write_scalar(Scalar::from_machine_usize(0, this), place.into())?;
134134
Self::add_extern_static(this, "__cxa_thread_atexit_impl", place.ptr);
135135
// "environ"
136136
Self::add_extern_static(this, "environ", this.machine.env_vars.environ.unwrap().ptr);

src/shims/env.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
337337
// This is memory backing an extern static, hence `Machine`, not `Env`.
338338
let layout = this.layout_of(this.tcx.types.usize)?;
339339
let place = this.allocate(layout, MiriMemoryKind::Machine.into());
340-
this.write_scalar(Scalar::from_machine_usize(0, &*this.tcx), place.into())?;
341340
this.machine.env_vars.environ = Some(place);
342341
}
343342

344343
// Collect all the pointers to each variable in a vector.
345344
let mut vars: Vec<Scalar<Tag>> = this.machine.env_vars.map.values().map(|&ptr| ptr.into()).collect();
346345
// Add the trailing null pointer.
347-
vars.push(Scalar::from_machine_usize(0, this));
346+
vars.push(Scalar::ptr_null(this));
348347
// Make an array with all these pointers inside Miri.
349348
let tcx = this.tcx;
350349
let vars_layout =

src/shims/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
860860
}
861861
Err(e) => {
862862
this.set_last_error_from_io_error(e)?;
863-
Ok(Scalar::from_machine_usize(0, this))
863+
Ok(Scalar::ptr_null(this))
864864
}
865865
}
866866
}

src/shims/intrinsics.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::iter;
22
use std::convert::TryFrom;
33

44
use rustc::mir;
5-
use rustc::mir::interpret::{InterpResult, PointerArithmetic};
65
use rustc::ty;
76
use rustc::ty::layout::{Align, LayoutOf};
87
use rustc_apfloat::Float;

0 commit comments

Comments
 (0)