-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove official ndebug variable support #563
Conversation
I'm in favour of movement along these lines; I find it weird to think that a |
It can be useful to run tests with both |
@SimonSapin I think the suggestion is to allow |
Ok, that sounds fine. |
Yes, this makes sense. |
Thinking a bit more, I think it would be useful to have the ability to narrow down the list of modules for which debug-assertions are enabled, as well. I've wanted this in C++ from time to time (and achieved it, by playing with |
In favor of the general idea. |
For context |
The |
|
||
# Detailed design | ||
|
||
The `debug_assertions` variable, the replacement for the `ndebug` variable, will be compiler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just clarifying, but by variable do you mean cfg
directive? For example, I would be able to do:
if cfg!(debug_assertions) { /* super-expensive code */ }
I have a minor concern that What other things might |
It seems like the flag could be more than just a boolean, but rather take a list of what to enable to allow fine-grained control, e.g. |
Just re-read the RFC again. I like it. I definitely like this part of it:
The only question then is how fine-grained to make the "opting back in". That is, do we want to distinguish debug-assertions from integer-overflow etc? I think we certainly want a simple way to say "put back in all the optional debugging stuff". Having more control also seems good but I'd be happy for that to come later too. |
Sorry for bikeshedding... if we want this to apply to more than just |
@huonw I don't have a strong opinion. I'm going to merge the RFC in any case, I think, and we can bikeshed independently and update the RFC/impl as we go. I think the important part is that we plan on integrating this more deeply in the compiler and that we plan on having the defaults be connected to the optimization level. |
The core team has decided to merge this RFC. There was no significant opposition, seems like a popular proposal all around. Some [minor] questions as to the precise command-line flags remain to be resolved [1, 2, 3], but the high-level idea of integrating ndebug more deeply into the compiler and tying it to the optimization flags is uncontroversial. |
Tracking issue: rust-lang/rust#22492 |
add in unresolved questions from the RFC discussion.
This commit is an implementation of [RFC 563][rfc] which adds a new `cfg(debug_assertions)` directive which is specially recognized and calculated by the compiler. The flag is turned off at any optimization level greater than 1 and may also be explicitly controlled through the `-C debug-assertions` flag. [rfc]: rust-lang/rfcs#563 The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of the `ndebug` variable and `ndebug` no longer holds any meaning to the standard library. Code which was previously relying on `not(ndebug)` to gate expensive code should be updated to rely on `debug_assertions` instead. Closes rust-lang#22492 [breaking-change]
…kfelix This commit is an implementation of [RFC 563][rfc] which adds a new `cfg(debug_assertions)` directive which is specially recognized and calculated by the compiler. The flag is turned off at any optimization level greater than 1 and may also be explicitly controlled through the `-C debug-assertions` flag. [rfc]: rust-lang/rfcs#563 The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of the `ndebug` variable and `ndebug` no longer holds any meaning to the standard library. Code which was previously relying on `not(ndebug)` to gate expensive code should be updated to rely on `debug_assertions` instead. Closes rust-lang#22492 [breaking-change]
This commit is an implementation of [RFC 563][rfc] which adds a new `cfg(debug_assertions)` directive which is specially recognized and calculated by the compiler. The flag is turned off at any optimization level greater than 1 and may also be explicitly controlled through the `-C debug-assertions` flag. [rfc]: rust-lang/rfcs#563 The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of the `ndebug` variable and `ndebug` no longer holds any meaning to the standard library. Code which was previously relying on `not(ndebug)` to gate expensive code should be updated to rely on `debug_assertions` instead. Closes rust-lang#22492 [breaking-change]
…kfelix This commit is an implementation of [RFC 563][rfc] which adds a new `cfg(debug_assertions)` directive which is specially recognized and calculated by the compiler. The flag is turned off at any optimization level greater than 1 and may also be explicitly controlled through the `-C debug-assertions` flag. [rfc]: rust-lang/rfcs#563 The `debug_assert!` and `debug_assert_eq!` macros now respect this instead of the `ndebug` variable and `ndebug` no longer holds any meaning to the standard library. Code which was previously relying on `not(ndebug)` to gate expensive code should be updated to rely on `debug_assertions` instead. Closes rust-lang#22492 [breaking-change]
Rendered View