Skip to content

Commit 7dc953b

Browse files
authored
Simplify code for special case of annotation
1 parent 75a7c27 commit 7dc953b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/librustc_errors/emitter.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -622,18 +622,16 @@ impl EmitterWriter {
622622
// 3 | |
623623
// 4 | | }
624624
// | |_^ test
625-
if line.annotations.len() == 1 {
626-
if let Some(ref ann) = line.annotations.get(0) {
627-
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
628-
if source_string.chars().take(ann.start_col).all(|c| c.is_whitespace()) {
629-
let style = if ann.is_primary {
630-
Style::UnderlinePrimary
631-
} else {
632-
Style::UnderlineSecondary
633-
};
634-
buffer.putc(line_offset, width_offset + depth - 1, '/', style);
635-
return vec![(depth, style)];
636-
}
625+
if let [ann] = &line.annotations[..] {
626+
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
627+
if source_string.chars().take(ann.start_col).all(|c| c.is_whitespace()) {
628+
let style = if ann.is_primary {
629+
Style::UnderlinePrimary
630+
} else {
631+
Style::UnderlineSecondary
632+
};
633+
buffer.putc(line_offset, width_offset + depth - 1, '/', style);
634+
return vec![(depth, style)];
637635
}
638636
}
639637
}

0 commit comments

Comments
 (0)