Skip to content

False positive in cast_sign_loss #2728

Closed
@dtolnay

Description

@dtolnay

I have some code like this in serde_yaml:

error: casting i64 to u64 may lose the sign of the value
   --> src/number.rs:172:37
    |
172 |                             if n <= i64::max_value() as u64 {
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^

It would be nice to suppress cast_sign_loss in cases where Clippy can determine that the value is nonnegative, for example i64::MAX and i64::max_value().

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions