From 298253af98db70ce5dd0294698dfb89cb3bd09ab Mon Sep 17 00:00:00 2001 From: Cameron Steffen Date: Thu, 27 Oct 2022 16:14:48 -0500 Subject: [PATCH] Specialize ToString for Symbol --- compiler/rustc_span/src/symbol.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3fe79370c374d..7f16da52b4439 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1901,6 +1901,13 @@ impl fmt::Display for Symbol { } } +// takes advantage of `str::to_string` specialization +impl ToString for Symbol { + fn to_string(&self) -> String { + self.as_str().to_string() + } +} + impl Encodable for Symbol { default fn encode(&self, s: &mut S) { s.emit_str(self.as_str());