@@ -289,6 +289,7 @@ use super::deconstruct_pat::{Constructor, DeconstructedPat, Fields, SplitWildcar
289
289
use rustc_data_structures:: captures:: Captures ;
290
290
291
291
use rustc_arena:: TypedArena ;
292
+ use rustc_data_structures:: stack:: ensure_sufficient_stack;
292
293
use rustc_hir:: def_id:: DefId ;
293
294
use rustc_hir:: HirId ;
294
295
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
@@ -808,8 +809,9 @@ fn is_useful<'p, 'tcx>(
808
809
// We try each or-pattern branch in turn.
809
810
let mut matrix = matrix. clone ( ) ;
810
811
for v in v. expand_or_pat ( ) {
811
- let usefulness =
812
- is_useful ( cx, & matrix, & v, witness_preference, hir_id, is_under_guard, false ) ;
812
+ let usefulness = ensure_sufficient_stack ( || {
813
+ is_useful ( cx, & matrix, & v, witness_preference, hir_id, is_under_guard, false )
814
+ } ) ;
813
815
ret. extend ( usefulness) ;
814
816
// If pattern has a guard don't add it to the matrix.
815
817
if !is_under_guard {
@@ -840,8 +842,9 @@ fn is_useful<'p, 'tcx>(
840
842
// We cache the result of `Fields::wildcards` because it is used a lot.
841
843
let spec_matrix = start_matrix. specialize_constructor ( pcx, & ctor) ;
842
844
let v = v. pop_head_constructor ( cx, & ctor) ;
843
- let usefulness =
844
- is_useful ( cx, & spec_matrix, & v, witness_preference, hir_id, is_under_guard, false ) ;
845
+ let usefulness = ensure_sufficient_stack ( || {
846
+ is_useful ( cx, & spec_matrix, & v, witness_preference, hir_id, is_under_guard, false )
847
+ } ) ;
845
848
let usefulness = usefulness. apply_constructor ( pcx, start_matrix, & ctor) ;
846
849
847
850
// When all the conditions are met we have a match with a `non_exhaustive` enum
0 commit comments