[−][src]Static rustc_ap_rustc_lint_defs::builtin::IRREFUTABLE_LET_PATTERNS
pub static IRREFUTABLE_LET_PATTERNS: &Lint
The irrefutable_let_patterns
lint detects detects irrefutable
patterns in if-let and while-let statements.
Example
if let _ = 123 { println!("always runs!"); }
{{produces}}
Explanation
There usually isn't a reason to have an irrefutable pattern in an
if-let or while-let statement, because the pattern will always match
successfully. A let
or loop
statement will suffice. However,
when generating code with a macro, forbidding irrefutable patterns
would require awkward workarounds in situations where the macro
doesn't know if the pattern is refutable or not. This lint allows
macros to accept this form, while alerting for a possibly incorrect
use in normal code.
See RFC 2086 for more details.