Split inline const to two feature gates
This commit is contained in:
parent
cebd2dda1d
commit
6d61d87b22
21 changed files with 67 additions and 31 deletions
|
@ -1243,7 +1243,7 @@ impl<'a> Parser<'a> {
|
|||
} else if self.eat_keyword(kw::Unsafe) {
|
||||
self.parse_block_expr(None, lo, BlockCheckMode::Unsafe(ast::UserProvided), attrs)
|
||||
} else if self.check_inline_const(0) {
|
||||
self.parse_const_block(lo.to(self.token.span))
|
||||
self.parse_const_block(lo.to(self.token.span), false)
|
||||
} else if self.is_do_catch_block() {
|
||||
self.recover_do_catch(attrs)
|
||||
} else if self.is_try_block() {
|
||||
|
|
|
@ -1095,8 +1095,12 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
/// Parses inline const expressions.
|
||||
fn parse_const_block(&mut self, span: Span) -> PResult<'a, P<Expr>> {
|
||||
self.sess.gated_spans.gate(sym::inline_const, span);
|
||||
fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> {
|
||||
if pat {
|
||||
self.sess.gated_spans.gate(sym::inline_const_pat, span);
|
||||
} else {
|
||||
self.sess.gated_spans.gate(sym::inline_const, span);
|
||||
}
|
||||
self.eat_keyword(kw::Const);
|
||||
let blk = self.parse_block()?;
|
||||
let anon_const = AnonConst {
|
||||
|
|
|
@ -437,7 +437,7 @@ impl<'a> Parser<'a> {
|
|||
PatKind::Box(pat)
|
||||
} else if self.check_inline_const(0) {
|
||||
// Parse `const pat`
|
||||
let const_expr = self.parse_const_block(lo.to(self.token.span))?;
|
||||
let const_expr = self.parse_const_block(lo.to(self.token.span), true)?;
|
||||
|
||||
if let Some(re) = self.parse_range_end() {
|
||||
self.parse_pat_range_begin_with(const_expr, re)?
|
||||
|
@ -884,7 +884,7 @@ impl<'a> Parser<'a> {
|
|||
|
||||
fn parse_pat_range_end(&mut self) -> PResult<'a, P<Expr>> {
|
||||
if self.check_inline_const(0) {
|
||||
self.parse_const_block(self.token.span)
|
||||
self.parse_const_block(self.token.span, true)
|
||||
} else if self.check_path() {
|
||||
let lo = self.token.span;
|
||||
let (qself, path) = if self.eat_lt() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue