about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorklensy <klensy@users.noreply.github.com>2022-06-08 21:23:39 +0300
committerklensy <klensy@users.noreply.github.com>2022-06-16 14:40:30 +0300
commit68ea8ff16f74be00797a237f8fd438b1d097ab5a (patch)
tree724e6126d5769db8f749958f39b66027e7151876 /compiler/rustc_errors/src
parent989d1a732f194d852e9a3636fc283c65612f995f (diff)
downloadrust-68ea8ff16f74be00797a237f8fd438b1d097ab5a.tar.gz
rust-68ea8ff16f74be00797a237f8fd438b1d097ab5a.zip
drive by fix needless allocation of const string number
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/emitter.rs8
1 files changed, 6 insertions, 2 deletions
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(