Skip to content

Commit 8d0243a

Browse files
authored
Rollup merge of rust-lang#62527 - matklad:debug-assert, r=Centril
clarify that debug_assert does not completely omits the code TIL that debug_assert is implemented using `if cfg!(debug_assertions)` rather than `#[cfg(debug_assertions)]`. This means one can not use API gated with `#[cfg(debug_assertions)]` in `debug_assert` family of macros.
2 parents c57a223 + b052fbb commit 8d0243a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libcore/macros.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ macro_rules! assert_ne {
145145
/// # Uses
146146
///
147147
/// Unlike [`assert!`], `debug_assert!` statements are only enabled in non
148-
/// optimized builds by default. An optimized build will omit all
148+
/// optimized builds by default. An optimized build will not execute
149149
/// `debug_assert!` statements unless `-C debug-assertions` is passed to the
150150
/// compiler. This makes `debug_assert!` useful for checks that are too
151151
/// expensive to be present in a release build but may be helpful during
152-
/// development.
152+
/// development. The result of expanding `debug_assert!` is always type checked.
153153
///
154154
/// An unchecked assertion allows a program in an inconsistent state to keep
155155
/// running, which might have unexpected consequences but does not introduce
@@ -190,11 +190,11 @@ macro_rules! debug_assert {
190190
/// debug representations.
191191
///
192192
/// Unlike [`assert_eq!`], `debug_assert_eq!` statements are only enabled in non
193-
/// optimized builds by default. An optimized build will omit all
193+
/// optimized builds by default. An optimized build will not execute
194194
/// `debug_assert_eq!` statements unless `-C debug-assertions` is passed to the
195195
/// compiler. This makes `debug_assert_eq!` useful for checks that are too
196196
/// expensive to be present in a release build but may be helpful during
197-
/// development.
197+
/// development. The result of expanding `debug_assert_eq!` is always type checked.
198198
///
199199
/// [`assert_eq!`]: ../std/macro.assert_eq.html
200200
///
@@ -217,11 +217,11 @@ macro_rules! debug_assert_eq {
217217
/// debug representations.
218218
///
219219
/// Unlike [`assert_ne!`], `debug_assert_ne!` statements are only enabled in non
220-
/// optimized builds by default. An optimized build will omit all
220+
/// optimized builds by default. An optimized build will not execute
221221
/// `debug_assert_ne!` statements unless `-C debug-assertions` is passed to the
222222
/// compiler. This makes `debug_assert_ne!` useful for checks that are too
223223
/// expensive to be present in a release build but may be helpful during
224-
/// development.
224+
/// development. The result of expanding `debug_assert_ne!` is always type checked.
225225
///
226226
/// [`assert_ne!`]: ../std/macro.assert_ne.html
227227
///

0 commit comments

Comments
 (0)