Skip to content

Commit 5c9819e

Browse files
committed
ub_checks intrinsics: fall back to cfg(ub_checks)
1 parent edbc000 commit 5c9819e

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
@@ -202,6 +202,7 @@
202202
#![feature(cfg_sanitize)]
203203
#![feature(cfg_target_has_atomic)]
204204
#![feature(cfg_target_has_atomic_equal_alignment)]
205+
#![feature(cfg_ub_checks)]
205206
#![feature(const_fn_floating_point_arithmetic)]
206207
#![feature(const_for)]
207208
#![feature(const_mut_refs)]

0 commit comments

Comments
 (0)