Skip to content

Commit ef862a7

Browse files
committed
Auto merge of #121662 - saethlin:precondition-unification, r=RalfJung
Distinguish between library and lang UB in assert_unsafe_precondition As described in rust-lang/rust#121583 (comment), `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do). `debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation. Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR. r? RalfJung
2 parents 5ec45d3 + 127c232 commit ef862a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ fn codegen_stmt<'tcx>(
779779
NullOp::OffsetOf(fields) => {
780780
layout.offset_of_subfield(fx, fields.iter()).bytes()
781781
}
782-
NullOp::DebugAssertions => {
782+
NullOp::UbCheck(_) => {
783783
let val = fx.tcx.sess.opts.debug_assertions;
784784
let val = CValue::by_val(
785785
fx.bcx.ins().iconst(types::I8, i64::try_from(val).unwrap()),

0 commit comments

Comments
 (0)