-
Notifications
You must be signed in to change notification settings - Fork 1.7k
assertion_on_constants
lint: false positive?
#3765
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
Comments
This is probably fixed by #3740, however that's not included in a nightly yet. It might be good to add this test case to the UI tests: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui/assertions_on_constants.rs |
Confirmed: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eba556d590a3e9f3c718e6061130e0f5 |
@mcarton: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=213800165b6b1581281c97c4d040110e still triggers a warning when I run Clippy against this kind of code locally too, and I just just updated to the latest nightly and Clippy component. You've closed the issue, were you aware of @phansch's observation? Can you please explain how the issue can be solved downstream for the programmer using Clippy? |
This lint still triggers in the clippy version that comes with rustup in nightly-2019-04-12-x86_64-unknown-linux-gnu
|
cc #3948 This lint should not be triggered at all for |
The following code:
Triggers
assertion_on_constants
for me. https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants explains that this assertion would be optimized out by the compiler. That shouldn't be so. A statically false assertion should become a panic, not be optimized away. Since this assertion is only triggered in debug builds, using a plainunreachable!
orpanic!
isn't an equivalent alternative. So as long asdebug_unreachable!
isn't part of the standard library, this lint should not fire in cases like the above. Furthermore, the lint explanation should be corrected to say that (only) statically true assertions may be optimized out.The text was updated successfully, but these errors were encountered: