1
Fork 0

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>
This commit is contained in:
David Wood 2019-10-01 15:17:50 +01:00
parent ff191b54cc
commit 2537a8aa7a
No known key found for this signature in database
GPG key ID: 2592E76C87381FD9
8 changed files with 93 additions and 8 deletions

View file

@ -1212,6 +1212,7 @@ impl<'a> Parser<'a> {
&mut err,
pat,
is_name_required,
is_self_allowed,
is_trait_item,
) {
err.emit();