Skip to content

Recover from function pointer types with generic parameter list - #104223

Merged
bors merged 1 commit into
rust-lang:masterfrom
fmease:recover-fn-ptr-with-generics
Nov 15, 2022
Merged

Recover from function pointer types with generic parameter list#104223
bors merged 1 commit into
rust-lang:masterfrom
fmease:recover-fn-ptr-with-generics

Conversation

@fmease

@fmeasefmease commented Nov 10, 2022

Copy link
Copy Markdown
Member

Give a more helpful error when encountering function pointer types with a generic parameter list like fn<'a>(&'a str) -> bool or fn<T>(T) -> T and suggest moving lifetime parameters to a for<> parameter list.

I've added a bunch of extra code to properly handle (unlikely?) corner cases like for<'a> fn<'b>() (where there already exists a for<> parameter list) correctly suggesting for<'a, 'b> fn() (merging the lists). If you deem this useless, I can simplify the code by suggesting nothing at all in this case.

I am quite open to suggestions regarding the wording of the diagnostic messages.

Fixes#103487.
@rustbot label A-diagnostics
r? diagnostics

@rustbotrustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2022
@rustbot

Copy link
Copy Markdown
Collaborator

rustc_error_messages was changed

cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki

@rustbotrustbot added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 10, 2022
@fmeasefmease changed the title Recover from fn ptr tys with generic param listRecover from function pointer types with generic parameter listNov 10, 2022
Comment threadcompiler/rustc_parse/src/parser/ty.rs Outdated
@fmease
fmeaseforce-pushed the recover-fn-ptr-with-generics branch 2 times, most recently from 5fe8cf1 to bbe8f1dCompareNovember 10, 2022 11:46
@estebank

Copy link
Copy Markdown
Contributor

r? @estebank
@bors r+

@bors

bors commented Nov 11, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit bbe8f1d56588bc85f450fec2e041066a417f8f03 has been approved by estebank

It is now in the queue for this repository.

@rustbotrustbot assigned estebank and unassigned davidtwcoNov 11, 2022
@borsbors 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 Nov 11, 2022
@bors

This comment was marked as resolved.

@borsbors 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 Nov 11, 2022
@fmease
fmeaseforce-pushed the recover-fn-ptr-with-generics branch from bbe8f1d to c2b906bCompareNovember 11, 2022 12:43
@fmease

Copy link
Copy Markdown
MemberAuthor

@rustbot reviewer

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 11, 2022
@davidtwco

Copy link
Copy Markdown
Member

@bors r=estebank

@bors

bors commented Nov 14, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit c2b906b has been approved by estebank

It is now in the queue for this repository.

@borsbors 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 Nov 14, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 14, 2022
…s, r=estebank
Recover from function pointer types with generic parameter list
Give a more helpful error when encountering function pointer types with a generic parameter list like `fn<'a>(&'a str) -> bool` or `fn<T>(T) -> T` and suggest moving lifetime parameters to a `for<>` parameter list.
I've added a bunch of extra code to properly handle (unlikely?) corner cases like `for<'a> fn<'b>()` (where there already exists a `for<>` parameter list) correctly suggesting `for<'a, 'b> fn()` (merging the lists). If you deem this useless, I can simplify the code by suggesting nothing at all in this case.
I am quite open to suggestions regarding the wording of the diagnostic messages.
Fixesrust-lang#103487.
`@rustbot` label A-diagnostics
r? diagnostics
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 15, 2022
…iaskrgr
Rollup of 11 pull requests
Successful merges:
- rust-lang#101967 (Move `unix_socket_abstract` feature API to `SocketAddrExt`.)
- rust-lang#102470 (Stabilize const char convert)
- rust-lang#104223 (Recover from function pointer types with generic parameter list)
- rust-lang#104229 (Don't print full paths in overlap errors)
- rust-lang#104294 (Don't ICE with inline const errors during MIR build)
- rust-lang#104332 (Fixed some `_i32` notation in `maybe_uninit`’s doc)
- rust-lang#104349 (fix some typos in comments)
- rust-lang#104350 (Fix x finding Python on Windows)
- rust-lang#104356 (interpret: make check_mplace public)
- rust-lang#104364 (rustdoc: Resolve doc links in external traits having local impls)
- rust-lang#104378 (Bump chalk to v0.87)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit a86bdb4 into rust-lang:masterNov 15, 2022
@rustbotrustbot added this to the 1.67.0 milestone Nov 15, 2022
@fmease
fmease deleted the recover-fn-ptr-with-generics branch November 15, 2022 13:41
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-translationArea: Translation infrastructure, and migrating existing diagnostics to SessionDiagnosticS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a better error message for function pointers with generic parameters

5 participants

@fmease@rustbot@estebank@bors@davidtwco