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

Fix precise capturing suggestion for hidden regions when we have APITs #127664

Merged

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 12, 2024

Suggests to turn APITs into type parameters so they can be named in precise capturing syntax for hidden type lifetime errors. We also note that it may change the API.

This is currently done via a note and a suggestion, which feels a bit redundant, but I wasn't totally sure of a better alternative for the presentation.

Code is kind of a mess but there's a lot of cases to consider. Happy to iterate on this if you think the approach is too messy.

Based on #127619, only the last commit is relevant.
r? oli-obk

Tracking:

@rustbot rustbot added 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 Jul 12, 2024
@bors
Copy link
Contributor

bors commented Jul 13, 2024

☔ The latest upstream changes (presumably #127665) made this pull request unmergeable. Please resolve the merge conflicts.

@traviscross traviscross added the F-precise_capturing `#![feature(precise_capturing)]` label Jul 14, 2024
Comment on lines 1383 to 1387
// This currently involves stripping the `impl` from the name of
// the parameter, since APITs are always named after how they are
// rendered in the AST. This sucks! But to recreate the bound list
// from the APIT itself would be miserable, so we're stuck with
// this for now!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also adjust the spans in the future to not include the impl if that is nice diagnostic wise on other diagnostics, too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there are likely problems with not returning the full span (e.g. for deletion, or renaming). Like, we already need to use the full span in this diagnostic to suggest renaming impl Trait into T.

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me after a rebase

@compiler-errors compiler-errors force-pushed the precise-capturing-better-sugg-apit branch from 5a1a949 to 1d40d4c Compare July 17, 2024 14:53
@compiler-errors
Copy link
Member Author

@bors r=oli-obk rollup

@bors
Copy link
Contributor

bors commented Jul 17, 2024

📌 Commit 1d40d4c has been approved by oli-obk

It is now in the queue for this repository.

@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 Jul 17, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 17, 2024
…better-sugg-apit, r=oli-obk

Fix precise capturing suggestion for hidden regions when we have APITs

Suggests to turn APITs into type parameters so they can be named in precise capturing syntax for hidden type lifetime errors. We also note that it may change the API.

This is currently done via a note *and* a suggestion, which feels a bit redundant, but I wasn't totally sure of a better alternative for the presentation.

Code is kind of a mess but there's a lot of cases to consider. Happy to iterate on this if you think the approach is too messy.

Based on rust-lang#127619, only the last commit is relevant.
r? oli-obk

Tracking:

- rust-lang#123432
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#127542 ([`macro_metavar_expr_concat`] Add support for literals)
 - rust-lang#127652 (Unignore cg_gcc fmt)
 - rust-lang#127664 (Fix precise capturing suggestion for hidden regions when we have APITs)
 - rust-lang#127806 (Some parser improvements)
 - rust-lang#127828 (Commonize `uname -m` results for `aarch64` in docker runner)
 - rust-lang#127845 (unix: break `stack_overflow::install_main_guard` into smaller fn)
 - rust-lang#127854 (Add internal lint for detecting non-glob imports of `rustc_type_ir::inherent`)
 - rust-lang#127861 (Document the column numbers for the dbg! macro)
 - rust-lang#127875 (style-guide: Clarify version-sorting)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
Rollup of 9 pull requests

Successful merges:

 - rust-lang#127542 ([`macro_metavar_expr_concat`] Add support for literals)
 - rust-lang#127652 (Unignore cg_gcc fmt)
 - rust-lang#127664 (Fix precise capturing suggestion for hidden regions when we have APITs)
 - rust-lang#127806 (Some parser improvements)
 - rust-lang#127828 (Commonize `uname -m` results for `aarch64` in docker runner)
 - rust-lang#127845 (unix: break `stack_overflow::install_main_guard` into smaller fn)
 - rust-lang#127859 (ptr::metadata: avoid references to extern types)
 - rust-lang#127861 (Document the column numbers for the dbg! macro)
 - rust-lang#127875 (style-guide: Clarify version-sorting)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b5771e7 into rust-lang:master Jul 18, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 18, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 18, 2024
Rollup merge of rust-lang#127664 - compiler-errors:precise-capturing-better-sugg-apit, r=oli-obk

Fix precise capturing suggestion for hidden regions when we have APITs

Suggests to turn APITs into type parameters so they can be named in precise capturing syntax for hidden type lifetime errors. We also note that it may change the API.

This is currently done via a note *and* a suggestion, which feels a bit redundant, but I wasn't totally sure of a better alternative for the presentation.

Code is kind of a mess but there's a lot of cases to consider. Happy to iterate on this if you think the approach is too messy.

Based on rust-lang#127619, only the last commit is relevant.
r? oli-obk

Tracking:

- rust-lang#123432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-precise_capturing `#![feature(precise_capturing)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant 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.

5 participants