Skip to content

Consider emitting a warning if a negative constant with no suffix is silently converted to unsigned #11273

Closed
@octurion

Description

@octurion

In the following function, -1 is silently converted to std::u32::max_value, which makes it hard to figure out why the expression -1 < x is false without looking up the type of x.

fn main() {
    let x = 42u32;
    println!("{}", -1 < x)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions