hir::MatchSource::IfDesugar { .. } | hir::MatchSource::WhileDesugar => {
bug!()
}
- hir::MatchSource::IfLetDesugar { .. } => {
- cx.tcx.lint_hir(
- lint::builtin::IRREFUTABLE_LET_PATTERNS,
- hir_pat.hir_id,
- pat.span,
- "irrefutable if-let pattern",
- );
- }
- hir::MatchSource::WhileLetDesugar => {
+ hir::MatchSource::IfLetDesugar { .. }
+ | hir::MatchSource::WhileLetDesugar => {
// check which arm we're on.
match arm_index {
// The arm with the user-specified pattern.
}
// The arm with the wildcard pattern.
1 => {
+ let msg = match source {
+ hir::MatchSource::IfLetDesugar { .. } => {
+ "irrefutable if-let pattern"
+ }
+ hir::MatchSource::WhileLetDesugar => {
+ "irrefutable while-let pattern"
+ }
+ _ => bug!(),
+ };
cx.tcx.lint_hir(
lint::builtin::IRREFUTABLE_LET_PATTERNS,
hir_pat.hir_id,
pat.span,
- "irrefutable while-let pattern",
+ msg,
);
}
_ => bug!(),
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
-warning: irrefutable if-let pattern
+error: unreachable pattern
--> $DIR/top-level-alternation.rs:5:20
|
LL | if let 0..=2 | 1 = 0 {}
| ^
- |
- = note: `#[warn(irrefutable_let_patterns)]` on by default
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:10:15
+ --> $DIR/top-level-alternation.rs:9:15
|
LL | | 0 => {}
| ^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:15:15
+ --> $DIR/top-level-alternation.rs:14:15
|
LL | | Some(0) => {}
| ^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:20:9
+ --> $DIR/top-level-alternation.rs:19:9
|
LL | (0, 0) => {}
| ^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:40:9
+ --> $DIR/top-level-alternation.rs:39:9
|
LL | _ => {}
| ^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:44:9
+ --> $DIR/top-level-alternation.rs:43:9
|
LL | Some(_) => {}
| ^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:45:9
+ --> $DIR/top-level-alternation.rs:44:9
|
LL | None => {}
| ^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:50:9
+ --> $DIR/top-level-alternation.rs:49:9
|
LL | None
| ^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:51:15
+ --> $DIR/top-level-alternation.rs:50:15
|
LL | | Some(_) => {}
| ^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:55:9
+ --> $DIR/top-level-alternation.rs:54:9
|
LL | 1..=2 => {},
| ^^^^^
-error: aborting due to 10 previous errors
+error: aborting due to 11 previous errors