Skip to content

Warning for explicit norange ( uInt..0 ) #115738

Open
@NimonSour

Description

@NimonSour

The issue I'd like to address was discussed and closed ten years ago in #9555.
I wonder how many people have come across it.

I see the point, I understand the benefits of having this particular behaviour!

However, the fact that there isn't any algorithm still, stating that Rust's range is different from ranges in other languages makes me raise this matter again.

My proposition is to include a warning, for expicit norage ( uInt..0 ) so a for i in uInt..0 {} may triger:

Warning: Unused block of code
or
Note: Rust range (start..end) if and only start < end
or
Help: If you meant to iter over revers range use (0..uInt).rev()

anything but silence really!

It looks like something unimportant but silencing an explicit dead block of code it is not what's expected from an environment
which casually warns about unused variables, this is not why we love Rust so much:
Screenshot 2023-09-10 at 20 56 16

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-clippyArea: ClippyA-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