pattern_analysis
doesn't need to know what spans are
This commit is contained in:
parent
8c5e89907c
commit
1e89a38423
6 changed files with 39 additions and 36 deletions
|
@ -856,21 +856,21 @@ fn report_arm_reachability<'p, 'tcx>(
|
|||
for (arm, is_useful) in report.arm_usefulness.iter() {
|
||||
match is_useful {
|
||||
Usefulness::Redundant => {
|
||||
report_unreachable_pattern(*arm.pat.span(), arm.arm_data, catchall)
|
||||
report_unreachable_pattern(*arm.pat.data(), arm.arm_data, catchall)
|
||||
}
|
||||
Usefulness::Useful(redundant_spans) if redundant_spans.is_empty() => {}
|
||||
Usefulness::Useful(redundant_subpats) if redundant_subpats.is_empty() => {}
|
||||
// The arm is reachable, but contains redundant subpatterns (from or-patterns).
|
||||
Usefulness::Useful(redundant_spans) => {
|
||||
let mut redundant_spans = redundant_spans.clone();
|
||||
Usefulness::Useful(redundant_subpats) => {
|
||||
let mut redundant_subpats = redundant_subpats.clone();
|
||||
// Emit lints in the order in which they occur in the file.
|
||||
redundant_spans.sort_unstable();
|
||||
for span in redundant_spans {
|
||||
report_unreachable_pattern(span, arm.arm_data, None);
|
||||
redundant_subpats.sort_unstable_by_key(|pat| pat.data());
|
||||
for pat in redundant_subpats {
|
||||
report_unreachable_pattern(*pat.data(), arm.arm_data, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
if !arm.has_guard && catchall.is_none() && pat_is_catchall(arm.pat) {
|
||||
catchall = Some(*arm.pat.span());
|
||||
catchall = Some(*arm.pat.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue