-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Make opaque types regular HIR nodes #129244
Conversation
rustbot has assigned @michaelwoerister. Use |
HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
tests/ui/async-await/multiple-lifetimes/ret-impl-trait-one.stderr
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
Ignoring all the ID parenting questions, the change looks reasonable to me because
Regarding DefIds, HirIds and parenting, the change is not strictly necessary (#129023 (comment)) to fix the HIR ownership issues, and I'd like to discuss that topic separately (see my other messages in #129023). |
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
Until I fix clippy: |
This comment has been minimized.
This comment has been minimized.
Make opaque types regular HIR nodes Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead. I haven't gone through all the test changes yet, so there may be a few surprises. Many thanks to `@camelid` for the first draft. Fixes rust-lang#129023 Fixes rust-lang#129099 Fixes rust-lang#125843 Fixes rust-lang#119716 Fixes rust-lang#121422
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #126161) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me. The fact that opaques were separate items was a constant source of annoyance and I'm glad to see this being settled.
I reviewed everything and only had a few questions. I am not totally caught up on the DefId
mismatch problem, was that resolved?
This needs a rebase, and I'd like to take a quick look afterwards, so please ping me when that happens.
@@ -686,22 +678,19 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { | |||
hir::TyKind::Ref(lifetime_ref, ref mt) => { | |||
self.visit_lifetime(lifetime_ref); | |||
let scope = Scope::ObjectLifetimeDefault { | |||
lifetime: self.map.defs.get(&lifetime_ref.hir_id).cloned(), | |||
lifetime: self.map.defs.get(&lifetime_ref.hir_id.local_id).cloned(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way we can assert that the lifetime's OwnerId
is the same owner that we're resolving here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And elsewhere throughout this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm possibly just being paranoid, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this is useful. We don't track the root OwnerId
, so we'd need to add it, for limited benefit IMHO.
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
@bors r+ rollup=never |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5a4ee43): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary -1.9%, secondary -1.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary -2.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 770.7s -> 774.178s (0.45%) |
Make opaque types regular HIR nodes Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead. I haven't gone through all the test changes yet, so there may be a few surprises. Many thanks to `@camelid` for the first draft. Fixes rust-lang#129023 Fixes rust-lang#129099 Fixes rust-lang#125843 Fixes rust-lang#119716 Fixes rust-lang#121422
…r-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#129244 Fixes rust-lang#125249 Fixes rust-lang#126850 cc `@compiler-errors` `@spastorino` r? `@petrochenkov`
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#129244 Fixes rust-lang#125249 Fixes rust-lang#126850 cc `@compiler-errors` `@spastorino` r? `@petrochenkov`
Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead.
I haven't gone through all the test changes yet, so there may be a few surprises.
Many thanks to @camelid for the first draft.
Fixes #129023
Fixes #129099
Fixes #125843
Fixes #119716
Fixes #121422