diff options
| author | lcnr <rust@lcnr.de> | 2025-03-14 12:47:08 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-03-21 09:35:31 +0100 |
| commit | d4b8fa9e4c04f3afb7daad03d6719605a8c4bb90 (patch) | |
| tree | 5008bd6e2b3e6bb2086bb5959eb4b7bfa2c951f6 /compiler/rustc_parse/src/parser/mod.rs | |
| parent | 5d85a714b10a9121d2ec5115f39e904174f804e1 (diff) | |
| download | rust-d4b8fa9e4c04f3afb7daad03d6719605a8c4bb90.tar.gz rust-d4b8fa9e4c04f3afb7daad03d6719605a8c4bb90.zip | |
remove `feature(inline_const_pat)`
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index a79b4048288..d865fd42764 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1370,9 +1370,6 @@ impl<'a> Parser<'a> { /// Parses inline const expressions. fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> { - if pat { - self.psess.gated_spans.gate(sym::inline_const_pat, span); - } self.expect_keyword(exp!(Const))?; let (attrs, blk) = self.parse_inner_attrs_and_block(None)?; let anon_const = AnonConst { @@ -1380,7 +1377,17 @@ impl<'a> Parser<'a> { value: self.mk_expr(blk.span, ExprKind::Block(blk, None)), }; let blk_span = anon_const.value.span; - Ok(self.mk_expr_with_attrs(span.to(blk_span), ExprKind::ConstBlock(anon_const), attrs)) + let kind = if pat { + let guar = self + .dcx() + .struct_span_err(blk_span, "`inline_const_pat` has been removed") + .with_help("use a named `const`-item or an `if`-guard instead") + .emit(); + ExprKind::Err(guar) + } else { + ExprKind::ConstBlock(anon_const) + }; + Ok(self.mk_expr_with_attrs(span.to(blk_span), kind, attrs)) } /// Parses mutability (`mut` or nothing). |
