@@ -289,6 +289,7 @@ use super::deconstruct_pat::{Constructor, DeconstructedPat, Fields, SplitWildcar
289289use rustc_data_structures:: captures:: Captures ;
290290
291291use rustc_arena:: TypedArena ;
292+ use rustc_data_structures:: stack:: ensure_sufficient_stack;
292293use rustc_hir:: def_id:: DefId ;
293294use rustc_hir:: HirId ;
294295use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
@@ -808,8 +809,9 @@ fn is_useful<'p, 'tcx>(
808809 // We try each or-pattern branch in turn.
809810 let mut matrix = matrix. clone ( ) ;
810811 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+ } ) ;
813815 ret. extend ( usefulness) ;
814816 // If pattern has a guard don't add it to the matrix.
815817 if !is_under_guard {
@@ -840,8 +842,9 @@ fn is_useful<'p, 'tcx>(
840842 // We cache the result of `Fields::wildcards` because it is used a lot.
841843 let spec_matrix = start_matrix. specialize_constructor ( pcx, & ctor) ;
842844 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+ } ) ;
845848 let usefulness = usefulness. apply_constructor ( pcx, start_matrix, & ctor) ;
846849
847850 // When all the conditions are met we have a match with a `non_exhaustive` enum
0 commit comments