Skip to content

Commit 0697dec

Browse files
committed
Merge from rust-lang/rust
2 parents 9bdaf04 + bf22cf9 commit 0697dec

13 files changed

+73
-28
lines changed

src/intrinsics/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
189189
let place = this.deref_pointer(place)?;
190190
let rhs = this.read_immediate(rhs)?;
191191

192-
if !place.layout.ty.is_integral() && !place.layout.ty.is_unsafe_ptr() {
192+
if !place.layout.ty.is_integral() && !place.layout.ty.is_raw_ptr() {
193193
span_bug!(
194194
this.cur_span(),
195195
"atomic arithmetic operations only work on integer and raw pointer types",

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![feature(rustc_private)]
33
#![feature(cell_update)]
44
#![feature(float_gamma)]
5+
#![feature(float_erf)]
56
#![feature(map_try_insert)]
67
#![feature(never_type)]
78
#![feature(try_blocks)]

src/operator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5252
// Some more operations are possible with atomics.
5353
// The return value always has the provenance of the *left* operand.
5454
Add | Sub | BitOr | BitAnd | BitXor => {
55-
assert!(left.layout.ty.is_unsafe_ptr());
56-
assert!(right.layout.ty.is_unsafe_ptr());
55+
assert!(left.layout.ty.is_raw_ptr());
56+
assert!(right.layout.ty.is_raw_ptr());
5757
let ptr = left.to_scalar().to_pointer(this)?;
5858
// We do the actual operation with usize-typed scalars.
5959
let left = ImmTy::from_uint(ptr.addr().bytes(), this.machine.layouts.usize);

src/shims/foreign_items.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
742742
| "log1pf"
743743
| "expm1f"
744744
| "tgammaf"
745+
| "erff"
746+
| "erfcf"
745747
=> {
746748
let [f] = this.check_shim(abi, Conv::C , link_name, args)?;
747749
let f = this.read_scalar(f)?.to_f32()?;
@@ -759,6 +761,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
759761
"log1pf" => f_host.ln_1p(),
760762
"expm1f" => f_host.exp_m1(),
761763
"tgammaf" => f_host.gamma(),
764+
"erff" => f_host.erf(),
765+
"erfcf" => f_host.erfc(),
762766
_ => bug!(),
763767
};
764768
let res = res.to_soft();
@@ -799,6 +803,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
799803
| "log1p"
800804
| "expm1"
801805
| "tgamma"
806+
| "erf"
807+
| "erfc"
802808
=> {
803809
let [f] = this.check_shim(abi, Conv::C , link_name, args)?;
804810
let f = this.read_scalar(f)?.to_f64()?;
@@ -816,6 +822,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
816822
"log1p" => f_host.ln_1p(),
817823
"expm1" => f_host.exp_m1(),
818824
"tgamma" => f_host.gamma(),
825+
"erf" => f_host.erf(),
826+
"erfc" => f_host.erfc(),
819827
_ => bug!(),
820828
};
821829
let res = res.to_soft();

tests/fail/panic/panic_abort1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
3-
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
3+
//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort
55

66
fn main() {

tests/fail/panic/panic_abort2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
3-
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
3+
//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort
55

66
fn main() {

tests/fail/panic/panic_abort3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
3-
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
3+
//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort
55

66
fn main() {

tests/fail/panic/panic_abort4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@error-in-other-file: the program aborted execution
22
//@normalize-stderr-test: "\| +\^+" -> "| ^"
3-
//@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();"
3+
//@normalize-stderr-test: "unsafe \{ libc::abort\(\); \}|core::intrinsics::abort\(\);" -> "ABORT();"
44
//@compile-flags: -C panic=abort
55

66
fn main() {

tests/fail/ptr_swap_nonoverlapping.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! This is a regression test for <https://github.com/rust-lang/miri/issues/4188>: The precondition
2+
//! check in `ptr::swap_nonoverlapping` was incorrectly disabled in Miri.
3+
//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();"
4+
//@normalize-stderr-test: "\| +\^+" -> "| ^"
5+
//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
6+
//@normalize-stderr-test: "\n +at [^\n]+" -> ""
7+
//@error-in-other-file: aborted execution
8+
9+
fn main() {
10+
let mut data = 0usize;
11+
let ptr = std::ptr::addr_of_mut!(data);
12+
unsafe {
13+
std::ptr::swap_nonoverlapping(ptr, ptr, 1);
14+
}
15+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
3+
unsafe precondition(s) violated: ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap
4+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
5+
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
6+
thread caused non-unwinding panic. aborting.
7+
error: abnormal termination: the program aborted execution
8+
--> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
9+
|
10+
LL | ABORT();
11+
| ^ the program aborted execution
12+
|
13+
= note: BACKTRACE:
14+
= note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
15+
= note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
16+
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
17+
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
18+
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
19+
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
20+
= note: inside `std::ptr::swap_nonoverlapping::precondition_check` at RUSTLIB/core/src/ub_checks.rs:LL:CC
21+
= note: inside `std::ptr::swap_nonoverlapping::<usize>` at RUSTLIB/core/src/ub_checks.rs:LL:CC
22+
note: inside `main`
23+
--> tests/fail/ptr_swap_nonoverlapping.rs:LL:CC
24+
|
25+
LL | std::ptr::swap_nonoverlapping(ptr, ptr, 1);
26+
| ^
27+
28+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
29+
30+
error: aborting due to 1 previous error
31+

0 commit comments

Comments
 (0)