remove feature(inline_const_pat)
This commit is contained in:
parent
5d85a714b1
commit
d4b8fa9e4c
53 changed files with 110 additions and 887 deletions
|
@ -842,8 +842,6 @@ parse_unexpected_expr_in_pat_const_sugg = consider extracting the expression int
|
|||
|
||||
parse_unexpected_expr_in_pat_create_guard_sugg = consider moving the expression to a match arm guard
|
||||
|
||||
parse_unexpected_expr_in_pat_inline_const_sugg = consider wrapping the expression in an inline `const` (requires `{"#"}![feature(inline_const_pat)]`)
|
||||
|
||||
parse_unexpected_expr_in_pat_update_guard_sugg = consider moving the expression to the match arm guard
|
||||
|
||||
parse_unexpected_if_with_if = unexpected `if` in the condition expression
|
||||
|
|
|
@ -2787,17 +2787,6 @@ pub(crate) enum UnexpectedExpressionInPatternSugg {
|
|||
/// The statement's block's indentation.
|
||||
indentation: String,
|
||||
},
|
||||
|
||||
#[multipart_suggestion(
|
||||
parse_unexpected_expr_in_pat_inline_const_sugg,
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
InlineConst {
|
||||
#[suggestion_part(code = "const {{ ")]
|
||||
start_span: Span,
|
||||
#[suggestion_part(code = " }}")]
|
||||
end_span: Span,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -631,15 +631,6 @@ impl<'a> Parser<'a> {
|
|||
ident,
|
||||
indentation,
|
||||
});
|
||||
|
||||
// help: wrap the expr in a `const { expr }`
|
||||
// FIXME(inline_const_pat): once stabilized, remove this check and remove the `(requires #[feature(inline_const_pat)])` note from the message
|
||||
if self.parser.psess.unstable_features.is_nightly_build() {
|
||||
err.subdiagnostic(UnexpectedExpressionInPatternSugg::InlineConst {
|
||||
start_span: expr_span.shrink_to_lo(),
|
||||
end_span: expr_span.shrink_to_hi(),
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue