Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax: improve parameter without type suggestions #64959

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

davidtwco
Copy link
Member

@davidtwco davidtwco commented Oct 1, 2019

Fixes #64252.

This PR 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 :.

r? @Centril
cc @estebank @yoshuawuyts

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 1, 2019
@Centril
Copy link
Contributor

Centril commented Oct 1, 2019

Didn't quite make it today. Giving this a look tomorrow =)

@estebank
Copy link
Contributor

estebank commented Oct 1, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Oct 1, 2019

📌 Commit e42a0be12c24a247992530938172a81b508e0dde has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 1, 2019
@estebank
Copy link
Contributor

estebank commented Oct 1, 2019

r? @estebank

@rust-highfive rust-highfive assigned estebank and unassigned Centril Oct 1, 2019
bors added a commit that referenced this pull request Oct 2, 2019
Rollup of 11 pull requests

Successful merges:

 - #64649 (Avoid ICE on return outside of fn with literal array)
 - #64722 (Make all alt builders produce parallel-enabled compilers)
 - #64801 (Avoid `chain()` in `find_constraint_paths_between_regions()`.)
 - #64805 (Still more `ObligationForest` improvements.)
 - #64840 (SelfProfiler API refactoring and part one of event review)
 - #64885 (use try_fold instead of try_for_each to reduce compile time)
 - #64942 (Fix clippy warnings)
 - #64952 (Update cargo.)
 - #64974 (Fix zebra-striping in generic dataflow visualization)
 - #64978 (Fully clear `HandlerInner` in `Handler::reset_err_count`)
 - #64979 (Update books)

Failed merges:

 - #64959 (syntax: improve parameter without type suggestions)

r? @ghost
@tmandry
Copy link
Member

tmandry commented Oct 2, 2019

Needs rebase, @bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 2, 2019
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 <[email protected]>
@davidtwco davidtwco force-pushed the issue-64252-self-type-help branch from e42a0be to 2537a8a Compare October 2, 2019 09:11
@Centril
Copy link
Contributor

Centril commented Oct 2, 2019

@bors r=Centril,estebank

@bors
Copy link
Contributor

bors commented Oct 2, 2019

📌 Commit 2537a8a has been approved by Centril,estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 2, 2019
Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 2, 2019
…p, r=Centril,estebank

syntax: improve parameter without type suggestions

Fixes rust-lang#64252.

This PR 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 `:`.

r? @Centril
cc @estebank @yoshuawuyts
Centril added a commit to Centril/rust that referenced this pull request Oct 2, 2019
…p, r=Centril,estebank

syntax: improve parameter without type suggestions

Fixes rust-lang#64252.

This PR 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 `:`.

r? @Centril
cc @estebank @yoshuawuyts
Centril added a commit to Centril/rust that referenced this pull request Oct 3, 2019
…p, r=Centril,estebank

syntax: improve parameter without type suggestions

Fixes rust-lang#64252.

This PR 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 `:`.

r? @Centril
cc @estebank @yoshuawuyts
bors added a commit that referenced this pull request Oct 3, 2019
Rollup of 7 pull requests

Successful merges:

 - #63678 (Improve HRTB error span when -Zno-leak-check is used)
 - #64931 (Reword E0392 slightly)
 - #64959 (syntax: improve parameter without type suggestions)
 - #64975 (Implement Clone::clone_from for LinkedList)
 - #64993 (BacktraceStatus: add Eq impl)
 - #64998 (Filter out RLS output directories on tidy runs)
 - #65010 (Compare `primary` with maximum of `children`s' line num instead of dropping it)

Failed merges:

r? @ghost
@bors bors merged commit 2537a8a into rust-lang:master Oct 3, 2019
@davidtwco davidtwco deleted the issue-64252-self-type-help branch October 3, 2019 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diagnostics: help text for missing left-hand side in arbitrary self type
6 participants