Skip to content

Commit c07998e

Browse files
authored
Rollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercote
Explain why inlining default ToString impl Trying to remove inline attribute from default ToString impl causes regression. Perf result at <#74852 (comment)>.
2 parents 3522676 + 27e1b06 commit c07998e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/alloc/src/string.rs

+3
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,9 @@ pub trait ToString {
21962196
/// since `fmt::Write for String` never returns an error itself.
21972197
#[stable(feature = "rust1", since = "1.0.0")]
21982198
impl<T: fmt::Display + ?Sized> ToString for T {
2199+
// A common guideline is to not inline generic functions. However,
2200+
// remove `#[inline]` from this method causes non-negligible regression.
2201+
// See <https://github.com/rust-lang/rust/pull/74852> as last attempt try to remove it.
21992202
#[inline]
22002203
default fn to_string(&self) -> String {
22012204
use fmt::Write;

0 commit comments

Comments
 (0)