|
1 |
| -use super::usefulness::Usefulness::*; |
2 | 1 | use super::usefulness::{
|
3 |
| - compute_match_usefulness, expand_pattern, MatchArm, MatchCheckCtxt, UsefulnessReport, |
| 2 | + compute_match_usefulness, expand_pattern, MatchArm, MatchCheckCtxt, Reachability, |
| 3 | + UsefulnessReport, |
4 | 4 | };
|
5 | 5 | use super::{PatCtxt, PatKind, PatternError};
|
6 | 6 |
|
@@ -398,10 +398,11 @@ fn report_arm_reachability<'p, 'tcx>(
|
398 | 398 | report: &UsefulnessReport<'p, 'tcx>,
|
399 | 399 | source: hir::MatchSource,
|
400 | 400 | ) {
|
| 401 | + use Reachability::*; |
401 | 402 | let mut catchall = None;
|
402 | 403 | for (arm_index, (arm, is_useful)) in report.arm_usefulness.iter().enumerate() {
|
403 | 404 | match is_useful {
|
404 |
| - NotUseful => { |
| 405 | + Unreachable => { |
405 | 406 | match source {
|
406 | 407 | hir::MatchSource::WhileDesugar => bug!(),
|
407 | 408 |
|
@@ -430,17 +431,16 @@ fn report_arm_reachability<'p, 'tcx>(
|
430 | 431 | hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {}
|
431 | 432 | }
|
432 | 433 | }
|
433 |
| - Useful(unreachables) if unreachables.is_empty() => {} |
| 434 | + Reachable(unreachables) if unreachables.is_empty() => {} |
434 | 435 | // The arm is reachable, but contains unreachable subpatterns (from or-patterns).
|
435 |
| - Useful(unreachables) => { |
436 |
| - let mut unreachables: Vec<_> = unreachables.iter().collect(); |
| 436 | + Reachable(unreachables) => { |
| 437 | + let mut unreachables = unreachables.clone(); |
437 | 438 | // Emit lints in the order in which they occur in the file.
|
438 | 439 | unreachables.sort_unstable();
|
439 | 440 | for span in unreachables {
|
440 | 441 | unreachable_pattern(cx.tcx, span, arm.hir_id, None);
|
441 | 442 | }
|
442 | 443 | }
|
443 |
| - UsefulWithWitness(_) => bug!(), |
444 | 444 | }
|
445 | 445 | if !arm.has_guard && catchall.is_none() && pat_is_catchall(arm.pat) {
|
446 | 446 | catchall = Some(arm.pat.span);
|
|
0 commit comments