mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
address review: modify matches/mod.rs
The candidate shouldn't have false_edge_start_block if it has sub candidates. In remove_never_subcandidates(), the false_edge_start_block from the first sub candidte is assigned to a value and the value is later used if all sub candidates are removed and candidate doesn't have false_edge_start_block. In merge_trivial_subcandidates, I leave the if block which assign a false_edge_start_block into the candidate as before I put this commit since compile panics. Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
This commit is contained in:
parent
d8a216b866
commit
481ed2d931
@ -1940,10 +1940,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
/// in match tree lowering.
|
||||
fn merge_trivial_subcandidates(&mut self, candidate: &mut Candidate<'_, 'tcx>) {
|
||||
assert!(!candidate.subcandidates.is_empty());
|
||||
if candidate.false_edge_start_block.is_none() {
|
||||
candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
|
||||
}
|
||||
|
||||
if candidate.has_guard {
|
||||
// FIXME(or_patterns; matthewjasper) Don't give up if we have a guard.
|
||||
return;
|
||||
@ -1963,6 +1959,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let or_span = candidate.or_span.take().unwrap();
|
||||
let source_info = self.source_info(or_span);
|
||||
|
||||
if candidate.false_edge_start_block.is_none() {
|
||||
candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
|
||||
}
|
||||
|
||||
// Remove the (known-trivial) subcandidates from the candidate tree,
|
||||
// so that they aren't visible after match tree lowering, and wire them
|
||||
// all to join up at a single shared pre-binding block.
|
||||
@ -1986,6 +1986,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
return;
|
||||
}
|
||||
|
||||
let false_edge_start_block = candidate.subcandidates[0].false_edge_start_block;
|
||||
candidate.subcandidates.retain_mut(|candidate| {
|
||||
if candidate.extra_data.is_never {
|
||||
candidate.visit_leaves(|subcandidate| {
|
||||
@ -2004,6 +2005,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let next_block = self.cfg.start_new_block();
|
||||
candidate.pre_binding_block = Some(next_block);
|
||||
candidate.otherwise_block = Some(next_block);
|
||||
// In addition, if `candidate` should have `false_edge_start_block`.
|
||||
if candidate.false_edge_start_block.is_none() {
|
||||
candidate.false_edge_start_block = false_edge_start_block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user