File tree Expand file tree Collapse file tree 4 files changed +11
-6
lines changed
Expand file tree Collapse file tree 4 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 176176// Language features:
177177// tidy-alphabetical-start
178178#![ cfg_attr( bootstrap, feature( associated_type_bounds) ) ]
179+ #![ cfg_attr( not( bootstrap) , rustc_preserve_ub_checks) ]
179180#![ cfg_attr( not( test) , feature( coroutine_trait) ) ]
180181#![ cfg_attr( test, feature( panic_update_hook) ) ]
181182#![ cfg_attr( test, feature( test) ) ]
Original file line number Diff line number Diff line change @@ -2686,12 +2686,14 @@ pub const unsafe fn typed_swap<T>(x: *mut T, y: *mut T) {
26862686 unsafe { ptr:: swap_nonoverlapping ( x, y, 1 ) } ;
26872687}
26882688
2689- /// Returns whether we should perform some UB-checking at runtime. This evaluate to the value of
2690- /// `cfg!(debug_assertions)` during monomorphization.
2691- ///
2692- /// This intrinsic is evaluated after monomorphization, which is relevant when mixing crates
2693- /// compiled with and without debug_assertions. The common case here is a user program built with
2694- /// debug_assertions linked against the distributed sysroot which is built without debug_assertions.
2689+ /// Returns whether we should perform some UB-checking at runtime. This eventually evaluates to
2690+ /// `cfg!(debug_assertions)`, but behaves different from `cfg!` when mixing crates built with different
2691+ /// flags: if the crate has debug assertions enabled or carries the `#[rustc_preserve_ub_checks]`
2692+ /// attribute, evaluation is delayed until monomorphization (or until the call gets inlined into
2693+ /// a crate that does not delay evaluation further); otherwise it can happen any time.
2694+ ///
2695+ /// The common case here is a user program built with debug_assertions linked against the distributed
2696+ /// sysroot which is built without debug_assertions but with `#[rustc_preserve_ub_checks]`.
26952697/// For code that gets monomorphized in the user crate (i.e., generic functions and functions with
26962698/// `#[inline]`), gating assertions on `ub_checks()` rather than `cfg!(debug_assertions)` means that
26972699/// assertions are enabled whenever the *user crate* has debug assertions enabled. However if the
Original file line number Diff line number Diff line change 9494) ) ]
9595#![ no_core]
9696#![ rustc_coherence_is_core]
97+ #![ cfg_attr( not( bootstrap) , rustc_preserve_ub_checks) ]
9798//
9899// Lints:
99100#![ deny( rust_2021_incompatible_or_patterns) ]
Original file line number Diff line number Diff line change 221221//
222222#![ cfg_attr( not( feature = "restricted-std" ) , stable( feature = "rust1" , since = "1.0.0" ) ) ]
223223#![ cfg_attr( feature = "restricted-std" , unstable( feature = "restricted_std" , issue = "none" ) ) ]
224+ #![ cfg_attr( not( bootstrap) , rustc_preserve_ub_checks) ]
224225#![ doc(
225226 html_playground_url = "https://play.rust-lang.org/" ,
226227 issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/" ,
You can’t perform that action at this time.
0 commit comments