Keep reference to the original Pat
in DeconstructedPat
This commit is contained in:
parent
deace71034
commit
fc0be3c921
3 changed files with 9 additions and 9 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.data().unwrap(), arm.arm_data, catchall)
|
||||
report_unreachable_pattern(arm.pat.data().unwrap().span, arm.arm_data, catchall)
|
||||
}
|
||||
Usefulness::Useful(redundant_subpats) if redundant_subpats.is_empty() => {}
|
||||
// The arm is reachable, but contains redundant subpatterns (from or-patterns).
|
||||
Usefulness::Useful(redundant_subpats) => {
|
||||
let mut redundant_subpats = redundant_subpats.clone();
|
||||
// Emit lints in the order in which they occur in the file.
|
||||
redundant_subpats.sort_unstable_by_key(|pat| pat.data());
|
||||
redundant_subpats.sort_unstable_by_key(|pat| pat.data().unwrap().span);
|
||||
for pat in redundant_subpats {
|
||||
report_unreachable_pattern(*pat.data().unwrap(), arm.arm_data, None);
|
||||
report_unreachable_pattern(pat.data().unwrap().span, arm.arm_data, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
if !arm.has_guard && catchall.is_none() && pat_is_catchall(arm.pat) {
|
||||
catchall = Some(*arm.pat.data().unwrap());
|
||||
catchall = Some(arm.pat.data().unwrap().span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue