Skip to content

Commit 68ea8ff

Browse files
committed
drive by fix needless allocation of const string number
1 parent 989d1a7 commit 68ea8ff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/rustc_errors/src/emitter.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,12 @@ impl EmitterWriter {
771771
self
772772
}
773773

774-
fn maybe_anonymized(&self, line_num: usize) -> String {
775-
if self.ui_testing { ANONYMIZED_LINE_NUM.to_string() } else { line_num.to_string() }
774+
fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> {
775+
if self.ui_testing {
776+
Cow::Borrowed(ANONYMIZED_LINE_NUM)
777+
} else {
778+
Cow::Owned(line_num.to_string())
779+
}
776780
}
777781

778782
fn draw_line(

0 commit comments

Comments
 (0)