Uh oh!
There was an error while loading. Please reload this page.
Remap impl-trait lifetimes on HIR instead of AST lowering - #129383
Conversation
petrochenkov
commented
Aug 22, 2024
8127ba2 to
d334955Compare
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
1729436 to
92cd183Compare
This comment was marked as resolved.
This comment was marked as resolved.
c2ad831 to
12b94cdComparerustbot
commented
Oct 5, 2024
HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment was marked as resolved.
This comment was marked as resolved.
bors
commented
Oct 15, 2024
☔ The latest upstream changes (presumably #131724) made this pull request unmergeable. Please resolve the merge conflicts. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Oct 24, 2024
Reviewed. |
cjgillot
commented
Oct 26, 2024
@compiler-errors do you mind taking a look? I'm not sure I correctly implemented the logic around |
| //~^ ERROR ['_: o] | ||
| //~| ERROR ['_: o] | ||
| //~| ERROR `impl Trait` captures lifetime parameter | ||
| //~^ ERROR [] |
There was a problem hiding this comment.
Ah, this doesn't seem right. Or at least, it changes the semantics of what we mean by "capture all in-scope parameters" for nested opaques.
Without having yet looked at the code, I assume what's happening here is that the nested opaque doesn't see any nested lifetimes because of the use<> from the outer opaque, which shadows the lifetimes that the inner opaque considers to be in-scope. Is that right?
There was a problem hiding this comment.
I'm not actually certain if https://rust-lang.github.io/rfcs/3617-precise-capturing.html#summary prescribes what should happen here 🤔 -- it doesn't seem to do so, after having done a brief scan.
There was a problem hiding this comment.
I changed the code to recurse and capture all in-scope lifetimes when we have nested opaques.
There was a problem hiding this comment.
@compiler-errors I have re-implemented the resolution to walk the scopes and not stop at the closest opaque. Is this closer to what you had in mind?
There was a problem hiding this comment.
Yeah, I believe so. If in the future we want opaque type captures to stop at the closest opaque, we can do so; that actually seems like the right behavior, but this should mean there are no observable changes.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
compiler-errors
commented
Oct 30, 2024
r=me,petrochenkov after rebase |
cjgillot
commented
Oct 30, 2024
@bors r=compiler-errors,petrochenkov rollup=iffy |
bors
commented
Oct 30, 2024
…kingjubilee Rollup of 5 pull requests Successful merges: - rust-lang#129383 (Remap impl-trait lifetimes on HIR instead of AST lowering) - rust-lang#132210 (rustdoc: make doctest span tweak a 2024 edition change) - rust-lang#132246 (Rename `rustc_abi::Abi` to `BackendRepr`) - rust-lang#132267 (force-recompile library changes on download-rustc="if-unchanged") - rust-lang#132344 (Merge `HostPolarity` and `BoundConstness`) Failed merges: - rust-lang#132347 (Remove `ValueAnalysis` and `ValueAnalysisWrapper`.) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129383 - cjgillot:opaque-noremap, r=compiler-errors,petrochenkov Remap impl-trait lifetimes on HIR instead of AST lowering Current AST->HIR lowering goes out of its way to remap lifetimes for opaque types. This is complicated and leaks into upstream and downstream code. This PR stops trying to be clever during lowering, and prefers to do this remapping during the HIR->ty lowering. The remapping computation easily fits into the bound var resolution code. Its result can be used in by `generics_of` and `hir_ty_lowering::new_opaque` to add the proper parameters and arguments. See an example on the doc for query `opaque_captured_lifetimes`. Based on rust-lang#129244Fixesrust-lang#125249Fixesrust-lang#126850 cc `@compiler-errors` `@spastorino` r? `@petrochenkov`
Current AST->HIR lowering goes out of its way to remap lifetimes for opaque types. This is complicated and leaks into upstream and downstream code.
This PR stops trying to be clever during lowering, and prefers to do this remapping during the HIR->ty lowering. The remapping computation easily fits into the bound var resolution code. Its result can be used in by
generics_ofandhir_ty_lowering::new_opaqueto add the proper parameters and arguments.See an example on the doc for query
opaque_captured_lifetimes.Based on #129244
Fixes#125249
Fixes#126850
cc @compiler-errors@spastorino
r? @petrochenkov