about summary refs log tree commit diff
path: root/src/tools
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-02-12 20:26:35 +0000
committerbors <bors@rust-lang.org>2025-02-12 20:26:35 +0000
commitef148cd7eb00a5a973130dc6473da71fd6c487ee (patch)
treed355ad9542f2c7b39e7ab32b08b8b670869ebbcd /src/tools
parentced8e650cddbafad92094b2c89dee97b8a807d9c (diff)
parent8567fbb4b5b5153a7789d7eb76a8a46700183a1c (diff)
downloadrust-ef148cd7eb00a5a973130dc6473da71fd6c487ee.tar.gz
rust-ef148cd7eb00a5a973130dc6473da71fd6c487ee.zip
Auto merge of #136943 - GuillaumeGomez:rollup-amtd3mq, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #136758 (tests: `-Copt-level=3` instead of `-O` in assembly tests)
 - #136761 (tests: `-Copt-level=3` instead of `-O` in codegen tests)
 - #136784 (Nuke `Buffer` abstraction from `librustdoc`, take 2 💣)
 - #136838 (Check whole `Unsize` predicate for escaping bound vars)
 - #136848 (add docs and ut for bootstrap util cache)
 - #136871 (dev-guide: Link to `t-lang` procedures for new features)
 - #136890 (Change swap_nonoverlapping from lang to library UB)
 - #136901 (compiler: give `ExternAbi` truly stable `Hash` and `Ord`)
 - #136907 (compiler: Make middle errors `pub(crate)` and bury the dead code)
 - #136916 (use cc archiver as default in `cc2ar`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/miri/tests/fail/ptr_swap_nonoverlapping.rs15
-rw-r--r--src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr31
2 files changed, 46 insertions, 0 deletions
diff --git a/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.rs b/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.rs
new file mode 100644
index 00000000000..6f627c416b0
--- /dev/null
+++ b/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.rs
@@ -0,0 +1,15 @@
+//! This is a regression test for <https://github.com/rust-lang/miri/issues/4188>: The precondition
+//! check in `ptr::swap_nonoverlapping` was incorrectly disabled in Miri.
+//@normalize-stderr-test: "unsafe \{ libc::abort\(\) \}|crate::intrinsics::abort\(\);" -> "ABORT();"
+//@normalize-stderr-test: "\| +\^+" -> "| ^"
+//@normalize-stderr-test: "\n +[0-9]+:[^\n]+" -> ""
+//@normalize-stderr-test: "\n +at [^\n]+" -> ""
+//@error-in-other-file: aborted execution
+
+fn main() {
+    let mut data = 0usize;
+    let ptr = std::ptr::addr_of_mut!(data);
+    unsafe {
+        std::ptr::swap_nonoverlapping(ptr, ptr, 1);
+    }
+}
diff --git a/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr b/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr
new file mode 100644
index 00000000000..782303d5f3f
--- /dev/null
+++ b/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr
@@ -0,0 +1,31 @@
+
+thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
+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
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
+note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
+thread caused non-unwinding panic. aborting.
+error: abnormal termination: the program aborted execution
+  --> RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
+   |
+LL |     ABORT();
+   | ^ the program aborted execution
+   |
+   = note: BACKTRACE:
+   = note: inside `std::sys::pal::PLATFORM::abort_internal` at RUSTLIB/std/src/sys/pal/PLATFORM/mod.rs:LL:CC
+   = note: inside `std::panicking::rust_panic_with_hook` at RUSTLIB/std/src/panicking.rs:LL:CC
+   = note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
+   = 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
+   = note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
+   = note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
+   = note: inside `std::ptr::swap_nonoverlapping::precondition_check` at RUSTLIB/core/src/ub_checks.rs:LL:CC
+   = note: inside `std::ptr::swap_nonoverlapping::<usize>` at RUSTLIB/core/src/ub_checks.rs:LL:CC
+note: inside `main`
+  --> tests/fail/ptr_swap_nonoverlapping.rs:LL:CC
+   |
+LL |         std::ptr::swap_nonoverlapping(ptr, ptr, 1);
+   | ^
+
+note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
+
+error: aborting due to 1 previous error
+