Rollup merge of #101502 - TaKO8Ki:do-not-suggest-semicolon-for-macro-without-exclamation-mark, r=wesleywiser

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

Fixes a regression in #101490
This commit is contained in:
Matthias Krüger 2022-09-07 21:48:15 +02:00 committed by GitHub
commit c365ce3ffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 16 additions and 2 deletions

View File

@ -1977,6 +1977,9 @@ fn suggest_missing_semicolon_before_array(
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]
| ^