Skip to content

Commit

Permalink
Rollup merge of #74852 - lzutao:inline-rm-tostring, r=nnethercote
Browse files Browse the repository at this point in the history
Explain why inlining default ToString impl

Trying to remove inline attribute from default ToString impl causes regression.
Perf result at <#74852 (comment)>.
  • Loading branch information
Manishearth committed Jul 29, 2020
2 parents 3522676 + 27e1b06 commit c07998e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,9 @@ pub trait ToString {
/// since `fmt::Write for String` never returns an error itself.
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: fmt::Display + ?Sized> ToString for T {
// A common guideline is to not inline generic functions. However,
// remove `#[inline]` from this method causes non-negligible regression.
// See <https://github.com/rust-lang/rust/pull/74852> as last attempt try to remove it.
#[inline]
default fn to_string(&self) -> String {
use fmt::Write;
Expand Down

0 comments on commit c07998e

Please sign in to comment.