about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-29 16:38:22 -0700
committerGitHub <noreply@github.com>2020-07-29 16:38:22 -0700
commitc07998e0e7ea182491aaad2a3cf82dfaabf64c0d (patch)
tree608cd92035a6aaba47c12bffd425f236de80787c
parent35226766c98147142c573c2087a5c3aae9819e99 (diff)
parent27e1b0632cea37733050b7e130c3fbaf0b70b52d (diff)
downloadrust-c07998e0e7ea182491aaad2a3cf82dfaabf64c0d.tar.gz
rust-c07998e0e7ea182491aaad2a3cf82dfaabf64c0d.zip
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>.
-rw-r--r--library/alloc/src/string.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
index 05398ca68c8..d7d7b6bd157 100644
--- a/library/alloc/src/string.rs
+++ b/library/alloc/src/string.rs
@@ -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;