Skip to content

[WIP] rustdoc: Improve ItemKind - #162916

Draft
fmease wants to merge 7 commits into
rust-lang:mainfrom
fmease:rustdoc-better-item-kinds
Draft

fmease wants to merge 7 commits into
rust-lang:mainfrom
fmease:rustdoc-better-item-kinds

Conversation

@fmease

@fmease fmease commented Sep 17, 2026

Copy link
Copy Markdown
Member

TODO: Description.

Addresses #112901 (comment) & thereby fixes #112901.

(No LLM was or will be used by me during the entire creation process of this PR)

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Sep 17, 2026
@fmease

fmease commented Sep 17, 2026

Copy link
Copy Markdown
Member 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 Sep 17, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
@fmease
fmease force-pushed the rustdoc-better-item-kinds branch from 75c7db0 to b15adfe Compare September 17, 2026 17:36
Moreover, rename `Function` to `Fn`, `*Method` to `*AssocFn`,
`*Type` to `*Ty`, `Constant` to `Const` & `Macro` to `DeclMacro`.
…ssocConst`

I had to modify several HTML rendering routines because parameter
`parent: ItemType` of fn `render_assoc_item` didn't always refer to
the parent container (impl vs trait) since it was actually misused to
control the styling (!), namely the indentation & the look of the
where-clause, but now with `ProvidedAssocConst` & `ImplAssocConst` merged
I needed to know the actual container to determine `AssocConstValue`.

`render_assoc_item` previously only used the `parent` param to determine
the indentation & `assoc_method` used it to determine the indentation &
the style of the where-clause (see enum `Ending`; complete misnomer!).

That led to `item_trait` (for rendering trait pages) literally passing
`ItemType::Impl` for the "docs section" (as contrasted with the "code
block") to avoid indenting it.

To untangle this, I forced the callers of `render_assoc_item` to specify
the indentation & the where-clause styling via new parameters.

*Moreover*, as alluded to above, only `assoc_method` made the
where-clause styling (`Ending`) dependent on the context, not however
`assoc_const` or `assoc_ty`! I've fixed that here to avoid making the
parameter list of `render_assoc_item` even longer & since it makes them
consistent (thereby fixing the remaining issues reported in RUST-112901).
FIXME: Better names & types.
@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 77d2154 (77d215460b0d48a45bad88d416cbd1326a27a011)
Base parent: c999cef (c999cef531ea9059e189e82fe0e82c5daf249bc9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (77d2154): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

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.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.1%] 8
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.8%, secondary 1.0%)

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

mean range count
Regressions ❌
(primary)
1.8% [1.4%, 2.1%] 2
Regressions ❌
(secondary)
3.2% [2.2%, 3.7%] 3
Improvements ✅
(primary)
-2.4% [-3.1%, -2.0%] 3
Improvements ✅
(secondary)
-2.2% [-2.7%, -1.6%] 2
All ❌✅ (primary) -0.8% [-3.1%, 2.1%] 5

Cycles

Results (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)
- - 0
Regressions ❌
(secondary)
3.7% [3.3%, 4.2%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 500.132s -> 501.928s (0.36%)
Artifact size: 406.81 MiB -> 407.66 MiB (0.21%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 17, 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 perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustdoc: where-clauses on tuple & unit structs and on assoc tys are weirdly styled

3 participants