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:
bors 2019-06-03 05:40:53 +00:00
commit c57ed9d947
8 changed files with 182 additions and 40 deletions

View file

@ -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 `@`

View file

@ -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) {}
| -----^

View file

@ -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