@@ -2274,22 +2274,27 @@ extern "rust-intrinsic" {
2274
2274
#[ allow_internal_unstable( const_eval_select) ] // permit this to be called in stably-const fn
2275
2275
macro_rules! assert_unsafe_precondition {
2276
2276
( $name: expr, $( [ $( $tt: tt) * ] ) ?( $( $i: ident: $ty: ty) ,* $( , ) ?) => $e: expr) => {
2277
- if cfg! ( debug_assertions ) {
2277
+ {
2278
2278
// allow non_snake_case to allow capturing const generics
2279
2279
#[ allow( non_snake_case) ]
2280
2280
#[ inline( always) ]
2281
2281
fn runtime$( <$( $tt) * >) ?( $( $i: $ty) ,* ) {
2282
- if !$e {
2283
- // don't unwind to reduce impact on code size
2284
- :: core:: panicking:: panic_nounwind(
2285
- concat!( "unsafe precondition(s) violated: " , $name)
2286
- ) ;
2282
+ if cfg!( debug_assertions) {
2283
+ if !$e {
2284
+ // don't unwind to reduce impact on code size
2285
+ $crate:: panicking:: panic_nounwind(
2286
+ concat!( "unsafe precondition(s) violated: " , $name)
2287
+ ) ;
2288
+ }
2289
+ } else {
2290
+ // SAFETY: the caller must ensure this
2291
+ unsafe { $crate:: intrinsics:: assume( $e) } ;
2287
2292
}
2288
2293
}
2289
2294
#[ allow( non_snake_case) ]
2290
2295
const fn comptime$( <$( $tt) * >) ?( $( _: $ty) ,* ) { }
2291
2296
2292
- :: core :: intrinsics:: const_eval_select( ( $( $i, ) * ) , comptime, runtime) ;
2297
+ $crate :: intrinsics:: const_eval_select( ( $( $i, ) * ) , comptime, runtime) ;
2293
2298
}
2294
2299
} ;
2295
2300
}
0 commit comments