-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rustdoc: simplify handling of plain text output #109246
Conversation
r? @notriddle (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
ab52287
to
ce9289a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit dde3cced5ea68bec455d2b47f49b54621c692c95 with merge 56fa9753c5bb8be807bdabf9018e03618dd75fbf... |
💔 Test failed - checks-actions |
Looks relevant: https://github.com/rust-lang-ci/rust/actions/runs/4469549308/jobs/7851815712#step:26:40193
|
This comment has been minimized.
This comment has been minimized.
Yep! Will take a look in a bit. Thanks for digging up the log line. |
Hey :) Does this PR fix #109488 perchance? |
When I make the example from #109488 into a test, I get a compiler ICE; presumably it needs the code you're working on? I have a pretty strong suspicion the issue is this line, which I didn't touch yet because it looked fishy and I couldn't figure out the intention: rust/src/librustdoc/html/format.rs Line 1158 in 4c0f500
I should also change it in this branch because |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 236c18f with merge 9c4e97025c634ec4878a1580cc34680aa24ce17e... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9c4e97025c634ec4878a1580cc34680aa24ce17e): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
Bummer, looks like performance got worse. I think I can probably iterate and improve it though. |
@jsha any updates on this? |
I'll close this for now and hope to come back to it. |
Replace use of
f.alternate()
in format.rs, and offers insteadType::print_plain
, andPath::print_plain
.Adopt Askama template for rendering of functions and methods.
Motivation:
In rustdoc we generally emit HTML, but there are a few places where we need to emit a plain text form of
clean::Type
and/orclean::Path
:Trait Implementations
, we render traits, e.g.AsRef<str>
. These should be plain because we don't want to separately linkAsRef
andstr
to those respective types; we want a single link that goes to that trait implementation.Originally, plain text output was controlled via Formatter's
f.alternate()
mechanism, so you could generate HTML by formatting with{}
or plain text by formatting with{:#}
. This avoids having to generate HTML only to strip it out. However, it leads to a lot of duplication and branching in format.rs. Since the only HTML we care about comes from within a single module, we can write a very simple HTML remover that strips all tags and only cares about a handful of entities.This also lets us simplify calculating the width of a function header - we can simply pass a template and count its bytes.
This PR can be reviewed commit-by-commit.
Related: #108868