Refactor if block to use idiomatic matches
This commit is contained in:
parent
014e61094a
commit
37f2382435
1 changed files with 9 additions and 13 deletions
|
@ -395,22 +395,18 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
|
|||
assert!(self.bccx.region_scope_tree.scopes_intersect(old_loan.kill_scope,
|
||||
new_loan.kill_scope));
|
||||
|
||||
let err_old_new = Result::err(self.report_error_if_loan_conflicts_with_restriction(
|
||||
old_loan, new_loan, old_loan, new_loan
|
||||
));
|
||||
let err_new_old = Result::err(self.report_error_if_loan_conflicts_with_restriction(
|
||||
new_loan, old_loan, old_loan, new_loan
|
||||
));
|
||||
let err_old_new = self.report_error_if_loan_conflicts_with_restriction(
|
||||
old_loan, new_loan, old_loan, new_loan).err();
|
||||
let err_new_old = self.report_error_if_loan_conflicts_with_restriction(
|
||||
new_loan, old_loan, old_loan, new_loan).err();
|
||||
|
||||
if let Some(mut err_old) = err_old_new {
|
||||
err_old.emit();
|
||||
if let Some(mut err_new) = err_new_old {
|
||||
match (err_old_new, err_new_old) {
|
||||
(Some(mut err), None) | (None, Some(mut err)) => err.emit(),
|
||||
(Some(mut err_old), Some(mut err_new)) => {
|
||||
err_old.emit();
|
||||
err_new.cancel();
|
||||
}
|
||||
} else if let Some(mut err_new) = err_new_old {
|
||||
err_new.emit();
|
||||
} else {
|
||||
return true;
|
||||
(None, None) => return true,
|
||||
}
|
||||
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue