Brace-ident-colon can certainly no longer start a block
thanks to the removal of type ascription.
This commit is contained in:
parent
848b0da34f
commit
82796dd858
7 changed files with 88 additions and 61 deletions
|
@ -3474,19 +3474,9 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
|
||||
fn is_certainly_not_a_block(&self) -> bool {
|
||||
// `{ ident, ` and `{ ident: ` cannot start a block.
|
||||
self.look_ahead(1, |t| t.is_ident())
|
||||
&& (
|
||||
// `{ ident, ` cannot start a block.
|
||||
self.look_ahead(2, |t| t == &token::Comma)
|
||||
|| self.look_ahead(2, |t| t == &token::Colon)
|
||||
&& (
|
||||
// `{ ident: token, ` cannot start a block.
|
||||
self.look_ahead(4, |t| t == &token::Comma)
|
||||
// `{ ident: ` cannot start a block unless it's a type ascription
|
||||
// `ident: Type`.
|
||||
|| self.look_ahead(3, |t| !t.can_begin_type())
|
||||
)
|
||||
)
|
||||
&& self.look_ahead(2, |t| t == &token::Comma || t == &token::Colon)
|
||||
}
|
||||
|
||||
fn maybe_parse_struct_expr(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue