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

Suggest using precise capturing for hidden type that captures region #127619

Merged
merged 2 commits into from
Jul 13, 2024

Conversation

compiler-errors
Copy link
Member

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

Adjusts the "add + '_" suggestion for opaques to instead suggest adding or reusing the + use<> in the opaque.

r? oli-obk or please re-roll if you're busy!

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 11, 2024
|
LL | fn lifetime_in_hidden<'a>(x: &'a ()) -> impl Sized + use<> + 'a { x }
| ++++
LL | fn lifetime_in_hidden<'a>(x: &'a ()) -> impl Sized + use<'a> { x }
Copy link
Member Author

Choose a reason for hiding this comment

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

✨ yay

None,
Some(reg_info.def_id),
)
if infcx.tcx.features().precise_capturing {
Copy link
Member

Choose a reason for hiding this comment

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

Are there other cases where we suggest adding a feature if using nightly? If so, that might be better!

Copy link
Member Author

@compiler-errors compiler-errors Jul 11, 2024

Choose a reason for hiding this comment

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

Yeah, that could be done, though I think we plan on stabilizing precise capturing soon, so not totally certain about the value. Also, having things gated on "is this a nightly compiler" adds one more weird case that's impossible to test 😅

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 with or without nit if you think it's overkill

@compiler-errors
Copy link
Member Author

Actually I think I'll just open a follow-up that at least leaves a note explaining what needs to be done here to fix the code.

@bors r=oli-obk rollup

@bors
Copy link
Contributor

bors commented Jul 12, 2024

📌 Commit 42653c0 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 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 12, 2024
…kingjubilee

Rollup of 11 pull requests

Successful merges:

 - rust-lang#126502 (Ignore allocation bytes in some mir-opt tests)
 - rust-lang#126922 (add lint for inline asm labels that look like binary)
 - rust-lang#127209 (Added the `xop` target-feature and the `xop_target_feature` feature gate)
 - rust-lang#127310 (Fix import suggestion ice)
 - rust-lang#127338 (Migrate `extra-filename-with-temp-outputs` and `issue-85019-moved-src-dir` `run-make` tests to rmake)
 - rust-lang#127381 (Migrate `issue-83045`, `rustc-macro-dep-files` and `env-dep-info` `run-make` tests to rmake)
 - rust-lang#127535 (Fire unsafe_code lint on unsafe extern blocks)
 - rust-lang#127619 (Suggest using precise capturing for hidden type that captures region)
 - rust-lang#127631 (Remove `fully_normalize`)
 - rust-lang#127632 (Implement `precise_capturing` support for rustdoc)
 - rust-lang#127660 (Rename the internal `const_strlen` to just `strlen`)

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

Suggest using precise capturing for hidden type that captures region

Adjusts the "add `+ '_`" suggestion for opaques to instead suggest adding or reusing the `+ use<>` in the opaque.

r? oli-obk or please re-roll if you're busy!
@traviscross traviscross added the F-precise_capturing `#![feature(precise_capturing)]` label Jul 14, 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
tgross35 added a commit to tgross35/rust that referenced this pull request Jul 18, 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
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.

6 participants