2537a8aa7a
This commit improves the suggestions provided when function parameters do not have types: - A new suggestion is added for arbitrary self types, which suggests adding `self: ` before the type. - Existing suggestions are now provided when a `<` is found where a `:` was expected (previously only `,` and `)` or trait items), this gives suggestions in the case where the unnamed parameter type is generic in a free function. - The suggestion that a type name be provided (e.g. `fn foo(HashMap<u32>)` -> `fn foo(HashMap: TypeName<u32>)`) will no longer occur when a `<` was found instead of `:`. - The ident will not be used for recovery when a `<` was found instead of `:`. Signed-off-by: David Wood <david@davidtw.co>
75 lines
2.7 KiB
Plaintext
75 lines
2.7 KiB
Plaintext
error: expected one of `:`, `@`, or `|`, found `)`
|
|
--> $DIR/anon-params-denied-2018.rs:6:15
|
|
|
|
|
LL | fn foo(i32);
|
|
| ^ expected one of `:`, `@`, or `|` here
|
|
|
|
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
|
help: if this is a `self` type, give it a parameter name
|
|
|
|
|
LL | fn foo(self: i32);
|
|
| ^^^^^^^^^
|
|
help: if this was a parameter name, give it a type
|
|
|
|
|
LL | fn foo(i32: TypeName);
|
|
| ^^^^^^^^^^^^^
|
|
help: if this is a type, explicitly ignore the parameter name
|
|
|
|
|
LL | fn foo(_: i32);
|
|
| ^^^^^^
|
|
|
|
error: expected one of `:`, `@`, or `|`, found `,`
|
|
--> $DIR/anon-params-denied-2018.rs:8:36
|
|
|
|
|
LL | fn bar_with_default_impl(String, String) {}
|
|
| ^ expected one of `:`, `@`, or `|` here
|
|
|
|
|
= note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
|
|
help: if this is a `self` type, give it a parameter name
|
|
|
|
|
LL | fn bar_with_default_impl(self: String, String) {}
|
|
| ^^^^^^^^^^^^
|
|
help: if this was a parameter name, give it a type
|
|
|
|
|
LL | fn bar_with_default_impl(String: TypeName, String) {}
|
|
| ^^^^^^^^^^^^^^^^
|
|
help: if this is a type, explicitly ignore the parameter name
|
|
|
|
|
LL | fn bar_with_default_impl(_: String, String) {}
|
|
| ^^^^^^^^^
|
|
|
|
error: expected one of `:`, `@`, or `|`, found `)`
|
|
--> $DIR/anon-params-denied-2018.rs:8:44
|
|
|
|
|
LL | fn bar_with_default_impl(String, String) {}
|
|
| ^ 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 bar_with_default_impl(String, String: TypeName) {}
|
|
| ^^^^^^^^^^^^^^^^
|
|
help: if this is a type, explicitly ignore the parameter name
|
|
|
|
|
LL | fn bar_with_default_impl(String, _: String) {}
|
|
| ^^^^^^^^^
|
|
|
|
error: expected one of `:`, `@`, or `|`, found `,`
|
|
--> $DIR/anon-params-denied-2018.rs:13:22
|
|
|
|
|
LL | fn baz(a:usize, b, c: usize) -> usize {
|
|
| ^ 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 baz(a:usize, b: TypeName, c: usize) -> usize {
|
|
| ^^^^^^^^^^^
|
|
help: if this is a type, explicitly ignore the parameter name
|
|
|
|
|
LL | fn baz(a:usize, _: b, c: usize) -> usize {
|
|
| ^^^^
|
|
|
|
error: aborting due to 4 previous errors
|
|
|