Skip to content

Unsigned negation in for inferred expressions doesn't warn #24676

Closed
@Aatch

Description

@Aatch

While this warns about unsigned negation:

let x : u8 = -1;

This does not:

let x = -1;
let y : u8 = x;

This especially egregious in places like range expressions where it can cause a loop to not run at all when the lower bound is negative (and therefore becomes a large unsigned integer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions