Skip to content

Commit 82e45ef

Browse files
committed
format code
1 parent 1207a2d commit 82e45ef

File tree

1 file changed

+45
-40
lines changed

1 file changed

+45
-40
lines changed

compiler/rustc_errors/src/emitter.rs

+45-40
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,9 @@ impl HumanEmitter {
797797
if let AnnotationType::MultilineStart(depth) = ann.annotation_type {
798798
if source_string.chars().take(ann.start_col.display).all(|c| c.is_whitespace()) {
799799
let uline = self.underline(ann.is_primary);
800-
let style = uline.style;
801800
let chr = uline.multiline_whole_line;
802-
annotations.push((depth, style));
803-
buffer_ops.push((line_offset, width_offset + depth - 1, chr, style));
801+
annotations.push((depth, uline.style));
802+
buffer_ops.push((line_offset, width_offset + depth - 1, chr, uline.style));
804803
} else {
805804
short_start = false;
806805
break;
@@ -1019,26 +1018,24 @@ impl HumanEmitter {
10191018
// | _
10201019
for &(pos, annotation) in &annotations_position {
10211020
let underline = self.underline(annotation.is_primary);
1022-
let chr = underline.multiline_horizontal;
1023-
let style = underline.style;
10241021
let pos = pos + 1;
10251022
match annotation.annotation_type {
10261023
AnnotationType::MultilineStart(depth) | AnnotationType::MultilineEnd(depth) => {
10271024
self.draw_range(
10281025
buffer,
1029-
chr,
1026+
underline.multiline_horizontal,
10301027
line_offset + pos,
10311028
width_offset + depth,
10321029
(code_offset + annotation.start_col.display).saturating_sub(left),
1033-
style,
1030+
underline.style,
10341031
);
10351032
}
10361033
_ if self.teach => {
10371034
buffer.set_style_range(
10381035
line_offset,
10391036
(code_offset + annotation.start_col.display).saturating_sub(left),
10401037
(code_offset + annotation.end_col.display).saturating_sub(left),
1041-
style,
1038+
underline.style,
10421039
annotation.is_primary,
10431040
);
10441041
}
@@ -1059,13 +1056,6 @@ impl HumanEmitter {
10591056
// | |_
10601057
for &(pos, annotation) in &annotations_position {
10611058
let underline = self.underline(annotation.is_primary);
1062-
let style = underline.style;
1063-
let chr = underline.vertical_text_line;
1064-
let multiline = underline.multiline_vertical;
1065-
let start = underline.top_left;
1066-
let corner = underline.bottom_left;
1067-
let go_left = underline.bottom_right;
1068-
let end_with_label = underline.multiline_bottom_right_with_text;
10691059
let pos = pos + 1;
10701060

10711061
if pos > 1 && (annotation.has_label() || annotation.takes_space()) {
@@ -1074,24 +1064,24 @@ impl HumanEmitter {
10741064
buffer.putc(
10751065
p,
10761066
(code_offset + annotation.start_col.display).saturating_sub(left),
1077-
multiline,
1078-
style,
1067+
underline.multiline_vertical,
1068+
underline.style,
10791069
);
10801070
} else {
10811071
buffer.putc(
10821072
p,
10831073
(code_offset + annotation.start_col.display).saturating_sub(left),
1084-
chr,
1085-
style,
1074+
underline.vertical_text_line,
1075+
underline.style,
10861076
);
10871077
}
10881078
}
10891079
if let AnnotationType::MultilineStart(_) = annotation.annotation_type {
10901080
buffer.putc(
10911081
line_offset + pos,
10921082
(code_offset + annotation.start_col.display).saturating_sub(left),
1093-
go_left,
1094-
style,
1083+
underline.bottom_right,
1084+
underline.style,
10951085
);
10961086
}
10971087
if let AnnotationType::MultilineEnd(_) = annotation.annotation_type
@@ -1100,23 +1090,43 @@ impl HumanEmitter {
11001090
buffer.putc(
11011091
line_offset + pos,
11021092
(code_offset + annotation.start_col.display).saturating_sub(left),
1103-
end_with_label,
1104-
style,
1093+
underline.multiline_bottom_right_with_text,
1094+
underline.style,
11051095
);
11061096
}
11071097
}
11081098
match annotation.annotation_type {
11091099
AnnotationType::MultilineStart(depth) => {
1110-
buffer.putc(line_offset + pos, width_offset + depth - 1, start, style);
1100+
buffer.putc(
1101+
line_offset + pos,
1102+
width_offset + depth - 1,
1103+
underline.top_left,
1104+
underline.style,
1105+
);
11111106
for p in line_offset + pos + 1..line_offset + line_len + 2 {
1112-
buffer.putc(p, width_offset + depth - 1, multiline, style);
1107+
buffer.putc(
1108+
p,
1109+
width_offset + depth - 1,
1110+
underline.multiline_vertical,
1111+
underline.style,
1112+
);
11131113
}
11141114
}
11151115
AnnotationType::MultilineEnd(depth) => {
11161116
for p in line_offset..line_offset + pos {
1117-
buffer.putc(p, width_offset + depth - 1, multiline, style);
1117+
buffer.putc(
1118+
p,
1119+
width_offset + depth - 1,
1120+
underline.multiline_vertical,
1121+
underline.style,
1122+
);
11181123
}
1119-
buffer.putc(line_offset + pos, width_offset + depth - 1, corner, style);
1124+
buffer.putc(
1125+
line_offset + pos,
1126+
width_offset + depth - 1,
1127+
underline.bottom_left,
1128+
underline.style,
1129+
);
11201130
}
11211131
_ => (),
11221132
}
@@ -1172,18 +1182,13 @@ impl HumanEmitter {
11721182
// | _^ test
11731183
for &(pos, annotation) in &annotations_position {
11741184
let uline = self.underline(annotation.is_primary);
1175-
let style = uline.style;
1176-
let underline = uline.underline;
1177-
let labeled_start = uline.label_start;
1178-
let flat_start = uline.top_right_flat;
1179-
let vertical_start = uline.multiline_start_down;
11801185
for p in annotation.start_col.display..annotation.end_col.display {
11811186
// The default span label underline.
11821187
buffer.putc(
11831188
line_offset + 1,
11841189
(code_offset + p).saturating_sub(left),
1185-
underline,
1186-
style,
1190+
uline.underline,
1191+
uline.style,
11871192
);
11881193
}
11891194

@@ -1197,8 +1202,8 @@ impl HumanEmitter {
11971202
buffer.putc(
11981203
line_offset + 1,
11991204
(code_offset + annotation.start_col.display).saturating_sub(left),
1200-
flat_start,
1201-
style,
1205+
uline.top_right_flat,
1206+
uline.style,
12021207
);
12031208
} else if pos != 0
12041209
&& matches!(
@@ -1211,16 +1216,16 @@ impl HumanEmitter {
12111216
buffer.putc(
12121217
line_offset + 1,
12131218
(code_offset + annotation.start_col.display).saturating_sub(left),
1214-
vertical_start,
1215-
style,
1219+
uline.multiline_start_down,
1220+
uline.style,
12161221
);
12171222
} else if pos != 0 && annotation.has_label() {
12181223
// The beginning of a span label with an actual label, we'll point down.
12191224
buffer.putc(
12201225
line_offset + 1,
12211226
(code_offset + annotation.start_col.display).saturating_sub(left),
1222-
labeled_start,
1223-
style,
1227+
uline.label_start,
1228+
uline.style,
12241229
);
12251230
}
12261231
}

0 commit comments

Comments
 (0)