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

librustdoc: return impl fmt::Display in more places instead of writing to strings #137425

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yotamofek
Copy link
Contributor

Continuation of #136784 , another attempt at landing the larger parts of #136748 .
I'd like to, gradually, make all of the building blocks for rendering docs in librustdoc return impl fmt::Display instead of returning Strings, or receiving a &mut String (or &mut impl fmt::Write). Another smaller end goal is to be able to get rid of write_str.
This PR is a large step in that direction.

Most of the changes are quite mechanical, and split up into separate commits for easier reviewing (hopefully). I took print_item and then started by converting all the functions it called (and their dependencies), and the last commit does the conversion for print_item itself. Ignoring whitespace should make reviewing a bit easier.

And most importantly, perf run shows pretty good results locally, hopefully CI will also show green 😁

r? @GuillaumeGomez , if you feel like it.

@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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Feb 22, 2025
@lukas-code
Copy link
Member

@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 Feb 22, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 22, 2025
…play-redux, r=<try>

`librustdoc`: return `impl fmt::Display` in more places instead of writing to strings

Continuation of rust-lang#136784 , another attempt at landing the larger parts of rust-lang#136748 .
I'd like to, gradually, make all of the building blocks for rendering docs in `librustdoc` return `impl fmt::Display` instead of returning `Strings`, or receiving a `&mut String` (or `&mut impl fmt::Write`). Another smaller end goal is to be able to get rid of [`write_str`](https://github.com/rust-lang/rust/blob/8dac72bb1d12b2649acd0c190e41524f83da5683/src/librustdoc/html/format.rs#L40-L42).
This PR is a large step in that direction.

Most of the changes are quite mechanical, and split up into separate commits for easier reviewing (hopefully). I took `print_item` and then started by converting all the functions it called (and their dependencies), and the last commit does the conversion for `print_item` itself. Ignoring whitespace should make reviewing a bit easier.

And most importantly, perf run shows pretty good results locally, hopefully CI will also show green 😁

r? `@GuillaumeGomez` , if you feel like it.
@bors
Copy link
Contributor

bors commented Feb 22, 2025

⌛ Trying commit 1015ae9 with merge d331e3c...

@GuillaumeGomez
Copy link
Member

Looks good to me, let's see what the benches will tell.

@bors
Copy link
Contributor

bors commented Feb 22, 2025

☀️ Try build successful - checks-actions
Build commit: d331e3c (d331e3cd8e49b266010010bac60180ba08dc0c93)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d331e3c): 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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

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

Max RSS (memory usage)

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

Cycles

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

Binary size

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

Bootstrap: 773.405s -> 773.68s (0.04%)
Artifact size: 361.04 MiB -> 361.04 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 22, 2025
@GuillaumeGomez
Copy link
Member

Thanks!

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Feb 22, 2025

📌 Commit 1015ae9 has been approved by GuillaumeGomez

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 Feb 22, 2025
@fmease
Copy link
Member

fmease commented Feb 22, 2025

Sorry but can you squash this? 28 commits is a bit excessive.

@fmease
Copy link
Member

fmease commented Feb 22, 2025

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 22, 2025
@yotamofek
Copy link
Contributor Author

Sorry but can you squash this? 28 commits is a bit excessive.

Yeah, sure! One big commit then? Not really sure how to group it, otherwise

@fmease
Copy link
Member

fmease commented Feb 22, 2025

Either one big commit but one commit per file would be also be acceptable unless that makes no sense.

@yotamofek yotamofek force-pushed the pr/rustdoc/return-impl-display-redux branch from 1015ae9 to 479116e Compare February 23, 2025 04:34
@yotamofek
Copy link
Contributor Author

@fmease squashed into one commit

@fmease
Copy link
Member

fmease commented Feb 23, 2025

Thanks! @bors r=GuillaumeGomez

@bors
Copy link
Contributor

bors commented Feb 23, 2025

📌 Commit 479116e has been approved by GuillaumeGomez

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants