don't suggest placing code in block if next token is open-brace
Thanks to the inestimably inimitable Esteban "Estebank" Küber for pointing this out. This is relevant to #46836.
This commit is contained in:
@@ -4486,6 +4486,11 @@ impl<'a> Parser<'a> {
|
|||||||
// Which is valid in other languages, but not Rust.
|
// Which is valid in other languages, but not Rust.
|
||||||
match self.parse_stmt_without_recovery(false) {
|
match self.parse_stmt_without_recovery(false) {
|
||||||
Ok(Some(stmt)) => {
|
Ok(Some(stmt)) => {
|
||||||
|
if self.look_ahead(1, |t| t == &token::OpenDelim(token::Brace)) {
|
||||||
|
// if the next token is an open brace (e.g., `if a b {`), the place-
|
||||||
|
// inside-a-block suggestion would be more likely wrong than right
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
let mut stmt_span = stmt.span;
|
let mut stmt_span = stmt.span;
|
||||||
// expand the span to include the semicolon, if it exists
|
// expand the span to include the semicolon, if it exists
|
||||||
if self.eat(&token::Semi) {
|
if self.eat(&token::Semi) {
|
||||||
|
|||||||
Reference in New Issue
Block a user