Skip to content

Commit e29c33f

Browse files
committed
fix: Render continuation between no source labels
1 parent d9805b2 commit e29c33f

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
@@ -1670,23 +1670,27 @@ impl HumanEmitter {
16701670
{
16711671
already_closed = Some(!labels.is_empty());
16721672
}
1673-
for (label, is_primary) in labels.into_iter() {
1673+
let labels_len = labels.len();
1674+
for (label_idx, (label, is_primary)) in labels.into_iter().enumerate() {
16741675
let style = if is_primary {
16751676
Style::LabelPrimary
16761677
} else {
16771678
Style::LabelSecondary
16781679
};
1679-
let pipe = self.col_separator();
1680-
buffer.prepend(line_idx, &format!(" {pipe}"), Style::LineNumber);
1681-
for _ in 0..max_line_num_len {
1682-
buffer.prepend(line_idx, " ", Style::NoStyle);
1683-
}
1680+
self.draw_col_separator_no_space(
1681+
&mut buffer,
1682+
line_idx,
1683+
max_line_num_len + 1,
1684+
);
16841685
line_idx += 1;
1685-
let chr = self.note_separator();
1686-
buffer.append(line_idx, &format!(" {chr} note: "), style);
1687-
for _ in 0..max_line_num_len {
1688-
buffer.prepend(line_idx, " ", Style::NoStyle);
1689-
}
1686+
self.draw_note_separator(
1687+
&mut buffer,
1688+
line_idx,
1689+
max_line_num_len + 1,
1690+
label_idx != labels_len - 1,
1691+
);
1692+
buffer.append(line_idx, "note", Style::MainHeaderMsg);
1693+
buffer.append(line_idx, ": ", Style::NoStyle);
16901694
buffer.append(line_idx, label, style);
16911695
line_idx += 1;
16921696
}
@@ -2862,10 +2866,11 @@ impl HumanEmitter {
28622866
}
28632867
}
28642868

2865-
fn note_separator(&self) -> char {
2869+
fn note_separator(&self, is_cont: bool) -> &'static str {
28662870
match self.theme {
2867-
OutputTheme::Ascii => '=',
2868-
OutputTheme::Unicode => '╰',
2871+
OutputTheme::Ascii => "= ",
2872+
OutputTheme::Unicode if is_cont => "├ ",
2873+
OutputTheme::Unicode => "╰ ",
28692874
}
28702875
}
28712876

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

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)