Skip to content
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

assertion_on_constants: False positive on debug_assert!(false, ...) #3948

Closed
dtolnay opened this issue Apr 12, 2019 · 0 comments · Fixed by #3989
Closed

assertion_on_constants: False positive on debug_assert!(false, ...) #3948

dtolnay opened this issue Apr 12, 2019 · 0 comments · Fixed by #3989
Assignees
Labels
I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 12, 2019

The following code currently triggers assertion_on_constants. I believe the specific pattern of debug_assert!(false, ...) should be ignored by this lint as there is no current better similarly concise way to express the behavior of panic-in-debug-mode-only.

fn main() {
    debug_assert!(false, "oh no");
}

Example occurrence in Chrome OS: platform/crosvm/gpu_display/src/lib.rs

Mentioning @Arkweid and @flip1995 who have worked on this lint.


clippy 0.0.212 (37f5c1e 2019-04-09)

@flip1995 flip1995 self-assigned this Apr 13, 2019
bors added a commit that referenced this issue Apr 19, 2019
Don't trigger assertions_on_constants on debug_assert!(false)

Fixes #3948
Fixes #3765

changelog: Fix `debug_assert!` false positive on `assertions_on_constants` lint
@rustbot rustbot added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants