-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: impl core::fmt::Write for rustdoc::html::render::Buffer #92758
Conversation
r? @CraftSpider (rust-highfive has picked a reviewer for you, use r? to override) |
r? @jyn514 |
@@ -62,6 +62,12 @@ crate struct Buffer { | |||
buffer: String, | |||
} | |||
|
|||
impl core::fmt::Write for Buffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably just forward all three methods directly (I'm unsure about performance effects), since it's pretty trivial to do, and also annotate each of them with #[inline]
.
And we should probably remove the inherent write_str()
and write_fmt()
methods, replacing their usage with these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forwarded all the methods and then tried to use the trait methods but i could not make head or tail of the errors that came :(
I then tried to call the traits as <Self as Write>::write_fmt(....)
which worked. Have not pushed those changes up though, as I am not sure if they are sane :(
I tried to use the newly implemented impl Buffer {
...
crate fn write_str(&mut self, s: &str) {
<Self as Write>::write_str(self, s).unwrap();
}
crate fn write_fmt(&mut self, v: fmt::Arguments<'_>) {
<Self as Write>::write_fmt(self, v).unwrap();
}
...
} Although, I am not sure, if this is the right approach :( |
I meant removing the |
Yes, I tried that first, I was unable to get that working. Let me give it one more try.
|
That sounds like the right approach! How did it not work? Did you get a compiler error? If so, what? |
I apologize, I was not taking into account that the signatures have changed & I might have to add a bunch of |
b284d10
to
31ea629
Compare
@bors try |
Please remove your merge commits and instead use |
@@ -140,7 +140,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, | |||
}; | |||
|
|||
let heading = item_vars.render().unwrap(); | |||
buf.write_str(&heading); | |||
buf.write_str(&heading).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original point of my issue was to change this to do buf.write_fmt(format!("{}", heading))
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me do that activity after I resolve the git issues :)
[btw .. this process has been immense learning & apologies for me being a little slow to understand the bigger picture]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this @mfrw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine don't worry. If you have questions don't hesitate to ask. Thank you for working on this! :)
eba5046
to
ba4921d
Compare
I regret suggesting we should change all the instances of |
Take II with |
Sure, this was a huge learning :) |
If there is no perf improvement from it, I think that's what we will need to do because the increase of code for no gain isn't really worth it. So for the perf now: @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
This comment has been minimized.
This comment has been minimized.
Please fix the error. @bors: try- EDIT: And by the time I wrote this message, you did. 😆 |
Ok, let's try again! @bors try @rust-timer queue |
Thank you Very much :) |
Signed-off-by: Muhammad Falak R Wani <[email protected]>
Signed-off-by: Muhammad Falak R Wani <[email protected]>
Signed-off-by: Muhammad Falak R Wani <[email protected]>
0359e0b
to
62bea63
Compare
@djc & @GuillaumeGomez apologies for the late turn around :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Would be nice to get a perf run for this, I suppose?
Absolutely! @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 62bea63 with merge 213368f0aa11b580455fc90c29d5e4b4700f73d1... |
☀️ Try build successful - checks-actions |
Queued 213368f0aa11b580455fc90c29d5e4b4700f73d1 with parent 547f2ba, future comparison URL. |
Finished benchmarking commit (213368f0aa11b580455fc90c29d5e4b4700f73d1): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. @bors rollup=never |
📌 Commit 62bea63 has been approved by |
I don't see any doc things in the rustc-perf listing, what am I missing? |
You need to uncheck "Show only significant changes" and "Filter out very small changes". To have only relevant items, you can filter by using " doc". |
…llaumeGomez librustdoc: impl core::fmt::Write for rustdoc::html::render::Buffer Signed-off-by: Muhammad Falak R Wani <[email protected]> Fixes: rust-lang#92563
…askrgr Rollup of 7 pull requests Successful merges: - rust-lang#92758 (librustdoc: impl core::fmt::Write for rustdoc::html::render::Buffer) - rust-lang#92788 (Detect `::` -> `:` typo in type argument) - rust-lang#93420 (Improve wrapping on settings page) - rust-lang#93493 (Document valid values of the char type) - rust-lang#93531 (Fix incorrect panic message in example) - rust-lang#93559 (Add missing | between print options) - rust-lang#93560 (Fix two incorrect "it's" (typos in comments)) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Signed-off-by: Muhammad Falak R Wani [email protected]
Fixes: #92563