Skip to content

Commit 0156208

Browse files
authored
Rollup merge of #129551 - RalfJung:ub-checks-fallback, r=saethlin
ub_checks intrinsics: fall back to cfg(ub_checks) Not sure why the fallback body uses `debug_assertions`, probably a leftover from when `cfg!(ub_checks)` did not exist yet? r? `@saethlin`
2 parents 56ca2e2 + a772db4 commit 0156208

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

library/core/src/intrinsics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2949,15 +2949,15 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) {
29492949
/// sysroot which is built without ub_checks but with `#[rustc_preserve_ub_checks]`.
29502950
/// For code that gets monomorphized in the user crate (i.e., generic functions and functions with
29512951
/// `#[inline]`), gating assertions on `ub_checks()` rather than `cfg!(ub_checks)` means that
2952-
/// assertions are enabled whenever the *user crate* has UB checks enabled. However if the
2952+
/// assertions are enabled whenever the *user crate* has UB checks enabled. However, if the
29532953
/// user has UB checks disabled, the checks will still get optimized out. This intrinsic is
29542954
/// primarily used by [`ub_checks::assert_unsafe_precondition`].
29552955
#[rustc_const_unstable(feature = "const_ub_checks", issue = "none")]
29562956
#[unstable(feature = "core_intrinsics", issue = "none")]
29572957
#[inline(always)]
29582958
#[rustc_intrinsic]
29592959
pub const fn ub_checks() -> bool {
2960-
cfg!(debug_assertions)
2960+
cfg!(ub_checks)
29612961
}
29622962

29632963
/// Allocates a block of memory at compile time.

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@
203203
#![feature(cfg_sanitize)]
204204
#![feature(cfg_target_has_atomic)]
205205
#![feature(cfg_target_has_atomic_equal_alignment)]
206+
#![feature(cfg_ub_checks)]
206207
#![feature(const_for)]
207208
#![feature(const_mut_refs)]
208209
#![feature(const_precise_live_drops)]

0 commit comments

Comments
 (0)