Rollup merge of #72941 - nagisa:ensure-stack-for-match, r=oli-obk
Ensure stack when building MIR for matches In particular matching on complex types such as strings will cause deep recursion to happen. Fixes #72933 r? @matthewjasper @oli-obk
This commit is contained in:
commit
adc92becf0
|
@ -10,7 +10,7 @@ use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
|
||||||
use crate::build::{BlockAnd, BlockAndExtension, Builder};
|
use crate::build::{BlockAnd, BlockAndExtension, Builder};
|
||||||
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
|
use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
|
||||||
use crate::hair::{self, *};
|
use crate::hair::{self, *};
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::{fx::{FxHashMap, FxHashSet}, stack::ensure_sufficient_stack};
|
||||||
use rustc_hir::HirId;
|
use rustc_hir::HirId;
|
||||||
use rustc_index::bit_set::BitSet;
|
use rustc_index::bit_set::BitSet;
|
||||||
use rustc_middle::middle::region;
|
use rustc_middle::middle::region;
|
||||||
|
@ -909,30 +909,32 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||||
split_or_candidate |= self.simplify_candidate(candidate);
|
split_or_candidate |= self.simplify_candidate(candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if split_or_candidate {
|
ensure_sufficient_stack(|| {
|
||||||
// At least one of the candidates has been split into subcandidates.
|
if split_or_candidate {
|
||||||
// We need to change the candidate list to include those.
|
// At least one of the candidates has been split into subcandidates.
|
||||||
let mut new_candidates = Vec::new();
|
// We need to change the candidate list to include those.
|
||||||
|
let mut new_candidates = Vec::new();
|
||||||
|
|
||||||
for candidate in candidates {
|
for candidate in candidates {
|
||||||
candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate));
|
candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate));
|
||||||
|
}
|
||||||
|
self.match_simplified_candidates(
|
||||||
|
span,
|
||||||
|
start_block,
|
||||||
|
otherwise_block,
|
||||||
|
&mut *new_candidates,
|
||||||
|
fake_borrows,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
self.match_simplified_candidates(
|
||||||
|
span,
|
||||||
|
start_block,
|
||||||
|
otherwise_block,
|
||||||
|
candidates,
|
||||||
|
fake_borrows,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.match_simplified_candidates(
|
});
|
||||||
span,
|
|
||||||
start_block,
|
|
||||||
otherwise_block,
|
|
||||||
&mut *new_candidates,
|
|
||||||
fake_borrows,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
self.match_simplified_candidates(
|
|
||||||
span,
|
|
||||||
start_block,
|
|
||||||
otherwise_block,
|
|
||||||
candidates,
|
|
||||||
fake_borrows,
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_simplified_candidates(
|
fn match_simplified_candidates(
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue