-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in which the E0618 "expected function" diagnostic gets a makeover #55862
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,16 @@ LL | |y| x + y | |
error[E0618]: expected function, found `()` | ||
--> $DIR/issue-20862.rs:17:13 | ||
| | ||
LL | let x = foo(5)(2); | ||
| ^^^^^^^^^ not a function | ||
LL | / fn foo(x: i32) { | ||
LL | | |y| x + y | ||
LL | | //~^ ERROR: mismatched types | ||
LL | | } | ||
| |_- `foo` defined here returns `()` | ||
... | ||
LL | let x = foo(5)(2); | ||
| ^^^^^^--- | ||
| | | ||
| call expression requires function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder how muddled it'd be if you kept the "not a function" label pointing at the primary span. Even better, detecting chained calls would be nice to provide a custom message (follow up work that needs more thought put into it):
|
||
|
||
error: aborting due to 2 previous errors | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,9 @@ LL | let y = 42; | |
| - `{integer}` defined here | ||
LL | let x = y.; //~ ERROR unexpected token | ||
LL | let x = y.(); //~ ERROR unexpected token | ||
| ^^^^ not a function | ||
| ^--- | ||
| | | ||
| call expression requires function | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised at the parser taking this as a function call (but it's not problematic). |
||
|
||
error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields | ||
--> $DIR/parse-error-correct.rs:21:15 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fn vindictive() -> bool { true } | ||
|
||
fn perfidy() -> (i32, i32) { | ||
vindictive() //~ ERROR expected function, found `bool` | ||
(1, 2) | ||
} | ||
|
||
fn main() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍