Rollup merge of #136750 - kornelski:ub-bug, r=saethlin
Make ub_check message clear that it's not an assert I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation. This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
This commit is contained in:
commit
d7fe4c0e92
2 changed files with 5 additions and 3 deletions
|
@ -65,9 +65,9 @@ macro_rules! assert_unsafe_precondition {
|
|||
#[rustc_nounwind]
|
||||
const fn precondition_check($($name:$ty),*) {
|
||||
if !$e {
|
||||
::core::panicking::panic_nounwind(
|
||||
concat!("unsafe precondition(s) violated: ", $message)
|
||||
);
|
||||
::core::panicking::panic_nounwind(concat!("unsafe precondition(s) violated: ", $message,
|
||||
"\n\nThis indicates a bug in the program. \
|
||||
This Undefined Behavior check is optional, and cannot be relied on for safety."));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
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
|
||||
|
||||
This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue