-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
clarify that debug_assert does not completely omits the code #62527
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
r? @aidanhs (rust_highfive has picked a reviewer for you, use r? to override) |
Centril
reviewed
Jul 9, 2019
r? @Centril r=me with changes ^--- |
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
This comment has been minimized.
This comment has been minimized.
@bors r=Centril |
📌 Commit b052fbb has been approved by |
Centril
added a commit
to Centril/rust
that referenced
this pull request
Jul 9, 2019
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.
Centril
added a commit
to Centril/rust
that referenced
this pull request
Jul 9, 2019
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.
bors
added a commit
that referenced
this pull request
Jul 9, 2019
Rollup of 9 pull requests Successful merges: - #62417 (Fix ICEs when `Self` is used in type aliases) - #62450 (Raise the default recursion limit to 128) - #62470 (Prevent shrinking of "crate select" element on Firefox) - #62515 (cli: make help output for -l and -L consistent) - #62520 (Regression test for issue 42574.) - #62526 (normalize use of backticks in compiler messages for libsyntax/feature_gate.rs) - #62527 (clarify that debug_assert does not completely omits the code) - #62535 (ci: Configure $CI_JOB_NAME correctly) - #62541 (Add spastorino for rustc-guide toolstate) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #62542) made this pull request unmergeable. Please resolve the merge conflicts. |
Merged
hawkw
added a commit
to tokio-rs/tokio
that referenced
this pull request
Oct 28, 2019
The `debug_assert!` family of macros are guarded by an `if cfg!(debug_assertions)`, _not_ a `#[cfg(debug_assertions)]` attribute. This means that the code in the assertion is still type checked in release mode, and using code that only exists in debug mode will thus fail in release mode. See rust-lang/rust#62527. Therefore, since the `shard.tid` field has a `#[cfg(debug_assertions)]` attribute on it, it's necessary to also put that attribute on the assertions that use that field. cc @kleimkuhler, since you had previously asked why putting the cfg attribute on these assertions was necessary (#1625 (comment)). I thought you might nbe interested in seeing the answer. :) Signed-off-by: Eliza Weisman <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TIL that debug_assert is implemented using
if cfg!(debug_assertions)
rather than
#[cfg(debug_assertions)]
. This means one can not use APIgated with
#[cfg(debug_assertions)]
indebug_assert
family ofmacros.