Skip to content

Commit d3a5063

Browse files
committed
Convert all other debug_assert_nounwind
1 parent 27ef51f commit d3a5063

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

Diff for: library/core/src/panic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ pub macro unreachable_2021 {
146146
/// not compromise unwind safety.
147147
#[doc(hidden)]
148148
#[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)]
150150
#[rustc_macro_transparency = "semitransparent"]
151151
pub macro debug_assert_nounwind {
152152
($cond:expr $(,)?) => {
153-
if $crate::cfg!(debug_assertions) {
153+
if $crate::intrinsics::debug_assertions() {
154154
if !$cond {
155155
$crate::panicking::panic_nounwind($crate::concat!("assertion failed: ", $crate::stringify!($cond)));
156156
}
157157
}
158158
},
159159
($cond:expr, $($arg:tt)+) => {
160-
if $crate::cfg!(debug_assertions) {
160+
if $crate::intrinsics::debug_assertions() {
161161
if !$cond {
162162
$crate::panicking::panic_nounwind_fmt($crate::const_format_args!($($arg)+), false);
163163
}

Diff for: library/core/src/ptr/alignment.rs

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl Alignment {
7676
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]
7777
#[inline]
7878
pub const unsafe fn new_unchecked(align: usize) -> Self {
79+
#[cfg(debug_assertions)]
7980
crate::panic::debug_assert_nounwind!(
8081
align.is_power_of_two(),
8182
"Alignment::new_unchecked requires a power of two"

Diff for: library/core/src/slice/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,7 @@ impl<T> [T] {
19621962
let len = self.len();
19631963
let ptr = self.as_ptr();
19641964

1965+
#[cfg(debug_assertions)]
19651966
debug_assert_nounwind!(
19661967
mid <= len,
19671968
"slice::split_at_unchecked requires the index to be within the slice",
@@ -2012,6 +2013,7 @@ impl<T> [T] {
20122013
let len = self.len();
20132014
let ptr = self.as_mut_ptr();
20142015

2016+
#[cfg(debug_assertions)]
20152017
debug_assert_nounwind!(
20162018
mid <= len,
20172019
"slice::split_at_mut_unchecked requires the index to be within the slice",

Diff for: library/core/src/str/traits.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::cmp::Ordering;
44
use crate::ops;
5+
#[cfg(debug_assertions)]
56
use crate::panic::debug_assert_nounwind;
67
use crate::ptr;
78
use crate::slice::SliceIndex;
@@ -192,6 +193,7 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
192193
unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output {
193194
let slice = slice as *const [u8];
194195

196+
#[cfg(debug_assertions)]
195197
debug_assert_nounwind!(
196198
// We'd like to check that the bounds are on char boundaries,
197199
// but there's not really a way to do so without reading
@@ -213,6 +215,7 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
213215
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output {
214216
let slice = slice as *mut [u8];
215217

218+
#[cfg(debug_assertions)]
216219
debug_assert_nounwind!(
217220
self.end >= self.start && self.end <= slice.len(),
218221
"str::get_unchecked_mut requires that the range is within the string slice",

0 commit comments

Comments
 (0)