From 68ea8ff16f74be00797a237f8fd438b1d097ab5a Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 8 Jun 2022 21:23:39 +0300 Subject: drive by fix needless allocation of const string number --- compiler/rustc_errors/src/emitter.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 06a1a31c672..ec48efa9bce 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -771,8 +771,12 @@ impl EmitterWriter { self } - fn maybe_anonymized(&self, line_num: usize) -> String { - if self.ui_testing { ANONYMIZED_LINE_NUM.to_string() } else { line_num.to_string() } + fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> { + if self.ui_testing { + Cow::Borrowed(ANONYMIZED_LINE_NUM) + } else { + Cow::Owned(line_num.to_string()) + } } fn draw_line( -- cgit 1.4.1-3-g733a5