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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

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.

fn visit_opaque_ty(&mut self, opaq: &'hir OpaqueTy<'hir>) {
self.insert(opaq.span, opaq.hir_id, Node::OpaqueTy(opaq));

self.with_parent(opaq.hir_id, |this| {
Copy link
Contributor

Choose a reason for hiding this comment

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

This still creates a mismatch between HirId and DefId parenting.
The opaque's HirId is included into the parenting chain here, but its corresponding DefId is not included because it is created late.

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.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b64686e): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -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
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 13
Improvements ✅
(secondary)
-0.6% [-1.3%, -0.1%] 22
All ❌✅ (primary) -0.3% [-0.4%, -0.2%] 13

Max RSS (memory usage)

Results (primary -2.0%, secondary 2.7%)

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.7% [1.6%, 3.9%] 2
Improvements ✅
(primary)
-2.0% [-2.7%, -1.3%] 11
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-2.7%, -1.3%] 11

Cycles

Results (secondary -5.7%)

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)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.7% [-8.3%, -3.0%] 2
All ❌✅ (primary) - - 0

Binary size

Results (secondary 0.0%)

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)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 749.145s -> 754.024s (0.65%)
Artifact size: 338.93 MiB -> 339.22 MiB (0.09%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 23, 2024
@cjgillot cjgillot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 23, 2024
@bors
Copy link
Contributor

bors commented Aug 23, 2024

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
9 participants