Ensure stack in ThirBuildCx::mirror_exprs
This solve a stack overflow found on Fedora s390x when building `tests/ui/parser/survive-peano-lesson-queue.rs`. Note that the singular `mirror_expr` method already has this stack check, but in this case the plural method was the one recursing too deeply.
This commit is contained in:
parent
4b27a04cc8
commit
925e76167c
1 changed files with 4 additions and 1 deletions
|
|
@ -38,7 +38,10 @@ impl<'tcx> ThirBuildCx<'tcx> {
|
|||
}
|
||||
|
||||
pub(crate) fn mirror_exprs(&mut self, exprs: &'tcx [hir::Expr<'tcx>]) -> Box<[ExprId]> {
|
||||
exprs.iter().map(|expr| self.mirror_expr_inner(expr)).collect()
|
||||
// `mirror_exprs` may also recurse deeply, so it needs protection from stack overflow.
|
||||
// Note that we *could* forward to `mirror_expr` for that, but we can consolidate the
|
||||
// overhead of stack growth by doing it outside the iteration.
|
||||
ensure_sufficient_stack(|| exprs.iter().map(|expr| self.mirror_expr_inner(expr)).collect())
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(self, hir_expr))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue