forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#108244 - lukas-code:semicolon-recovery-span…
…, r=compiler-errors Use span of semicolon for eager recovery in expression Instead of the span of the token after the semicolon. This will hopefully cause fewer errors from overlapping spans. fixes rust-lang#108242 based on rust-lang#108239
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/ui/argument-suggestions/issue-108242-semicolon-recovery.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fn foo() {} | ||
fn main() { | ||
foo(; //~ ERROR this function takes 0 arguments but 2 arguments were supplied | ||
foo(; //~ ERROR this function takes 0 arguments but 1 argument was supplied | ||
//~^ ERROR expected one of | ||
} //~ ERROR mismatched closing delimiter |
62 changes: 62 additions & 0 deletions
62
tests/ui/argument-suggestions/issue-108242-semicolon-recovery.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `foo` | ||
--> $DIR/issue-108242-semicolon-recovery.rs:4:5 | ||
| | ||
LL | foo(; | ||
| - | ||
| | | ||
| expected one of `)`, `,`, `.`, `?`, or an operator | ||
| help: missing `,` | ||
LL | foo(; | ||
| ^^^ unexpected token | ||
|
||
error: mismatched closing delimiter: `}` | ||
--> $DIR/issue-108242-semicolon-recovery.rs:4:8 | ||
| | ||
LL | fn main() { | ||
| - closing delimiter possibly meant for this | ||
LL | foo(; | ||
LL | foo(; | ||
| ^ unclosed delimiter | ||
LL | | ||
LL | } | ||
| ^ mismatched closing delimiter | ||
|
||
error[E0061]: this function takes 0 arguments but 1 argument was supplied | ||
--> $DIR/issue-108242-semicolon-recovery.rs:4:5 | ||
| | ||
LL | foo(; | ||
| ^^^ - | ||
| | | ||
| unexpected argument | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/issue-108242-semicolon-recovery.rs:1:4 | ||
| | ||
LL | fn foo() {} | ||
| ^^^ | ||
|
||
error[E0061]: this function takes 0 arguments but 2 arguments were supplied | ||
--> $DIR/issue-108242-semicolon-recovery.rs:3:5 | ||
| | ||
LL | foo(; | ||
| ^^^ - unexpected argument | ||
LL | / foo(; | ||
LL | | | ||
LL | | } | ||
| |_- unexpected argument of type `()` | ||
| | ||
note: function defined here | ||
--> $DIR/issue-108242-semicolon-recovery.rs:1:4 | ||
| | ||
LL | fn foo() {} | ||
| ^^^ | ||
help: remove the extra arguments | ||
| | ||
LL - foo(; | ||
LL + foo( | ||
| | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0061`. |