Closed
Description
All I was able to find documenting this is an ambiguous mention in the rust reference:
https://github.com/rust-lang/rust/blob/17cae033787aca26b00a8c820c1599926a1fd94d/src/doc/reference.md#conditional-compilation
It would be nice if, for example, the documentation for std::debug_assert!
was updated to mention:
Unlike assert!, debug_assert! statements are only enabled in non optimized builds by default. An optimized build will omit all debug_assert! statements unless -C debug-assertions or -C opt-level=0 is passed to the compiler. This makes debug_assert! useful for checks that are too expensive to be present in a release build but may be helpful during development.
Activity
nagisa commentedon Feb 1, 2017
“An optimized build” seems to very clearly imply that
opt-level ≠ 0
to me.mystor commentedon Feb 1, 2017
That's true - I missed that on the first reading.
daxpedda commentedon Dec 21, 2018
Was currently trying to work with the cargo api and was struggling to find the issue until I found out about this.
In the new documentation this is mentioned nowhere:
https://doc.rust-lang.org/nightly/rustc/codegen-options/index.html#opt-level
-C opt-level=0
implies-C debug-assertions
. #57132Rollup merge of rust-lang#57132 - daxpedda:master, r=steveklabnik