about summary refs log tree commit diff
path: root/src/test/ui/parser
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2019-10-01 15:17:50 +0100
committerDavid Wood <david@davidtw.co>2019-10-02 09:51:27 +0100
commit2537a8aa7a44d76b3345b98f394f6d2744f3a9cc (patch)
treeee4189157d797893692099a1220c87a74b7973cc /src/test/ui/parser
parentff191b54cc8a95e3bfc7ae5f8f9984f934758165 (diff)
downloadrust-2537a8aa7a44d76b3345b98f394f6d2744f3a9cc.tar.gz
rust-2537a8aa7a44d76b3345b98f394f6d2744f3a9cc.zip
syntax: improve parameter without type suggestions
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>
Diffstat (limited to 'src/test/ui/parser')
-rw-r--r--src/test/ui/parser/pat-lt-bracket-2.stderr6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/test/ui/parser/pat-lt-bracket-2.stderr b/src/test/ui/parser/pat-lt-bracket-2.stderr
index dbc8d0f5865..2191e31ad1f 100644
--- a/src/test/ui/parser/pat-lt-bracket-2.stderr
+++ b/src/test/ui/parser/pat-lt-bracket-2.stderr
@@ -3,6 +3,12 @@ error: expected one of `:`, `@`, or `|`, found `<`
    |
 LL | fn a(B<) {}
    |       ^ expected one of `:`, `@`, or `|` here
+   |
+   = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
+help: if this is a type, explicitly ignore the parameter name
+   |
+LL | fn a(_: B<) {}
+   |      ^^^^
 
 error: aborting due to previous error