Skip to content

False negative checked_conversions for Int::MAX #5675

Closed
@tesuji

Description

@tesuji

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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions