Skip to content

Commit

Permalink
Unrolled build for rust-lang#129551
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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`
  • Loading branch information
rust-timer authored Aug 28, 2024
2 parents ac77e88 + a772db4 commit 69a3dc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2949,15 +2949,15 @@ 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")]
#[unstable(feature = "core_intrinsics", issue = "none")]
#[inline(always)]
#[rustc_intrinsic]
pub const fn ub_checks() -> bool {
cfg!(debug_assertions)
cfg!(ub_checks)
}

/// Allocates a block of memory at compile time.
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 69a3dc3

Please sign in to comment.