Skip to content

Commit d911058

Browse files
authored
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 b7b8146 + 6b9b271 commit d911058

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)