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

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

@Centril

This comment has been minimized.

Copy link
Member

commented Oct 1, 2019

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

@estebank

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

commented Oct 1, 2019

📌 Commit e42a0be has been approved by estebank

@estebank

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Oct 2, 2019

Needs rebase, @bors r-

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>
@davidtwco davidtwco force-pushed the davidtwco:issue-64252-self-type-help branch from e42a0be to 2537a8a Oct 2, 2019
@Centril

This comment has been minimized.

Copy link
Member

commented Oct 2, 2019

@bors r=Centril,estebank

@bors

This comment has been minimized.

Copy link
Contributor

commented Oct 2, 2019

📌 Commit 2537a8a has been approved by Centril,estebank

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
bors added a commit that referenced this pull request Oct 2, 2019
Rollup of 7 pull requests

Successful merges:

 - #64749 (Fix most remaining Polonius test differences)
 - #64906 (Add support for `const unsafe? extern fn`)
 - #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
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 Centril referenced this pull request Oct 2, 2019
bors added a commit that referenced this pull request Oct 2, 2019
Rollup of 7 pull requests

Successful merges:

 - #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)
 - #64999 (extract expected return type for async fn generators)
 - #65010 (Compare `primary` with maximum of `children`s' line num instead of dropping it)

Failed merges:

r? @ghost
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
@Centril Centril referenced this pull request Oct 3, 2019
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
3 of 4 checks passed
3 of 4 checks passed
pr
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
@davidtwco davidtwco deleted the davidtwco:issue-64252-self-type-help branch Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.