@@ -2575,6 +2575,7 @@ pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
2575
2575
/// assertions disabled. This intrinsic is primarily used by [`assert_unsafe_precondition`].
2576
2576
#[ rustc_const_unstable( feature = "delayed_debug_assertions" , issue = "none" ) ]
2577
2577
#[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
2578
+ #[ inline( always) ]
2578
2579
#[ cfg_attr( not( bootstrap) , rustc_intrinsic) ]
2579
2580
pub ( crate ) const fn debug_assertions ( ) -> bool {
2580
2581
cfg ! ( debug_assertions)
@@ -2659,7 +2660,13 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize)
2659
2660
macro_rules! assert_unsafe_precondition {
2660
2661
( $message: expr, ( $( $name: ident: $ty: ty = $arg: expr) ,* $( , ) ?) => $e: expr $( , ) ?) => {
2661
2662
{
2662
- #[ inline( never) ]
2663
+ // When the standard library is compiled with debug assertions, we want the check to inline for better performance.
2664
+ // This is important when working on the compiler, which is compiled with debug assertions locally.
2665
+ // When not compiled with debug assertions (so the precompiled std) we outline the check to minimize the compile
2666
+ // time impact when debug assertions are disabled.
2667
+ // It is not clear whether that is the best solution, see #120848.
2668
+ #[ cfg_attr( debug_assertions, inline( always) ) ]
2669
+ #[ cfg_attr( not( debug_assertions) , inline( never) ) ]
2663
2670
#[ rustc_nounwind]
2664
2671
fn precondition_check( $( $name: $ty) ,* ) {
2665
2672
if !$e {
0 commit comments