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

False negative checked_conversions for Int::MAX #5675

Closed
tesuji opened this issue Jun 2, 2020 · 0 comments · Fixed by #5677
Closed

False negative checked_conversions for Int::MAX #5675

tesuji opened this issue Jun 2, 2020 · 0 comments · Fixed by #5677
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@tesuji
Copy link
Contributor

tesuji commented Jun 2, 2020

Example (playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f64cf36f94d0d7480c40454b89ffc06e)

#![warn(clippy::checked_conversions)]

pub fn foo(value: i64) -> Option<u32> {
    let _ = value <= (u32::max_value() as i64) && value >= 0;
    //^WARN: Checked cast can be simplified.
    let _ = value <= (u32::MAX as i64) && value >= 0; // This should also be warned but it doesn't
    Some(42)
}
@tesuji tesuji changed the title Missing checked_conversions lint for Int::MAX False negative checked_conversions for Int::MAX Jun 2, 2020
@phansch phansch added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jun 2, 2020
@bors bors closed this as completed in e2fdeec Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants