Skip to content

Commit c855af5

Browse files
committed
fix: Render continuation between no source labels
1 parent 1ef6bb2 commit c855af5

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,23 +1671,27 @@ impl HumanEmitter {
16711671
{
16721672
code_window_status = CodeWindowStatus::Closed;
16731673
}
1674-
for (label, is_primary) in labels.into_iter() {
1674+
let labels_len = labels.len();
1675+
for (label_idx, (label, is_primary)) in labels.into_iter().enumerate() {
16751676
let style = if is_primary {
16761677
Style::LabelPrimary
16771678
} else {
16781679
Style::LabelSecondary
16791680
};
1680-
let pipe = self.col_separator();
1681-
buffer.prepend(line_idx, &format!(" {pipe}"), Style::LineNumber);
1682-
for _ in 0..max_line_num_len {
1683-
buffer.prepend(line_idx, " ", Style::NoStyle);
1684-
}
1681+
self.draw_col_separator_no_space(
1682+
&mut buffer,
1683+
line_idx,
1684+
max_line_num_len + 1,
1685+
);
16851686
line_idx += 1;
1686-
let chr = self.note_separator();
1687-
buffer.append(line_idx, &format!(" {chr} note: "), style);
1688-
for _ in 0..max_line_num_len {
1689-
buffer.prepend(line_idx, " ", Style::NoStyle);
1690-
}
1687+
self.draw_note_separator(
1688+
&mut buffer,
1689+
line_idx,
1690+
max_line_num_len + 1,
1691+
label_idx != labels_len - 1,
1692+
);
1693+
buffer.append(line_idx, "note", Style::MainHeaderMsg);
1694+
buffer.append(line_idx, ": ", Style::NoStyle);
16911695
buffer.append(line_idx, label, style);
16921696
line_idx += 1;
16931697
}
@@ -2863,10 +2867,11 @@ impl HumanEmitter {
28632867
}
28642868
}
28652869

2866-
fn note_separator(&self) -> char {
2870+
fn note_separator(&self, is_cont: bool) -> &'static str {
28672871
match self.theme {
2868-
OutputTheme::Ascii => '=',
2869-
OutputTheme::Unicode => '╰',
2872+
OutputTheme::Ascii => "= ",
2873+
OutputTheme::Unicode if is_cont => "├ ",
2874+
OutputTheme::Unicode => "╰ ",
28702875
}
28712876
}
28722877

@@ -2979,11 +2984,7 @@ impl HumanEmitter {
29792984
col: usize,
29802985
is_cont: bool,
29812986
) {
2982-
let chr = match self.theme {
2983-
OutputTheme::Ascii => "= ",
2984-
OutputTheme::Unicode if is_cont => "├ ",
2985-
OutputTheme::Unicode => "╰ ",
2986-
};
2987+
let chr = self.note_separator(is_cont);
29872988
buffer.puts(line, col, chr, Style::LineNumber);
29882989
}
29892990

tests/ui/suggestions/multi-suggestion.unicode.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LL │ wtf: Some(Box(U {
3434
note: constructor is not visible here due to private fields
3535
╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL
3636
37-
note: private field
37+
note: private field
3838
3939
╰ note: private field
4040
help: you might have meant to use an associated function to build this type

0 commit comments

Comments
 (0)