Rollup merge of #103946 - camsteffen:cleanup-bind-pattern, r=cjgillot
Cleanup bind_pattern args Fixes #101896
This commit is contained in:
commit
7b518af5d9
@ -364,12 +364,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let arm_block = this.bind_pattern(
|
let arm_block = this.bind_pattern(
|
||||||
outer_source_info,
|
outer_source_info,
|
||||||
candidate,
|
candidate,
|
||||||
arm.guard.as_ref(),
|
|
||||||
&fake_borrow_temps,
|
&fake_borrow_temps,
|
||||||
scrutinee_span,
|
scrutinee_span,
|
||||||
Some(arm.span),
|
Some((arm, match_scope)),
|
||||||
Some(arm.scope),
|
|
||||||
Some(match_scope),
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -410,12 +407,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
outer_source_info: SourceInfo,
|
outer_source_info: SourceInfo,
|
||||||
candidate: Candidate<'_, 'tcx>,
|
candidate: Candidate<'_, 'tcx>,
|
||||||
guard: Option<&Guard<'tcx>>,
|
|
||||||
fake_borrow_temps: &[(Place<'tcx>, Local)],
|
fake_borrow_temps: &[(Place<'tcx>, Local)],
|
||||||
scrutinee_span: Span,
|
scrutinee_span: Span,
|
||||||
arm_span: Option<Span>,
|
arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>,
|
||||||
arm_scope: Option<region::Scope>,
|
|
||||||
match_scope: Option<region::Scope>,
|
|
||||||
storages_alive: bool,
|
storages_alive: bool,
|
||||||
) -> BasicBlock {
|
) -> BasicBlock {
|
||||||
if candidate.subcandidates.is_empty() {
|
if candidate.subcandidates.is_empty() {
|
||||||
@ -424,11 +418,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
self.bind_and_guard_matched_candidate(
|
self.bind_and_guard_matched_candidate(
|
||||||
candidate,
|
candidate,
|
||||||
&[],
|
&[],
|
||||||
guard,
|
|
||||||
fake_borrow_temps,
|
fake_borrow_temps,
|
||||||
scrutinee_span,
|
scrutinee_span,
|
||||||
arm_span,
|
arm_match_scope,
|
||||||
match_scope,
|
|
||||||
true,
|
true,
|
||||||
storages_alive,
|
storages_alive,
|
||||||
)
|
)
|
||||||
@ -449,6 +441,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
// we lower the guard.
|
// we lower the guard.
|
||||||
let target_block = self.cfg.start_new_block();
|
let target_block = self.cfg.start_new_block();
|
||||||
let mut schedule_drops = true;
|
let mut schedule_drops = true;
|
||||||
|
let arm = arm_match_scope.unzip().0;
|
||||||
// We keep a stack of all of the bindings and type ascriptions
|
// We keep a stack of all of the bindings and type ascriptions
|
||||||
// from the parent candidates that we visit, that also need to
|
// from the parent candidates that we visit, that also need to
|
||||||
// be bound for each candidate.
|
// be bound for each candidate.
|
||||||
@ -456,21 +449,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
candidate,
|
candidate,
|
||||||
&mut Vec::new(),
|
&mut Vec::new(),
|
||||||
&mut |leaf_candidate, parent_bindings| {
|
&mut |leaf_candidate, parent_bindings| {
|
||||||
if let Some(arm_scope) = arm_scope {
|
if let Some(arm) = arm {
|
||||||
self.clear_top_scope(arm_scope);
|
self.clear_top_scope(arm.scope);
|
||||||
}
|
}
|
||||||
let binding_end = self.bind_and_guard_matched_candidate(
|
let binding_end = self.bind_and_guard_matched_candidate(
|
||||||
leaf_candidate,
|
leaf_candidate,
|
||||||
parent_bindings,
|
parent_bindings,
|
||||||
guard,
|
|
||||||
&fake_borrow_temps,
|
&fake_borrow_temps,
|
||||||
scrutinee_span,
|
scrutinee_span,
|
||||||
arm_span,
|
arm_match_scope,
|
||||||
match_scope,
|
|
||||||
schedule_drops,
|
schedule_drops,
|
||||||
storages_alive,
|
storages_alive,
|
||||||
);
|
);
|
||||||
if arm_scope.is_none() {
|
if arm.is_none() {
|
||||||
schedule_drops = false;
|
schedule_drops = false;
|
||||||
}
|
}
|
||||||
self.cfg.goto(binding_end, outer_source_info, target_block);
|
self.cfg.goto(binding_end, outer_source_info, target_block);
|
||||||
@ -636,12 +627,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
self.bind_pattern(
|
self.bind_pattern(
|
||||||
self.source_info(irrefutable_pat.span),
|
self.source_info(irrefutable_pat.span),
|
||||||
candidate,
|
candidate,
|
||||||
None,
|
|
||||||
&fake_borrow_temps,
|
&fake_borrow_temps,
|
||||||
irrefutable_pat.span,
|
irrefutable_pat.span,
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.unit()
|
.unit()
|
||||||
@ -1820,12 +1808,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let post_guard_block = self.bind_pattern(
|
let post_guard_block = self.bind_pattern(
|
||||||
self.source_info(pat.span),
|
self.source_info(pat.span),
|
||||||
guard_candidate,
|
guard_candidate,
|
||||||
None,
|
|
||||||
&fake_borrow_temps,
|
&fake_borrow_temps,
|
||||||
expr.span,
|
expr.span,
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1844,11 +1829,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
candidate: Candidate<'pat, 'tcx>,
|
candidate: Candidate<'pat, 'tcx>,
|
||||||
parent_bindings: &[(Vec<Binding<'tcx>>, Vec<Ascription<'tcx>>)],
|
parent_bindings: &[(Vec<Binding<'tcx>>, Vec<Ascription<'tcx>>)],
|
||||||
guard: Option<&Guard<'tcx>>,
|
|
||||||
fake_borrows: &[(Place<'tcx>, Local)],
|
fake_borrows: &[(Place<'tcx>, Local)],
|
||||||
scrutinee_span: Span,
|
scrutinee_span: Span,
|
||||||
arm_span: Option<Span>,
|
arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>,
|
||||||
match_scope: Option<region::Scope>,
|
|
||||||
schedule_drops: bool,
|
schedule_drops: bool,
|
||||||
storages_alive: bool,
|
storages_alive: bool,
|
||||||
) -> BasicBlock {
|
) -> BasicBlock {
|
||||||
@ -1960,7 +1943,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
// the reference that we create for the arm.
|
// the reference that we create for the arm.
|
||||||
// * So we eagerly create the reference for the arm and then take a
|
// * So we eagerly create the reference for the arm and then take a
|
||||||
// reference to that.
|
// reference to that.
|
||||||
if let Some(guard) = guard {
|
if let Some((arm, match_scope)) = arm_match_scope
|
||||||
|
&& let Some(guard) = &arm.guard
|
||||||
|
{
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
let bindings = parent_bindings
|
let bindings = parent_bindings
|
||||||
.iter()
|
.iter()
|
||||||
@ -1981,8 +1966,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
self.cfg.push_assign(block, scrutinee_source_info, Place::from(temp), borrow);
|
self.cfg.push_assign(block, scrutinee_source_info, Place::from(temp), borrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
let arm_span = arm_span.unwrap();
|
|
||||||
let match_scope = match_scope.unwrap();
|
|
||||||
let mut guard_span = rustc_span::DUMMY_SP;
|
let mut guard_span = rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
let (post_guard_block, otherwise_post_guard_block) =
|
let (post_guard_block, otherwise_post_guard_block) =
|
||||||
@ -1995,13 +1978,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
e,
|
e,
|
||||||
None,
|
None,
|
||||||
match_scope,
|
match_scope,
|
||||||
this.source_info(arm_span),
|
this.source_info(arm.span),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Guard::IfLet(ref pat, scrutinee) => {
|
Guard::IfLet(ref pat, scrutinee) => {
|
||||||
let s = &this.thir[scrutinee];
|
let s = &this.thir[scrutinee];
|
||||||
guard_span = s.span;
|
guard_span = s.span;
|
||||||
this.lower_let_expr(block, s, pat, match_scope, None, arm_span)
|
this.lower_let_expr(block, s, pat, match_scope, None, arm.span)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2317,24 +2300,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
let matching = this.bind_pattern(
|
let matching = this.bind_pattern(
|
||||||
this.source_info(pattern.span),
|
this.source_info(pattern.span),
|
||||||
candidate,
|
candidate,
|
||||||
None,
|
|
||||||
&fake_borrow_temps,
|
&fake_borrow_temps,
|
||||||
initializer_span,
|
initializer_span,
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
// This block is for the failure case
|
// This block is for the failure case
|
||||||
let failure = this.bind_pattern(
|
let failure = this.bind_pattern(
|
||||||
this.source_info(else_block_span),
|
this.source_info(else_block_span),
|
||||||
wildcard,
|
wildcard,
|
||||||
None,
|
|
||||||
&fake_borrow_temps,
|
&fake_borrow_temps,
|
||||||
initializer_span,
|
initializer_span,
|
||||||
None,
|
None,
|
||||||
None,
|
|
||||||
None,
|
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
this.break_for_else(failure, *let_else_scope, this.source_info(initializer_span));
|
this.break_for_else(failure, *let_else_scope, this.source_info(initializer_span));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user