Skip to content

Commit f481879

Browse files
author
Jonathan Turner
committed
Fix a couple UI test failures
1 parent 8612838 commit f481879

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

src/librustc_errors/emitter.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,24 @@ impl EmitterWriter {
187187

188188
if let Some(ref cm) = self.cm {
189189
for span_label in msp.span_labels() {
190-
let lo = cm.lookup_char_pos(span_label.span.lo);
191-
let hi = cm.lookup_char_pos(span_label.span.hi);
190+
let mut lo = cm.lookup_char_pos(span_label.span.lo);
191+
let mut hi = cm.lookup_char_pos(span_label.span.hi);
192+
let mut is_minimized = false;
192193

193194
// If the span is multi-line, simplify down to the span of one character
194-
let (start_col, mut end_col, is_minimized) = if lo.line != hi.line {
195-
(lo.col, CharPos(lo.col.0 + 1), true)
196-
} else {
197-
(lo.col, hi.col, false)
198-
};
195+
if lo.line != hi.line {
196+
hi.line = lo.line;
197+
hi.col = CharPos(lo.col.0 + 1);
198+
is_minimized = true;
199+
}
199200

200201
// Watch out for "empty spans". If we get a span like 6..6, we
201202
// want to just display a `^` at 6, so convert that to
202203
// 6..7. This is degenerate input, but it's best to degrade
203204
// gracefully -- and the parser likes to supply a span like
204205
// that for EOF, in particular.
205-
if start_col == end_col {
206-
end_col.0 += 1;
206+
if lo.col == hi.col {
207+
hi.col = CharPos(lo.col.0 + 1);
207208
}
208209

209210
add_annotation_to_file(&mut output,
@@ -530,7 +531,7 @@ impl EmitterWriter {
530531
buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber);
531532
let loc = primary_lo.clone();
532533
buffer.append(buffer_msg_line_offset,
533-
&format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0),
534+
&format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0 + 1),
534535
Style::LineAndColumn);
535536
for i in 0..max_line_num_len {
536537
buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle);
@@ -593,6 +594,10 @@ impl EmitterWriter {
593594
}
594595
}
595596

597+
if let Some(ref primary_span) = msp.primary_span().as_ref() {
598+
self.render_macro_backtrace_old_school(primary_span, &mut buffer)?;
599+
}
600+
596601
// final step: take our styled buffer, render it, then output it
597602
emit_to_destination(&buffer.render(), level, &mut self.dst);
598603

@@ -1180,7 +1185,7 @@ impl EmitterWriter {
11801185
}
11811186
let snippet = cm.span_to_string(trace.call_site);
11821187
buffer.append(line_offset, &format!("{} ", snippet), Style::NoStyle);
1183-
buffer.append(line_offset, "Note", Style::Level(Level::Note));
1188+
buffer.append(line_offset, "note", Style::Level(Level::Note));
11841189
buffer.append(line_offset, ": ", Style::NoStyle);
11851190
buffer.append(line_offset, &diag_string, Style::OldSchoolNoteText);
11861191
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
error: mismatched types [--explain E0308]
1+
error[E0308]: mismatched types
22
--> $DIR/issue-26480.rs:27:19
3-
|>
4-
27 |> $arr.len() * size_of($arr[0]));
5-
|> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
6-
$DIR/issue-26480.rs:38:5: 38:19: note: in this expansion of write! (defined in $DIR/issue-26480.rs)
3+
|
4+
27 | $arr.len() * size_of($arr[0]));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
6+
$DIR/issue-26480.rs:38:5: 38:19 note: in this expansion of write! (defined in $DIR/issue-26480.rs)
77

88
error: non-scalar cast: `_` as `()`
99
--> $DIR/issue-26480.rs:33:19
10-
|>
11-
33 |> ($x:expr) => ($x as ())
12-
|> ^^^^^^^^
13-
$DIR/issue-26480.rs:39:5: 39:14: note: in this expansion of cast! (defined in $DIR/issue-26480.rs)
10+
|
11+
33 | ($x:expr) => ($x as ())
12+
| ^^^^^^^^
13+
$DIR/issue-26480.rs:39:5: 39:14 note: in this expansion of cast! (defined in $DIR/issue-26480.rs)
1414

1515
error: aborting due to 2 previous errors
16+
+8-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
error: mismatched types [--explain E0308]
1+
error[E0308]: mismatched types
22
--> $DIR/main.rs:14:18
3-
|>
4-
14 |> let x: u32 = (
5-
|> ^ expected u32, found ()
6-
note: expected type `u32`
7-
note: found type `()`
3+
|
4+
14 | let x: u32 = (
5+
| ^ expected u32, found ()
6+
|
7+
= note: expected type `u32`
8+
= note: found type `()`
89

910
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)