diff options
| author | bors <bors@rust-lang.org> | 2023-08-20 11:48:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-08-20 11:48:37 +0000 |
| commit | c0b6ffaaea3ebdf5f7a58fc4cf7ee52c91077fb9 (patch) | |
| tree | e41f32f7dcc5740e293c2396da0353ed75fbf54b /compiler/rustc_parse/src | |
| parent | ff55fa30267d7963146c52026b4f4f5396484675 (diff) | |
| parent | 1e87ef66f4695d650672c8db0f60128f5024df18 (diff) | |
| download | rust-c0b6ffaaea3ebdf5f7a58fc4cf7ee52c91077fb9.tar.gz rust-c0b6ffaaea3ebdf5f7a58fc4cf7ee52c91077fb9.zip | |
Auto merge of #114990 - Zoxc:else-if-overflow, r=cjgillot
Fix a stack overflow with long else if chains This fixes stack overflows when running the `issue-74564-if-expr-stack-overflow.rs` test with the parallel compiler.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e308e5b3420..9ae3ef6172c 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -22,6 +22,7 @@ use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty use rustc_ast::{Arm, Async, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits}; use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind}; use rustc_ast_pretty::pprust; +use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::{ AddToDiagnostic, Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult, StashKey, @@ -2489,7 +2490,7 @@ impl<'a> Parser<'a> { let else_span = self.prev_token.span; // `else` let attrs = self.parse_outer_attributes()?; // For recovery. let expr = if self.eat_keyword(kw::If) { - self.parse_expr_if()? + ensure_sufficient_stack(|| self.parse_expr_if())? } else if self.check(&TokenKind::OpenDelim(Delimiter::Brace)) { self.parse_simple_block()? } else { |
