Skip to content

Remove rustc_middle dependency on rustc_hir_pretty - #160360

Open
mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:hir_pretty
Open

Remove rustc_middle dependency on rustc_hir_pretty#160360
mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:hir_pretty

Conversation

@mejrs

@mejrs mejrs commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

There is a impl PpAnn for TyCtxt that is unneeded. None of the big crates (middle, trait_selection) actually do any hir pretty printing so it can be removed and can either be implemented for local structs elsewhere or done by casting to &dyn PpAnn instead.

This probably doesn't have any perf effects (its not bottlenecking in timings) but I expect it to compose with #160336 and its followup works quite well.

Old graph:
graph

New graph:
graph_hir_pretty

@rustbot

rustbot commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@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 Aug 1, 2026
@rustbot

rustbot commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 17 candidates

Comment on lines +55 to +64
impl<'tcx, B: Bridge> rustc_hir_pretty::PpAnn for CompilerCtxt<'tcx, B> {
fn nested(&self, state: &mut rustc_hir_pretty::State<'_>, nested: rustc_hir_pretty::Nested) {
rustc_hir_pretty::PpAnn::nested(
&(&self.tcx as &dyn rustc_hir::intravisit::HirTyCtxt<'_>),
state,
nested,
)
}
}

@mejrs mejrs Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@celinval / @makai410 I'm low on rustc_public context and don't know if this impl can leak to rustc_public. This impl can be removed and replaced by a cast at the callsites, at your option.

View changes since the review

@mejrs

mejrs commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@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 1, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 1, 2026
Remove rustc_middle dependency on rustc_hir_pretty
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@mejrs

mejrs commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@bors try cancel

@rust-bors

rust-bors Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

There is a `impl PpAnn for TyCtxt`  that is unneeded. None of the big crates (middle, trait_selection) actually do any hir pretty printing so it can be removed and can either be implemented for local structs elsewhere or done by casting to `&dyn PpAnn` instead.
@rustbot

rustbot commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend T-clippy Relevant to the Clippy team. labels Aug 2, 2026
@mejrs

mejrs commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 2, 2026
Remove rustc_middle dependency on rustc_hir_pretty
@rust-bors

rust-bors Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0f4b3c5 (0f4b3c574fc058404e9860030574806f0a9564f0)
Base parent: 73dc916 (73dc9167f1cd099e525c9ade2e068d1907b78564)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0f4b3c5): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.2%, 0.5%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 0.5%, secondary 0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
0.6% [0.4%, 0.6%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.6% [-0.6%, -0.6%] 1
All ❌✅ (primary) 0.5% [0.5%, 0.5%] 1

Cycles

Results (primary 0.0%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.9% [0.4%, 2.3%] 7
Regressions ❌
(secondary)
0.8% [0.4%, 2.5%] 6
Improvements ✅
(primary)
-2.1% [-3.6%, -1.2%] 3
Improvements ✅
(secondary)
-1.5% [-3.7%, -0.5%] 4
All ❌✅ (primary) 0.0% [-3.6%, 2.3%] 10

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 63
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 57
All ❌✅ (primary) -0.1% [-0.1%, -0.0%] 63

Bootstrap: 490.553s -> 490.894s (0.07%)
Artifact size: 390.33 MiB -> 390.29 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. 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.

5 participants