do not suggest a semicolon for a macro without `!`

This commit is contained in:
Takayuki Maeda 2022-09-07 03:59:47 +09:00
parent b44197abb0
commit 7ac124803f
8 changed files with 16 additions and 2 deletions

View File

@ -1977,6 +1977,9 @@ impl<'a> Parser<'a> {
open_delim_span: Span,
) -> PResult<'a, ()> {
if self.token.kind == token::Comma {
if !self.sess.source_map().is_multiline(prev_span.until(self.token.span)) {
return Ok(());
}
let mut snapshot = self.create_snapshot_for_diagnostic();
snapshot.bump();
match snapshot.parse_seq_to_before_end(

View File

@ -1,5 +1,5 @@
error: expected one of `.`, `?`, `]`, or an operator, found `,`
--> $DIR/do-not-suggest-suggest-semicolon-before-array.rs:5:5
--> $DIR/do-not-suggest-semicolon-before-array.rs:5:5
|
LL | [1, 3)
| ^ ^ help: `]` may belong here

View File

@ -0,0 +1,3 @@
fn main() {
let _x = vec[1, 2, 3]; //~ ERROR expected one of `.`, `?`, `]`, or an operator
}

View File

@ -0,0 +1,8 @@
error: expected one of `.`, `?`, `]`, or an operator, found `,`
--> $DIR/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs:2:19
|
LL | let _x = vec[1, 2, 3];
| ^ expected one of `.`, `?`, `]`, or an operator
error: aborting due to previous error

View File

@ -1,5 +1,5 @@
error: expected `;`, found `[`
--> $DIR/suggest-suggest-semicolon-before-array.rs:8:5
--> $DIR/suggest-semicolon-before-array.rs:8:5
|
LL | [1, 3]
| ^