diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-06 00:58:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 00:58:45 +0200 |
| commit | 324681b76e958c5591f590c8ec065042849f40d9 (patch) | |
| tree | 62922355227080092fe01b358328498ca8d4fa41 /compiler/rustc_parse/src | |
| parent | 29954af23a56fc8172b09bf5303bad891e3c94fd (diff) | |
| parent | af2a85bd75c011fb3453a4963400918e096e1896 (diff) | |
Rollup merge of #142047 - cuviper:s390x-stack, r=oli-obk
Ensure stack in two places that affect s390x In our Fedora s390x test results, we found two tests that started hitting stack overflows in the 1.87.0 update. It seems to be related in some part to our use of PGO as well, probably inlining more into stack frames that were already recursive. The main points of recursion that I identified were: - `ui/parser/survive-peano-lesson-queue.rs` in `ThirBuildCx::mirror_exprs` - `ui/associated-consts/issue-93775.rs` in `Parser::parse_ty` A couple new `ensure_sufficient_stack` calls will solve these tests.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/ty.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 17481731b11..6eaec2e29ad 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -7,6 +7,7 @@ use rustc_ast::{ Pinnedness, PolyTraitRef, PreciseCapturingArg, TraitBoundModifiers, TraitObjectSyntax, Ty, TyKind, UnsafeBinderTy, }; +use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{Applicability, Diag, PResult}; use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym}; use thin_vec::{ThinVec, thin_vec}; @@ -104,14 +105,17 @@ fn can_begin_dyn_bound_in_edition_2015(t: &Token) -> bool { impl<'a> Parser<'a> { /// Parses a type. pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> { - self.parse_ty_common( - AllowPlus::Yes, - AllowCVariadic::No, - RecoverQPath::Yes, - RecoverReturnSign::Yes, - None, - RecoverQuestionMark::Yes, - ) + // Make sure deeply nested types don't overflow the stack. + ensure_sufficient_stack(|| { + self.parse_ty_common( + AllowPlus::Yes, + AllowCVariadic::No, + RecoverQPath::Yes, + RecoverReturnSign::Yes, + None, + RecoverQuestionMark::Yes, + ) + }) } pub(super) fn parse_ty_with_generics_recovery( |
