diff options
| author | bors <bors@rust-lang.org> | 2025-04-11 20:06:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-11 20:06:06 +0000 |
| commit | d2b3dd7c173de58881ead8109f7970b9cd926e2a (patch) | |
| tree | 48ccfce095356e8edf1cbb247de02de9f37e7bb0 /compiler/rustc_parse/src/parser | |
| parent | ed3a4aac8172c599c181120bddd2840843ecc9ad (diff) | |
| parent | c8992c90e003ada16d956bdf814f3d109c98dd31 (diff) | |
| download | rust-d2b3dd7c173de58881ead8109f7970b9cd926e2a.tar.gz rust-d2b3dd7c173de58881ead8109f7970b9cd926e2a.zip | |
Auto merge of #139689 - jhpratt:rollup-wlkdyjg, r=jhpratt
Rollup of 7 pull requests Successful merges: - #137835 (Use `BinOp::Cmp` for `iNN::signum`) - #139584 (Avoid a reverse map that is only used in diagnostics paths) - #139638 (Cleanup the `InstSimplify` MIR transformation) - #139653 (Handle a negated literal in `eat_token_lit`.) - #139662 (Tweak `DefPathData`) - #139664 (Reuse address-space computation from global alloc) - #139687 (Add spastorino to users_on_vacation) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 9c457f150a3..d52e36fcfac 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2166,10 +2166,15 @@ impl<'a> Parser<'a> { let expr = self .eat_metavar_seq(mv_kind, |this| this.parse_expr()) .expect("metavar seq expr"); - let ast::ExprKind::Lit(token_lit) = expr.kind else { - panic!("didn't reparse an expr"); - }; - Some(token_lit) + if let ast::ExprKind::Lit(token_lit) = expr.kind { + Some(token_lit) + } else if let ast::ExprKind::Unary(UnOp::Neg, inner) = &expr.kind + && let ast::Expr { kind: ast::ExprKind::Lit(_), .. } = **inner + { + None + } else { + panic!("unexpected reparsed expr: {:?}", expr.kind); + } } _ => None, } |
