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:
parent
ff191b54cc
commit
2537a8aa7a
8 changed files with 93 additions and 8 deletions
|
@ -1212,6 +1212,7 @@ impl<'a> Parser<'a> {
|
|||
&mut err,
|
||||
pat,
|
||||
is_name_required,
|
||||
is_self_allowed,
|
||||
is_trait_item,
|
||||
) {
|
||||
err.emit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue