File tree 4 files changed +9
-3
lines changed
4 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -146,18 +146,18 @@ pub macro unreachable_2021 {
146
146
/// not compromise unwind safety.
147
147
#[ doc( hidden) ]
148
148
#[ unstable( feature = "panic_internals" , issue = "none" ) ]
149
- #[ allow_internal_unstable( panic_internals, const_format_args) ]
149
+ #[ allow_internal_unstable( panic_internals, const_format_args, delayed_debug_assertions ) ]
150
150
#[ rustc_macro_transparency = "semitransparent" ]
151
151
pub macro debug_assert_nounwind {
152
152
( $cond: expr $( , ) ?) => {
153
- if $crate:: cfg! ( debug_assertions) {
153
+ if $crate:: intrinsics :: debug_assertions ( ) {
154
154
if !$cond {
155
155
$crate:: panicking:: panic_nounwind ( $crate:: concat!( "assertion failed: " , $crate :: stringify!( $cond) ) ) ;
156
156
}
157
157
}
158
158
} ,
159
159
( $cond: expr, $( $arg: tt) +) => {
160
- if $crate:: cfg! ( debug_assertions) {
160
+ if $crate:: intrinsics :: debug_assertions ( ) {
161
161
if !$cond {
162
162
$crate:: panicking:: panic_nounwind_fmt ( $crate:: const_format_args!( $( $arg) +) , false ) ;
163
163
}
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ impl Alignment {
76
76
#[ rustc_const_unstable( feature = "ptr_alignment_type" , issue = "102070" ) ]
77
77
#[ inline]
78
78
pub const unsafe fn new_unchecked ( align : usize ) -> Self {
79
+ #[ cfg( debug_assertions) ]
79
80
crate :: panic:: debug_assert_nounwind!(
80
81
align. is_power_of_two( ) ,
81
82
"Alignment::new_unchecked requires a power of two"
Original file line number Diff line number Diff line change @@ -1962,6 +1962,7 @@ impl<T> [T] {
1962
1962
let len = self . len ( ) ;
1963
1963
let ptr = self . as_ptr ( ) ;
1964
1964
1965
+ #[ cfg( debug_assertions) ]
1965
1966
debug_assert_nounwind ! (
1966
1967
mid <= len,
1967
1968
"slice::split_at_unchecked requires the index to be within the slice" ,
@@ -2012,6 +2013,7 @@ impl<T> [T] {
2012
2013
let len = self . len ( ) ;
2013
2014
let ptr = self . as_mut_ptr ( ) ;
2014
2015
2016
+ #[ cfg( debug_assertions) ]
2015
2017
debug_assert_nounwind ! (
2016
2018
mid <= len,
2017
2019
"slice::split_at_mut_unchecked requires the index to be within the slice" ,
Original file line number Diff line number Diff line change 2
2
3
3
use crate :: cmp:: Ordering ;
4
4
use crate :: ops;
5
+ #[ cfg( debug_assertions) ]
5
6
use crate :: panic:: debug_assert_nounwind;
6
7
use crate :: ptr;
7
8
use crate :: slice:: SliceIndex ;
@@ -192,6 +193,7 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
192
193
unsafe fn get_unchecked ( self , slice : * const str ) -> * const Self :: Output {
193
194
let slice = slice as * const [ u8 ] ;
194
195
196
+ #[ cfg( debug_assertions) ]
195
197
debug_assert_nounwind ! (
196
198
// We'd like to check that the bounds are on char boundaries,
197
199
// but there's not really a way to do so without reading
@@ -213,6 +215,7 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
213
215
unsafe fn get_unchecked_mut ( self , slice : * mut str ) -> * mut Self :: Output {
214
216
let slice = slice as * mut [ u8 ] ;
215
217
218
+ #[ cfg( debug_assertions) ]
216
219
debug_assert_nounwind ! (
217
220
self . end >= self . start && self . end <= slice. len( ) ,
218
221
"str::get_unchecked_mut requires that the range is within the string slice" ,
You can’t perform that action at this time.
0 commit comments