diff options
| author | bors <bors@rust-lang.org> | 2022-06-17 17:30:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-17 17:30:16 +0000 |
| commit | 0cb9899e780bcefb9008088c1e6d6cd5fe2593b4 (patch) | |
| tree | 99ff5236e8bf7662db9f6071acec6369d560272f /compiler/rustc_errors/src | |
| parent | 43c47db0b04627dbd0e16a1e7cad14a4a5a60d3a (diff) | |
| parent | 6fc412fb73e64c22e028b082d05c4b31c6b96a17 (diff) | |
| download | rust-0cb9899e780bcefb9008088c1e6d6cd5fe2593b4.tar.gz rust-0cb9899e780bcefb9008088c1e6d6cd5fe2593b4.zip | |
Auto merge of #97892 - klensy:fix-spaces, r=oli-obk
diagnostics: remove trailing spaces Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 1329e3a0b95..a4cbc73978d 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( @@ -819,7 +823,7 @@ impl EmitterWriter { } buffer.puts(line_offset, 0, &self.maybe_anonymized(line_index), Style::LineNumber); - draw_col_separator(buffer, line_offset, width_offset - 2); + draw_col_separator_no_space(buffer, line_offset, width_offset - 2); } fn render_source_line( @@ -1929,7 +1933,7 @@ impl EmitterWriter { // Only show an underline in the suggestions if the suggestion is not the // entirety of the code being shown and the displayed code is not multiline. if let DisplaySuggestion::Diff | DisplaySuggestion::Underline = show_code_change { - draw_col_separator(&mut buffer, row_num, max_line_num_len + 1); + draw_col_separator_no_space(&mut buffer, row_num, max_line_num_len + 1); for part in parts { let span_start_pos = sm.lookup_char_pos(part.span.lo()).col_display; let span_end_pos = sm.lookup_char_pos(part.span.hi()).col_display; |
