Skip to content

more descriptive warning for irrefutable while-let pattern #79716

Closed
@ash2x3zb9cy

Description

@ash2x3zb9cy

Writing a while-let loop for e. g. an event loop triggers a compiler warning:

warning: irrefutable while-let pattern
  --> src/main.rs:34:5
   |
34 | /     while let e = crossterm::event::read()? {
35 | |         // code
36 | |     }
   | |_____^
   |
   = note: `#[warn(irrefutable_let_patterns)]` on by default

There's no error code, and no further information, so it isn't the easiest to investigate as a user.

In my case, I believe it's warning about potentially running an unintentionally infinite/indefinite loop, which in my case is intentional. So my guess would be that I am OK to #[allow] it - at a guess.

I would suggest that additional notes be added to this warning detailing why it's a potential problem

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-enhancementCategory: An issue proposing an enhancement or a PR with one.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions