Skip to content

Commit 20fc20e

Browse files
Urgaugitbot
authored and
gitbot
committed
Rollup merge of rust-lang#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.
2 parents bd34cdb + b513281 commit 20fc20e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/ub_checks.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ macro_rules! assert_unsafe_precondition {
6565
#[rustc_nounwind]
6666
const fn precondition_check($($name:$ty),*) {
6767
if !$e {
68-
::core::panicking::panic_nounwind(
69-
concat!("unsafe precondition(s) violated: ", $message)
70-
);
68+
::core::panicking::panic_nounwind(concat!("unsafe precondition(s) violated: ", $message,
69+
"\n\nThis indicates a bug in the program. \
70+
This Undefined Behavior check is optional, and cannot be relied on for safety."));
7171
}
7272
}
7373

0 commit comments

Comments
 (0)