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 <https://github.com/rust-lang/rust/pull/74852#issuecomment-664812994>.
This commit is contained in:
Manish Goregaokar 2020-07-29 16:38:22 -07:00 committed by GitHub
commit c07998e0e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;