-
Notifications
You must be signed in to change notification settings - Fork 13.3k
add error message for c# style named arguments #118733
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
fn main() { | ||
let my = monad_bind(mx, T: Try); //~ ERROR invalid `struct` delimiters or `fn` call arguments | ||
let my = monad_bind(mx, T: Try); | ||
//~^ ERROR expected identifier, found `:` | ||
//~| ERROR cannot find value `mx` | ||
//~| ERROR cannot find value `Try` | ||
//~| ERROR cannot find function `monad_bind` | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,18 +1,33 @@ | ||
error: invalid `struct` delimiters or `fn` call arguments | ||
--> $DIR/issue-111416.rs:2:14 | ||
error: expected identifier, found `:` | ||
--> $DIR/issue-111416.rs:2:30 | ||
| | ||
LL | let my = monad_bind(mx, T: Try); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: if `monad_bind` is a struct, use braces as delimiters | ||
| ^ expected identifier | ||
| | ||
LL | let my = monad_bind { mx, T: Try }; | ||
| ~ ~ | ||
help: if `monad_bind` is a function, use the arguments directly | ||
help: if this is a parameter, remove the name for the parameter | ||
| | ||
LL - let my = monad_bind(mx, T: Try); | ||
LL + let my = monad_bind(mx, Try); | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
error[E0425]: cannot find value `mx` in this scope | ||
--> $DIR/issue-111416.rs:2:25 | ||
| | ||
LL | let my = monad_bind(mx, T: Try); | ||
| ^^ not found in this scope | ||
|
||
error[E0425]: cannot find value `Try` in this scope | ||
--> $DIR/issue-111416.rs:2:32 | ||
| | ||
LL | let my = monad_bind(mx, T: Try); | ||
| ^^^ not found in this scope | ||
|
||
error[E0425]: cannot find function `monad_bind` in this scope | ||
--> $DIR/issue-111416.rs:2:14 | ||
| | ||
LL | let my = monad_bind(mx, T: Try); | ||
| ^^^^^^^^^^ not found in this scope | ||
nouritsu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
This file contains hidden or 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 |
---|---|---|
@@ -1,18 +1,37 @@ | ||
error: invalid `struct` delimiters or `fn` call arguments | ||
--> $DIR/issue-34255-1.rs:8:5 | ||
error: expected expression, found `:` | ||
--> $DIR/issue-34255-1.rs:8:22 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: if `Test::Drill` is a struct, use braces as delimiters | ||
| ^ expected expression | ||
| | ||
LL | Test::Drill { field: 42 }; | ||
| ~ ~ | ||
help: if `Test::Drill` is a function, use the arguments directly | ||
help: if this is a parameter, remove the name for the parameter | ||
| | ||
LL - Test::Drill(field: 42); | ||
LL + Test::Drill(42); | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `:` | ||
--> $DIR/issue-34255-1.rs:8:22 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| ^ | ||
| | | ||
| expected one of 8 possible tokens | ||
| help: missing `,` | ||
|
||
error[E0425]: cannot find value `field` in this scope | ||
--> $DIR/issue-34255-1.rs:8:17 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| ^^^^^ not found in this scope | ||
|
||
error[E0533]: expected value, found struct variant `Test::Drill` | ||
--> $DIR/issue-34255-1.rs:8:5 | ||
| | ||
LL | Test::Drill(field: 42); | ||
| ^^^^^^^^^^^ not a value | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
Some errors have detailed explanations: E0425, E0533. | ||
For more information about an error, try `rustc --explain E0425`. |
This file contains hidden or 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 |
---|---|---|
@@ -1,22 +1,55 @@ | ||
error: invalid `struct` delimiters or `fn` call arguments | ||
--> $DIR/issue-44406.rs:3:9 | ||
error: expected expression, found `:` | ||
--> $DIR/issue-44406.rs:3:16 | ||
| | ||
LL | bar(baz: $rest) | ||
| ^^^^^^^^^^^^^^^ | ||
| ^ expected expression | ||
... | ||
LL | foo!(true); | ||
| ---------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: if `bar` is a struct, use braces as delimiters | ||
| | ||
LL | bar { baz: $rest } | ||
| ~ ~ | ||
help: if `bar` is a function, use the arguments directly | ||
help: if this is a parameter, remove the name for the parameter | ||
| | ||
LL - bar(baz: $rest) | ||
LL + bar(: $rest) | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `:` | ||
--> $DIR/issue-44406.rs:3:16 | ||
| | ||
LL | bar(baz: $rest) | ||
| ^ | ||
| | | ||
| expected one of 8 possible tokens | ||
| help: missing `,` | ||
... | ||
LL | foo!(true); | ||
| ---------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0425]: cannot find value `baz` in this scope | ||
--> $DIR/issue-44406.rs:3:13 | ||
| | ||
LL | bar(baz: $rest) | ||
| ^^^ not found in this scope | ||
... | ||
LL | foo!(true); | ||
| ---------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0425]: cannot find function `bar` in this scope | ||
--> $DIR/issue-44406.rs:3:9 | ||
| | ||
LL | bar(baz: $rest) | ||
| ^^^ not found in this scope | ||
... | ||
LL | foo!(true); | ||
| ---------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |
This file contains hidden or 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 |
---|---|---|
@@ -1,14 +1,35 @@ | ||
error: expected expression, found `:` | ||
--> $DIR/issue-91461.rs:2:8 | ||
| | ||
LL | a(_:b:,) | ||
| ^ expected expression | ||
| | ||
help: if this is a parameter, remove the name for the parameter | ||
| | ||
LL - a(_:b:,) | ||
LL + a(b:,) | ||
| | ||
|
||
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:` | ||
--> $DIR/issue-91461.rs:2:8 | ||
| | ||
LL | a(_:b:,) | ||
| ^ | ||
| | | ||
| expected one of `)`, `,`, `.`, `?`, or an operator | ||
| help: missing `,` | ||
|
||
error: expected identifier, found reserved identifier `_` | ||
--> $DIR/issue-91461.rs:2:7 | ||
| | ||
LL | a(_:b:,) | ||
| ^ expected identifier, found reserved identifier | ||
|
||
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `:` | ||
--> $DIR/issue-91461.rs:2:8 | ||
error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `:` | ||
--> $DIR/issue-91461.rs:2:10 | ||
| | ||
LL | a(_:b:,) | ||
| ^ expected one of `)`, `,`, `.`, `?`, or an operator | ||
| ^ expected one of 8 possible tokens | ||
|
||
error: aborting due to 2 previous errors | ||
error: aborting due to 4 previous errors | ||
|
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Still sad of losing this suggestion.
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.
Would it be possible for me to add on this suggestion along with the named arguments error? something like -
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.
Yes, you could likely include it to. Look at the existing one because there's some subtlety here: this suggestion is only potentially valid if all the previous expressions in the argument list are either an ident (like
mx
) or the type ascription (which is no longer represented in the expression syntax tree, theT: Try
), so we only emit the that suggestion if when encountering the problem, all prior args are just idents. We would also want to remove the older logic as now it won't trigger anymore.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.
I understand, I'll take a look at the existing solution and try to adapt it to this. Can we go over other changes that should be made to get all the tests to pass?