@@ -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;
@@ -907,30 +907,32 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
907907 split_or_candidate |= self . simplify_candidate ( candidate) ;
908908 }
909909
910- if split_or_candidate {
911- // At least one of the candidates has been split into subcandidates.
912- // We need to change the candidate list to include those.
913- let mut new_candidates = Vec :: new ( ) ;
910+ ensure_sufficient_stack ( || {
911+ if split_or_candidate {
912+ // At least one of the candidates has been split into subcandidates.
913+ // We need to change the candidate list to include those.
914+ let mut new_candidates = Vec :: new ( ) ;
914915
915- for candidate in candidates {
916- candidate. visit_leaves ( |leaf_candidate| new_candidates. push ( leaf_candidate) ) ;
916+ for candidate in candidates {
917+ candidate. visit_leaves ( |leaf_candidate| new_candidates. push ( leaf_candidate) ) ;
918+ }
919+ self . match_simplified_candidates (
920+ span,
921+ start_block,
922+ otherwise_block,
923+ & mut * new_candidates,
924+ fake_borrows,
925+ ) ;
926+ } else {
927+ self . match_simplified_candidates (
928+ span,
929+ start_block,
930+ otherwise_block,
931+ candidates,
932+ fake_borrows,
933+ ) ;
917934 }
918- self . match_simplified_candidates (
919- span,
920- start_block,
921- otherwise_block,
922- & mut * new_candidates,
923- fake_borrows,
924- ) ;
925- } else {
926- self . match_simplified_candidates (
927- span,
928- start_block,
929- otherwise_block,
930- candidates,
931- fake_borrows,
932- ) ;
933- } ;
935+ } ) ;
934936 }
935937
936938 fn match_simplified_candidates (
0 commit comments