Skip to content

rustdoc: skip blanket impls on recursive types - #160173

Open
im-lunex wants to merge 1 commit into
rust-lang:mainfrom
im-lunex:fix_#160105
Open

rustdoc: skip blanket impls on recursive types#160173
im-lunex wants to merge 1 commit into
rust-lang:mainfrom
im-lunex:fix_#160105

Conversation

@im-lunex

@im-lunex im-lunex commented Jul 29, 2026

Copy link
Copy Markdown

When a type contains itself through its fields (e.g. struct A(B<A>)),
evaluating blanket impl obligations on it can hang or take exponential
time. Skip blanket impl synthesis entirely for such types.

Adds a TypeVisitor that walks field types with cycle detection and
returns early from synthesize_blanket_impls when a recursive ADT
is found.

fixes #160105.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 29, 2026
@rustbot

rustbot commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @notriddle (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 8 candidates
  • Random selection from GuillaumeGomez, camelid, lolbinarycat, notriddle

@im-lunex
im-lunex marked this pull request as draft July 29, 2026 18:56
@rustbot rustbot 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 Jul 29, 2026
@im-lunex im-lunex changed the title rustdoc: speed up blanket impl synthesis for recursive types rustdoc: skip blanket impls on recursive types Jul 30, 2026
@rust-log-analyzer

This comment has been minimized.

@im-lunex
im-lunex marked this pull request as ready for review July 30, 2026 10:23
@rustbot rustbot 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 Jul 30, 2026
@rustbot

This comment has been minimized.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jul 30, 2026
@rustbot rustbot removed the has-merge-commits PR has merge commits, merge with caution. label Jul 30, 2026
@notriddle

Copy link
Copy Markdown
Contributor

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

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1701156 (1701156946ac94f71ac6fe1ac6110e8762eb2841)
Base parent: be3d26d (be3d26db984c6f96335faca1f254dc04873cb1c1)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1701156): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never rustc-perf
@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
Improvements ✅
(primary)
-1.0% [-3.5%, -0.2%] 9
Improvements ✅
(secondary)
-1.4% [-2.4%, -0.3%] 3
All ❌✅ (primary) -1.0% [-3.5%, -0.2%] 9

Max RSS (memory usage)

Results (primary 0.5%, secondary -1.6%)

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

mean range count
Regressions ❌
(primary)
2.7% [0.4%, 4.1%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.2% [-2.1%, -0.4%] 4
Improvements ✅
(secondary)
-1.6% [-1.6%, -1.6%] 1
All ❌✅ (primary) 0.5% [-2.1%, 4.1%] 7

Cycles

Results (primary -0.6%, secondary -2.6%)

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

mean range count
Regressions ❌
(primary)
0.7% [0.4%, 1.0%] 2
Regressions ❌
(secondary)
1.2% [0.4%, 3.7%] 12
Improvements ✅
(primary)
-1.0% [-3.2%, -0.4%] 7
Improvements ✅
(secondary)
-6.4% [-21.5%, -0.4%] 12
All ❌✅ (primary) -0.6% [-3.2%, 1.0%] 9

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.155s -> 489.631s (0.10%)
Artifact size: 390.64 MiB -> 390.69 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 30, 2026
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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustdoc extreme slowdown with cyclic generic structures

5 participants