Skip to content

Commit

Permalink
Rollup merge of rust-lang#101502 - TaKO8Ki:do-not-suggest-semicolon-f…
Browse files Browse the repository at this point in the history
…or-macro-without-exclamation-mark, r=wesleywiser

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

Fixes a regression in rust-lang#101490
  • Loading branch information
matthiaskrgr committed Sep 7, 2022
2 parents 9361297 + 7ac1248 commit c365ce3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
let _x = vec[1, 2, 3]; //~ ERROR expected one of `.`, `?`, `]`, or an operator
}
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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]
| ^
Expand Down

0 comments on commit c365ce3

Please sign in to comment.