diff options
| author | Scott Schafer <schaferjscott@gmail.com> | 2025-07-22 05:14:37 -0600 |
|---|---|---|
| committer | Scott Schafer <schaferjscott@gmail.com> | 2025-08-26 15:15:17 -0600 |
| commit | 2bd47d264628dc227ed317a6c0d0f03891dd8c5c (patch) | |
| tree | 94c257d89ecc5c88fdd6092d9b4b32de0fde0433 | |
| parent | 93d16c510066db062700e783a53461d45e5dbe4b (diff) | |
| download | rust-2bd47d264628dc227ed317a6c0d0f03891dd8c5c.tar.gz rust-2bd47d264628dc227ed317a6c0d0f03891dd8c5c.zip | |
fix: Render continuation between no source labels
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 39 | ||||
| -rw-r--r-- | tests/ui/suggestions/multi-suggestion.unicode.stderr | 2 |
2 files changed, 21 insertions, 20 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index bd3b81bca0c..b94370e8e9b 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1671,23 +1671,27 @@ impl HumanEmitter { { code_window_status = CodeWindowStatus::Closed; } - for (label, is_primary) in labels.into_iter() { + let labels_len = labels.len(); + for (label_idx, (label, is_primary)) in labels.into_iter().enumerate() { let style = if is_primary { Style::LabelPrimary } else { Style::LabelSecondary }; - let pipe = self.col_separator(); - buffer.prepend(line_idx, &format!(" {pipe}"), Style::LineNumber); - for _ in 0..max_line_num_len { - buffer.prepend(line_idx, " ", Style::NoStyle); - } + self.draw_col_separator_no_space( + &mut buffer, + line_idx, + max_line_num_len + 1, + ); line_idx += 1; - let chr = self.note_separator(); - buffer.append(line_idx, &format!(" {chr} note: "), style); - for _ in 0..max_line_num_len { - buffer.prepend(line_idx, " ", Style::NoStyle); - } + self.draw_note_separator( + &mut buffer, + line_idx, + max_line_num_len + 1, + label_idx != labels_len - 1, + ); + buffer.append(line_idx, "note", Style::MainHeaderMsg); + buffer.append(line_idx, ": ", Style::NoStyle); buffer.append(line_idx, label, style); line_idx += 1; } @@ -2863,10 +2867,11 @@ impl HumanEmitter { } } - fn note_separator(&self) -> char { + fn note_separator(&self, is_cont: bool) -> &'static str { match self.theme { - OutputTheme::Ascii => '=', - OutputTheme::Unicode => '╰', + OutputTheme::Ascii => "= ", + OutputTheme::Unicode if is_cont => "├ ", + OutputTheme::Unicode => "╰ ", } } @@ -2979,11 +2984,7 @@ impl HumanEmitter { col: usize, is_cont: bool, ) { - let chr = match self.theme { - OutputTheme::Ascii => "= ", - OutputTheme::Unicode if is_cont => "├ ", - OutputTheme::Unicode => "╰ ", - }; + let chr = self.note_separator(is_cont); buffer.puts(line, col, chr, Style::LineNumber); } diff --git a/tests/ui/suggestions/multi-suggestion.unicode.stderr b/tests/ui/suggestions/multi-suggestion.unicode.stderr index 3d3f3268c08..4835c263f19 100644 --- a/tests/ui/suggestions/multi-suggestion.unicode.stderr +++ b/tests/ui/suggestions/multi-suggestion.unicode.stderr @@ -34,7 +34,7 @@ LL │ wtf: Some(Box(U { note: constructor is not visible here due to private fields ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL │ - ╰ note: private field + ├ note: private field │ ╰ note: private field help: you might have meant to use an associated function to build this type |
