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

Make opaque types regular HIR nodes #129244

Merged
merged 11 commits into from
Oct 5, 2024
Merged

Make opaque types regular HIR nodes #129244

merged 11 commits into from
Oct 5, 2024

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Aug 18, 2024

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

@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2024

r? @michaelwoerister

rustbot has assigned @michaelwoerister.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 18, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 18, 2024

HIR ty lowering was modified

cc @fmease

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

compiler/rustc_ast_lowering/src/index.rs Show resolved Hide resolved
compiler/rustc_middle/src/hir/mod.rs Show resolved Hide resolved
compiler/rustc_middle/src/query/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_privacy/src/lib.rs Show resolved Hide resolved
@petrochenkov
Copy link
Contributor

petrochenkov commented Aug 20, 2024

Ignoring all the ID parenting questions, the change looks reasonable to me because

  • It reduces weirdness
    • We have some other nodes, like closures, that could could technically be "outlined" into items, but they are typically kept inline, and opaques now behave analogously to closures
  • It doesn't complicate the compiler logic while reducing weirdness

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).

@petrochenkov petrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 20, 2024
@bors

This comment was marked as resolved.

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

Until I fix clippy:
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 22, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 22, 2024
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
@bors
Copy link
Contributor

bors commented Aug 22, 2024

⌛ Trying commit b66cc38 with merge b64686e...

@bors
Copy link
Contributor

bors commented Aug 22, 2024

☀️ Try build successful - checks-actions
Build commit: b64686e (b64686e62be3a3e957a5559eae0d8cd2f7cbee0c)

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 25, 2024

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

@bors
Copy link
Contributor

bors commented Sep 7, 2024

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

Copy link
Member

@compiler-errors compiler-errors left a 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(),
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

compiler/rustc_ast_lowering/src/index.rs Show resolved Hide resolved
@compiler-errors
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Oct 5, 2024

📌 Commit ef17eb7 has been approved by compiler-errors

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 Oct 5, 2024
@bors
Copy link
Contributor

bors commented Oct 5, 2024

⌛ Testing commit ef17eb7 with merge 5a4ee43...

@bors
Copy link
Contributor

bors commented Oct 5, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 5a4ee43 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 5, 2024
@bors bors merged commit 5a4ee43 into rust-lang:master Oct 5, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Oct 5, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5a4ee43): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 2
Improvements ✅
(primary)
-0.2% [-0.3%, -0.1%] 13
Improvements ✅
(secondary)
-0.6% [-1.4%, -0.2%] 23
All ❌✅ (primary) -0.2% [-0.3%, -0.1%] 13

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.

mean range count
Regressions ❌
(primary)
2.7% [2.7%, 2.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-3.5%, -0.8%] 19
Improvements ✅
(secondary)
-1.2% [-3.1%, -0.6%] 4
All ❌✅ (primary) -1.9% [-3.5%, 2.7%] 20

Cycles

Results (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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.8% [-4.3%, -1.4%] 9
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 770.7s -> 774.178s (0.45%)
Artifact size: 342.04 MiB -> 342.23 MiB (0.06%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
9 participants