Skip to content

Potential improvement to reversed_empty_ranges #2477

Open
@pzmarzly

Description

@pzmarzly

While it is stated that this lint cannot catch loops over dynamically defined ranges, it could be improved to catch the following common pattern:

let x = 5u32;
for i in x..0 { ... }

Note that it is a range over unsigned values, so it makes no sense for the right side to be zero (as the range will always be empty then). Similar check could be done for signed integers by iXXX::MIN const.

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