diff options
| author | Ralf Jung <post@ralfj.de> | 2024-08-25 12:54:04 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-25 13:15:48 +0200 |
| commit | a772db420670b2d2c391311f184bc4b56baba59d (patch) | |
| tree | 2fd1332fbe87fff29bb1d874d2a831a6e660dbe7 | |
| parent | 717aec0f8eebdc5eb51756e5129dde15e8b25710 (diff) | |
| download | rust-a772db420670b2d2c391311f184bc4b56baba59d.tar.gz rust-a772db420670b2d2c391311f184bc4b56baba59d.zip | |
ub_checks intrinsics: fall back to cfg(ub_checks)
| -rw-r--r-- | library/core/src/intrinsics.rs | 4 | ||||
| -rw-r--r-- | library/core/src/lib.rs | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index bd99e90376a..8cb9accd59d 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2949,7 +2949,7 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) { /// sysroot which is built without ub_checks but with `#[rustc_preserve_ub_checks]`. /// For code that gets monomorphized in the user crate (i.e., generic functions and functions with /// `#[inline]`), gating assertions on `ub_checks()` rather than `cfg!(ub_checks)` means that -/// assertions are enabled whenever the *user crate* has UB checks enabled. However if the +/// assertions are enabled whenever the *user crate* has UB checks enabled. However, if the /// user has UB checks disabled, the checks will still get optimized out. This intrinsic is /// primarily used by [`ub_checks::assert_unsafe_precondition`]. #[rustc_const_unstable(feature = "const_ub_checks", issue = "none")] @@ -2957,7 +2957,7 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) { #[inline(always)] #[rustc_intrinsic] pub const fn ub_checks() -> bool { - cfg!(debug_assertions) + cfg!(ub_checks) } /// Allocates a block of memory at compile time. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 7f0efede240..06a745b690a 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -203,6 +203,7 @@ #![feature(cfg_sanitize)] #![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic_equal_alignment)] +#![feature(cfg_ub_checks)] #![feature(const_for)] #![feature(const_mut_refs)] #![feature(const_precise_live_drops)] |
