diff options
| author | Josh Stone <jistone@redhat.com> | 2025-06-04 15:03:19 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2025-06-04 15:21:30 -0700 |
| commit | 925e76167ce2465c5c9d990d97c2db99f459640b (patch) | |
| tree | b6d168f02eddaf689ac30d7909a397685876b6f9 | |
| parent | 4b27a04cc8ed4da10a546a871e23e665d03f7a79 (diff) | |
| download | rust-925e76167ce2465c5c9d990d97c2db99f459640b.tar.gz rust-925e76167ce2465c5c9d990d97c2db99f459640b.zip | |
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.
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/expr.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 226dc920a49..78c168778ac 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -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))] |
