Skip to content

Commit 94ec311

Browse files
committed
make MPlaceTy non-Copy
1 parent 7a21ea8 commit 94ec311

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/helpers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -600,14 +600,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
600600
/// necessary.
601601
fn last_error_place(&mut self) -> InterpResult<'tcx, MPlaceTy<'tcx, Provenance>> {
602602
let this = self.eval_context_mut();
603-
if let Some(errno_place) = this.active_thread_ref().last_error {
604-
Ok(errno_place)
603+
if let Some(errno_place) = this.active_thread_ref().last_error.as_ref() {
604+
Ok(errno_place.clone())
605605
} else {
606606
// Allocate new place, set initial value to 0.
607607
let errno_layout = this.machine.layouts.u32;
608608
let errno_place = this.allocate(errno_layout, MiriMemoryKind::Machine.into())?;
609609
this.write_scalar(Scalar::from_u32(0), &errno_place)?;
610-
this.active_thread_mut().last_error = Some(errno_place);
610+
this.active_thread_mut().last_error = Some(errno_place.clone());
611611
Ok(errno_place)
612612
}
613613
}
@@ -725,7 +725,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
725725

726726
let mplace = MPlaceTy::from_aligned_ptr(ptr, layout);
727727

728-
this.check_mplace(mplace)?;
728+
this.check_mplace(&mplace)?;
729729

730730
Ok(mplace)
731731
}

src/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
668668
Self::add_extern_static(
669669
this,
670670
"environ",
671-
this.machine.env_vars.environ.unwrap().ptr,
671+
this.machine.env_vars.environ.as_ref().unwrap().ptr,
672672
);
673673
// A couple zero-initialized pointer-sized extern statics.
674674
// Most of them are for weak symbols, which we all set to null (indicating that the
@@ -685,7 +685,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
685685
Self::add_extern_static(
686686
this,
687687
"environ",
688-
this.machine.env_vars.environ.unwrap().ptr,
688+
this.machine.env_vars.environ.as_ref().unwrap().ptr,
689689
);
690690
}
691691
"android" => {

src/shims/env.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ impl<'tcx> EnvVars<'tcx> {
8787
ecx.deallocate_ptr(ptr, None, MiriMemoryKind::Runtime.into())?;
8888
}
8989
// Deallocate environ var list.
90-
let environ = ecx.machine.env_vars.environ.unwrap();
91-
let old_vars_ptr = ecx.read_pointer(&environ)?;
90+
let environ = ecx.machine.env_vars.environ.as_ref().unwrap();
91+
let old_vars_ptr = ecx.read_pointer(environ)?;
9292
ecx.deallocate_ptr(old_vars_ptr, None, MiriMemoryKind::Runtime.into())?;
9393
Ok(())
9494
}
@@ -431,8 +431,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
431431
fn update_environ(&mut self) -> InterpResult<'tcx> {
432432
let this = self.eval_context_mut();
433433
// Deallocate the old environ list, if any.
434-
if let Some(environ) = this.machine.env_vars.environ {
435-
let old_vars_ptr = this.read_pointer(&environ)?;
434+
if let Some(environ) = this.machine.env_vars.environ.as_ref() {
435+
let old_vars_ptr = this.read_pointer(environ)?;
436436
this.deallocate_ptr(old_vars_ptr, None, MiriMemoryKind::Runtime.into())?;
437437
} else {
438438
// No `environ` allocated yet, let's do that.
@@ -459,7 +459,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
459459
let place = this.project_field(&vars_place, idx)?;
460460
this.write_pointer(var, &place)?;
461461
}
462-
this.write_pointer(vars_place.ptr, &this.machine.env_vars.environ.unwrap())?;
462+
this.write_pointer(vars_place.ptr, &this.machine.env_vars.environ.clone().unwrap())?;
463463

464464
Ok(())
465465
}

src/shims/unix/macos/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
8686
"_NSGetEnviron" => {
8787
let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
8888
this.write_pointer(
89-
this.machine.env_vars.environ.expect("machine must be initialized").ptr,
89+
this.machine.env_vars.environ.as_ref().expect("machine must be initialized").ptr,
9090
dest,
9191
)?;
9292
}

0 commit comments

Comments
 (0)