This commit is contained in:
The Miri Cronjob Bot 2024-12-07 05:05:09 +00:00
parent 97633d8e60
commit 8f05e4c4ce
3 changed files with 10 additions and 15 deletions

View file

@ -1245,7 +1245,10 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
/// Called on `ptr as usize` casts.
/// (Actually computing the resulting `usize` doesn't need machine help,
/// that's just `Scalar::try_to_int`.)
fn expose_provenance(ecx: &InterpCx<'tcx, Self>, provenance: Self::Provenance) -> InterpResult<'tcx> {
fn expose_provenance(
ecx: &InterpCx<'tcx, Self>,
provenance: Self::Provenance,
) -> InterpResult<'tcx> {
match provenance {
Provenance::Concrete { alloc_id, tag } => ecx.expose_ptr(alloc_id, tag),
Provenance::Wildcard => {

View file

@ -4,10 +4,8 @@ use std::ops::Deref;
use libffi::high::call as ffi;
use libffi::low::CodePtr;
use rustc_abi::{BackendRepr, HasDataLayout, Size};
use rustc_middle::{
mir::interpret::Pointer,
ty::{self as ty, IntTy, UintTy},
};
use rustc_middle::mir::interpret::Pointer;
use rustc_middle::ty::{self as ty, IntTy, UintTy};
use rustc_span::Symbol;
use crate::*;
@ -177,7 +175,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
this.prepare_for_native_call(alloc_id, prov)?;
}
}
// FIXME: In the future, we should also call `prepare_for_native_call` on all previously
// exposed allocations, since C may access any of them.

View file

@ -3,7 +3,6 @@
//@only-on-host
//@compile-flags: -Zmiri-permissive-provenance
#![feature(box_as_ptr)]
use std::mem::MaybeUninit;
@ -60,7 +59,7 @@ fn test_init_array() {
const LEN: usize = 3;
let mut array = MaybeUninit::<[i32; LEN]>::uninit();
let val = 31;
let array = unsafe {
init_array(array.as_mut_ptr().cast::<i32>(), LEN, val);
array.assume_init()
@ -72,7 +71,7 @@ fn test_init_array() {
fn test_init_static_inner() {
#[repr(C)]
struct SyncPtr {
ptr: *mut i32
ptr: *mut i32,
}
unsafe impl Sync for SyncPtr {}
@ -183,17 +182,12 @@ fn test_swap_ptr_triple_dangling() {
let ptr = Box::as_ptr(&b);
drop(b);
let z = 121;
let triple = Triple {
ptr0: &raw const x,
ptr1: ptr,
ptr2: &raw const z
};
let triple = Triple { ptr0: &raw const x, ptr1: ptr, ptr2: &raw const z };
unsafe { swap_ptr_triple_dangling(&triple) }
assert_eq!(unsafe { *triple.ptr2 }, x);
}
/// Test function that directly returns its pointer argument.
fn test_return_ptr() {
extern "C" {