Auto merge of #61331 - estebank:fn-arg-parse-recovery, r=varkor
Recover gracefully from argument with missing type or param name
This commit is contained in:
commit
c57ed9d947
8 changed files with 182 additions and 40 deletions
|
|
@ -20,6 +20,8 @@ fn pattern((i32, i32) (a, b)) {}
|
|||
|
||||
fn fizz(i32) {}
|
||||
//~^ ERROR expected one of `:` or `@`
|
||||
//~| HELP if this was a parameter name, give it a type
|
||||
//~| HELP if this is a type, explicitly ignore the parameter name
|
||||
|
||||
fn missing_colon(quux S) {}
|
||||
//~^ ERROR expected one of `:` or `@`
|
||||
|
|
|
|||
|
|
@ -33,9 +33,19 @@ error: expected one of `:` or `@`, found `)`
|
|||
|
|
||||
LL | fn fizz(i32) {}
|
||||
| ^ expected one of `:` or `@` here
|
||||
|
|
||||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||
help: if this was a parameter name, give it a type
|
||||
|
|
||||
LL | fn fizz(i32: TypeName) {}
|
||||
| ^^^^^^^^^^^^^
|
||||
help: if this is a type, explicitly ignore the parameter name
|
||||
|
|
||||
LL | fn fizz(_: i32) {}
|
||||
| ^^^^^^
|
||||
|
||||
error: expected one of `:` or `@`, found `S`
|
||||
--> $DIR/inverted-parameters.rs:24:23
|
||||
--> $DIR/inverted-parameters.rs:26:23
|
||||
|
|
||||
LL | fn missing_colon(quux S) {}
|
||||
| -----^
|
||||
|
|
|
|||
|
|
@ -3,6 +3,16 @@ error: expected one of `:` or `@`, found `)`
|
|||
|
|
||||
LL | fn foo(x) {
|
||||
| ^ expected one of `:` or `@` here
|
||||
|
|
||||
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
||||
help: if this was a parameter name, give it a type
|
||||
|
|
||||
LL | fn foo(x: TypeName) {
|
||||
| ^^^^^^^^^^^
|
||||
help: if this is a type, explicitly ignore the parameter name
|
||||
|
|
||||
LL | fn foo(_: x) {
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue