Skip to content

new lint: warn of dead code when range start is bigger than range end #4192

Closed
@matthiaskrgr

Description

@matthiaskrgr
fn main()  {
  (4..=1).for_each(|x| println!("{}", x));
}

This entire code is dead code and the content of main() is optimized away entirely without any warning.

IMO we should have a warning that suggests (1..=4).rev() instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-complexityLint: Belongs in the complexity lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions