Skip to content

Commit a591e9f

Browse files
committed
Auto merge of rust-lang#2440 - RalfJung:up, r=RalfJung
rustup
2 parents fff4742 + cbff63a commit a591e9f

File tree

7 files changed

+12
-31
lines changed

7 files changed

+12
-31
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
35a061724802377a21fc6dac1ebcbb9b8d1f558a
1+
7fe022f5aa32bbbb33c3a58755729d6667a461a9

src/machine.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
545545
true
546546
}
547547

548-
#[inline(always)]
549-
fn enforce_number_no_provenance(_ecx: &MiriEvalContext<'mir, 'tcx>) -> bool {
550-
true
551-
}
552-
553548
#[inline(always)]
554549
fn enforce_abi(ecx: &MiriEvalContext<'mir, 'tcx>) -> bool {
555550
ecx.machine.enforce_abi
@@ -753,14 +748,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
753748
intptrcast::GlobalStateInner::ptr_from_addr_cast(ecx, addr)
754749
}
755750

756-
#[inline(always)]
757-
fn ptr_from_addr_transmute(
758-
ecx: &MiriEvalContext<'mir, 'tcx>,
759-
addr: u64,
760-
) -> Pointer<Option<Self::Provenance>> {
761-
intptrcast::GlobalStateInner::ptr_from_addr_transmute(ecx, addr)
762-
}
763-
764751
fn expose_ptr(
765752
ecx: &mut InterpCx<'mir, 'tcx, Self>,
766753
ptr: Pointer<Self::Provenance>,

src/operator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'mir, 'tcx> {
5757

5858
Offset => {
5959
assert!(left.layout.ty.is_unsafe_ptr());
60-
let ptr = self.scalar_to_ptr(left.to_scalar()?)?;
60+
let ptr = left.to_scalar()?.to_pointer(self)?;
6161
let offset = right.to_scalar()?.to_machine_isize(self)?;
6262

6363
let pointee_ty =
@@ -71,7 +71,7 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'mir, 'tcx> {
7171
Add | Sub | BitOr | BitAnd | BitXor => {
7272
assert!(left.layout.ty.is_unsafe_ptr());
7373
assert!(right.layout.ty.is_unsafe_ptr());
74-
let ptr = self.scalar_to_ptr(left.to_scalar()?)?;
74+
let ptr = left.to_scalar()?.to_pointer(self)?;
7575
// We do the actual operation with usize-typed scalars.
7676
let left = ImmTy::from_uint(ptr.addr().bytes(), self.machine.layouts.usize);
7777
let right = ImmTy::from_uint(

src/shims/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
201201
this.saturating_arith(mir_op, &left, &right)?
202202
}
203203
Op::WrappingOffset => {
204-
let ptr = this.scalar_to_ptr(left.to_scalar()?)?;
204+
let ptr = left.to_scalar()?.to_pointer(this)?;
205205
let offset_count = right.to_scalar()?.to_machine_isize(this)?;
206206
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap().ty;
207207

src/shims/panic.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use helpers::check_arg_count;
2626
#[derive(Debug)]
2727
pub struct CatchUnwindData<'tcx> {
2828
/// The `catch_fn` callback to call in case of a panic.
29-
catch_fn: Scalar<Provenance>,
29+
catch_fn: Pointer<Option<Provenance>>,
3030
/// The `data` argument for that callback.
3131
data: Scalar<Provenance>,
3232
/// The return place from the original call to `try`.
@@ -86,7 +86,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
8686
let [try_fn, data, catch_fn] = check_arg_count(args)?;
8787
let try_fn = this.read_pointer(try_fn)?;
8888
let data = this.read_scalar(data)?.check_init()?;
89-
let catch_fn = this.read_scalar(catch_fn)?.check_init()?;
89+
let catch_fn = this.read_pointer(catch_fn)?;
9090

9191
// Now we make a function call, and pass `data` as first and only argument.
9292
let f_instance = this.get_ptr_fn(try_fn)?.as_instance()?;
@@ -140,8 +140,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
140140
let payload = this.active_thread_mut().panic_payload.take().unwrap();
141141

142142
// Push the `catch_fn` stackframe.
143-
let f_instance =
144-
this.get_ptr_fn(this.scalar_to_ptr(catch_unwind.catch_fn)?)?.as_instance()?;
143+
let f_instance = this.get_ptr_fn(catch_unwind.catch_fn)?.as_instance()?;
145144
trace!("catch_fn: {:?}", f_instance);
146145
this.call_function(
147146
f_instance,

src/shims/tls.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,10 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
241241
// (that would be basically https://github.com/rust-lang/miri/issues/450),
242242
// we specifically look up the static in libstd that we know is placed
243243
// in that section.
244-
let thread_callback = this.eval_path_scalar(&[
245-
"std",
246-
"sys",
247-
"windows",
248-
"thread_local_key",
249-
"p_thread_callback",
250-
])?;
251-
let thread_callback =
252-
this.get_ptr_fn(this.scalar_to_ptr(thread_callback)?)?.as_instance()?;
244+
let thread_callback = this
245+
.eval_path_scalar(&["std", "sys", "windows", "thread_local_key", "p_thread_callback"])?
246+
.to_pointer(this)?;
247+
let thread_callback = this.get_ptr_fn(thread_callback)?.as_instance()?;
253248

254249
// The signature of this function is `unsafe extern "system" fn(h: c::LPVOID, dwReason: c::DWORD, pv: c::LPVOID)`.
255250
let reason = this.eval_path_scalar(&["std", "sys", "windows", "c", "DLL_THREAD_DETACH"])?;

src/shims/unix/linux/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub fn futex<'tcx>(
121121
// The API requires `addr` to be a 4-byte aligned pointer, and will
122122
// use the 4 bytes at the given address as an (atomic) i32.
123123
this.check_ptr_access_align(
124-
this.scalar_to_ptr(addr_scalar)?,
124+
addr_scalar.to_pointer(this)?,
125125
Size::from_bytes(4),
126126
Align::from_bytes(4).unwrap(),
127127
CheckInAllocMsg::MemoryAccessTest,

0 commit comments

Comments
 (0)