@@ -10,7 +10,7 @@ use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
1010use crate :: build:: { BlockAnd , BlockAndExtension , Builder } ;
1111use crate :: build:: { GuardFrame , GuardFrameLocal , LocalsForNode } ;
1212use crate :: hair:: { self , * } ;
13- use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
13+ use rustc_data_structures:: { fx:: { FxHashMap , FxHashSet } , stack :: ensure_sufficient_stack } ;
1414use rustc_hir:: HirId ;
1515use rustc_index:: bit_set:: BitSet ;
1616use rustc_middle:: middle:: region;
@@ -909,30 +909,32 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
909909 split_or_candidate |= self . simplify_candidate ( candidate) ;
910910 }
911911
912- if split_or_candidate {
913- // At least one of the candidates has been split into subcandidates.
914- // We need to change the candidate list to include those.
915- let mut new_candidates = Vec :: new ( ) ;
912+ ensure_sufficient_stack ( || {
913+ if split_or_candidate {
914+ // At least one of the candidates has been split into subcandidates.
915+ // We need to change the candidate list to include those.
916+ let mut new_candidates = Vec :: new ( ) ;
916917
917- for candidate in candidates {
918- candidate. visit_leaves ( |leaf_candidate| new_candidates. push ( leaf_candidate) ) ;
918+ for candidate in candidates {
919+ candidate. visit_leaves ( |leaf_candidate| new_candidates. push ( leaf_candidate) ) ;
920+ }
921+ self . match_simplified_candidates (
922+ span,
923+ start_block,
924+ otherwise_block,
925+ & mut * new_candidates,
926+ fake_borrows,
927+ ) ;
928+ } else {
929+ self . match_simplified_candidates (
930+ span,
931+ start_block,
932+ otherwise_block,
933+ candidates,
934+ fake_borrows,
935+ ) ;
919936 }
920- self . match_simplified_candidates (
921- span,
922- start_block,
923- otherwise_block,
924- & mut * new_candidates,
925- fake_borrows,
926- ) ;
927- } else {
928- self . match_simplified_candidates (
929- span,
930- start_block,
931- otherwise_block,
932- candidates,
933- fake_borrows,
934- ) ;
935- } ;
937+ } ) ;
936938 }
937939
938940 fn match_simplified_candidates (
0 commit comments