From 27e1b0632cea37733050b7e130c3fbaf0b70b52d Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Wed, 29 Jul 2020 07:38:06 +0000 Subject: [PATCH] Explain why inline default ToString impl --- library/alloc/src/string.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 05398ca68c8ba..d7d7b6bd157bc 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 ToString for T { + // A common guideline is to not inline generic functions. However, + // remove `#[inline]` from this method causes non-negligible regression. + // See as last attempt try to remove it. #[inline] default fn to_string(&self) -> String { use fmt::Write;