Brace-ident-colon can certainly no longer start a block

thanks to the removal of type ascription.
This commit is contained in:
León Orell Valerian Liehr 2025-03-24 00:01:30 +01:00
parent 848b0da34f
commit 82796dd858
No known key found for this signature in database
GPG key ID: D17A07215F68E713
7 changed files with 88 additions and 61 deletions

View file

@ -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(