Skip to content

Commit 23aa174

Browse files
authored
Rollup merge of rust-lang#123411 - saethlin:ub-checks, r=Urgau,RalfJung
Put checks that detect UB under their own flag below debug_assertions Implementation of rust-lang/compiler-team#725
2 parents c8b6cd2 + f724f67 commit 23aa174

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/src/intrinsics.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,17 +2704,17 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) {
27042704
}
27052705

27062706
/// Returns whether we should perform some UB-checking at runtime. This eventually evaluates to
2707-
/// `cfg!(debug_assertions)`, but behaves different from `cfg!` when mixing crates built with different
2708-
/// flags: if the crate has debug assertions enabled or carries the `#[rustc_preserve_ub_checks]`
2707+
/// `cfg!(ub_checks)`, but behaves different from `cfg!` when mixing crates built with different
2708+
/// flags: if the crate has UB checks enabled or carries the `#[rustc_preserve_ub_checks]`
27092709
/// attribute, evaluation is delayed until monomorphization (or until the call gets inlined into
27102710
/// a crate that does not delay evaluation further); otherwise it can happen any time.
27112711
///
2712-
/// The common case here is a user program built with debug_assertions linked against the distributed
2713-
/// sysroot which is built without debug_assertions but with `#[rustc_preserve_ub_checks]`.
2712+
/// The common case here is a user program built with ub_checks linked against the distributed
2713+
/// sysroot which is built without ub_checks but with `#[rustc_preserve_ub_checks]`.
27142714
/// For code that gets monomorphized in the user crate (i.e., generic functions and functions with
2715-
/// `#[inline]`), gating assertions on `ub_checks()` rather than `cfg!(debug_assertions)` means that
2716-
/// assertions are enabled whenever the *user crate* has debug assertions enabled. However if the
2717-
/// user has debug assertions disabled, the checks will still get optimized out. This intrinsic is
2715+
/// `#[inline]`), gating assertions on `ub_checks()` rather than `cfg!(ub_checks)` means that
2716+
/// assertions are enabled whenever the *user crate* has UB checks enabled. However if the
2717+
/// user has UB checks disabled, the checks will still get optimized out. This intrinsic is
27182718
/// primarily used by [`ub_checks::assert_unsafe_precondition`].
27192719
#[rustc_const_unstable(feature = "const_ub_checks", issue = "none")]
27202720
#[unstable(feature = "core_intrinsics", issue = "none")]

0 commit comments

Comments
 (0)