Use more let_else in rustc_mir_build
Helps avoid rightward drift.
This commit is contained in:
parent
6414e0b5b3
commit
8dc8e72c4d
@ -1606,13 +1606,12 @@ fn test_candidates<'pat, 'b, 'c>(
|
||||
// encounter a candidate where the test is not relevant; at
|
||||
// that point, we stop sorting.
|
||||
while let Some(candidate) = candidates.first_mut() {
|
||||
if let Some(idx) = self.sort_candidate(&match_place.clone(), &test, candidate) {
|
||||
let Some(idx) = self.sort_candidate(&match_place.clone(), &test, candidate) else {
|
||||
break;
|
||||
};
|
||||
let (candidate, rest) = candidates.split_first_mut().unwrap();
|
||||
target_candidates[idx].push(candidate);
|
||||
candidates = rest;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// at least the first candidate ought to be tested
|
||||
assert!(total_candidate_count > candidates.len());
|
||||
|
@ -966,7 +966,9 @@ fn args_and_body(
|
||||
DropKind::Value,
|
||||
);
|
||||
|
||||
if let Some(arg) = arg_opt {
|
||||
let Some(arg) = arg_opt else {
|
||||
continue;
|
||||
};
|
||||
let pat = match tcx.hir().get(arg.pat.hir_id) {
|
||||
Node::Pat(pat) | Node::Binding(pat) => pat,
|
||||
node => bug!("pattern became {:?}", node),
|
||||
@ -1012,14 +1014,11 @@ fn args_and_body(
|
||||
Some((Some(&place), span)),
|
||||
);
|
||||
let place_builder = PlaceBuilder::from(local);
|
||||
unpack!(
|
||||
block = self.place_into_pattern(block, pattern, place_builder, false)
|
||||
);
|
||||
unpack!(block = self.place_into_pattern(block, pattern, place_builder, false));
|
||||
}
|
||||
}
|
||||
self.source_scope = original_source_scope;
|
||||
}
|
||||
}
|
||||
|
||||
// Enter the argument pattern bindings source scope, if it exists.
|
||||
if let Some(source_scope) = scope {
|
||||
|
@ -256,7 +256,13 @@ fn visit_pat(&mut self, pat: &Pat<'tcx>) {
|
||||
}
|
||||
PatKind::Binding { mode: BindingMode::ByRef(borrow_kind), ty, .. } => {
|
||||
if self.inside_adt {
|
||||
if let ty::Ref(_, ty, _) = ty.kind() {
|
||||
let ty::Ref(_, ty, _) = ty.kind() else {
|
||||
span_bug!(
|
||||
pat.span,
|
||||
"BindingMode::ByRef in pattern, but found non-reference type {}",
|
||||
ty
|
||||
);
|
||||
};
|
||||
match borrow_kind {
|
||||
BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
|
||||
if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
|
||||
@ -267,13 +273,6 @@ fn visit_pat(&mut self, pat: &Pat<'tcx>) {
|
||||
self.requires_unsafe(pat.span, MutationOfLayoutConstrainedField);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
span_bug!(
|
||||
pat.span,
|
||||
"BindingMode::ByRef in pattern, but found non-reference type {}",
|
||||
ty
|
||||
);
|
||||
}
|
||||
}
|
||||
visit::walk_pat(self, pat);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user