Rollup merge of #91018 - est31:let_else, r=matthewjasper
Adopt let_else in more places in rustc_mir_build Helps avoid rightward drift. followup of #89933
This commit is contained in:
commit
f37a6caffe
3 changed files with 66 additions and 69 deletions
|
@ -1606,13 +1606,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
// encounter a candidate where the test is not relevant; at
|
// encounter a candidate where the test is not relevant; at
|
||||||
// that point, we stop sorting.
|
// that point, we stop sorting.
|
||||||
while let Some(candidate) = candidates.first_mut() {
|
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();
|
let (candidate, rest) = candidates.split_first_mut().unwrap();
|
||||||
target_candidates[idx].push(candidate);
|
target_candidates[idx].push(candidate);
|
||||||
candidates = rest;
|
candidates = rest;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// at least the first candidate ought to be tested
|
// at least the first candidate ought to be tested
|
||||||
assert!(total_candidate_count > candidates.len());
|
assert!(total_candidate_count > candidates.len());
|
||||||
|
|
|
@ -966,7 +966,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
DropKind::Value,
|
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) {
|
let pat = match tcx.hir().get(arg.pat.hir_id) {
|
||||||
Node::Pat(pat) | Node::Binding(pat) => pat,
|
Node::Pat(pat) | Node::Binding(pat) => pat,
|
||||||
node => bug!("pattern became {:?}", node),
|
node => bug!("pattern became {:?}", node),
|
||||||
|
@ -1012,14 +1014,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
Some((Some(&place), span)),
|
Some((Some(&place), span)),
|
||||||
);
|
);
|
||||||
let place_builder = PlaceBuilder::from(local);
|
let place_builder = PlaceBuilder::from(local);
|
||||||
unpack!(
|
unpack!(block = self.place_into_pattern(block, pattern, place_builder, false));
|
||||||
block = self.place_into_pattern(block, pattern, place_builder, false)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.source_scope = original_source_scope;
|
self.source_scope = original_source_scope;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Enter the argument pattern bindings source scope, if it exists.
|
// Enter the argument pattern bindings source scope, if it exists.
|
||||||
if let Some(source_scope) = scope {
|
if let Some(source_scope) = scope {
|
||||||
|
|
|
@ -256,7 +256,13 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
PatKind::Binding { mode: BindingMode::ByRef(borrow_kind), ty, .. } => {
|
PatKind::Binding { mode: BindingMode::ByRef(borrow_kind), ty, .. } => {
|
||||||
if self.inside_adt {
|
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 {
|
match borrow_kind {
|
||||||
BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
|
BorrowKind::Shallow | BorrowKind::Shared | BorrowKind::Unique => {
|
||||||
if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
|
if !ty.is_freeze(self.tcx.at(pat.span), self.param_env) {
|
||||||
|
@ -267,13 +273,6 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
||||||
self.requires_unsafe(pat.span, MutationOfLayoutConstrainedField);
|
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);
|
visit::walk_pat(self, pat);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue