]> git.lizzy.rs Git - rust.git/commitdiff
Fix a couple UI test failures
authorJonathan Turner <jturner@mozilla.com>
Tue, 12 Jul 2016 16:37:57 +0000 (12:37 -0400)
committerJonathan Turner <jturner@mozilla.com>
Thu, 14 Jul 2016 11:57:46 +0000 (07:57 -0400)
src/librustc_errors/emitter.rs
src/test/ui/mismatched_types/issue-26480.stderr
src/test/ui/mismatched_types/main.stderr

index 037d64ba128fbc02571dfbb58310b48289601821..5147318d4a63d4e63716b326eb1d0c96229e8221 100644 (file)
@@ -187,23 +187,24 @@ fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
 
         if let Some(ref cm) = self.cm {
             for span_label in msp.span_labels() {
-                let lo = cm.lookup_char_pos(span_label.span.lo);
-                let hi = cm.lookup_char_pos(span_label.span.hi);
+                let mut lo = cm.lookup_char_pos(span_label.span.lo);
+                let mut hi = cm.lookup_char_pos(span_label.span.hi);
+                let mut is_minimized = false;
 
                 // If the span is multi-line, simplify down to the span of one character
-                let (start_col, mut end_col, is_minimized) = if lo.line != hi.line {
-                    (lo.col, CharPos(lo.col.0 + 1), true)
-                } else {
-                    (lo.col, hi.col, false)
-                };
+                if lo.line != hi.line {
+                    hi.line = lo.line;
+                    hi.col = CharPos(lo.col.0 + 1);
+                    is_minimized = true;
+                }
 
                 // Watch out for "empty spans". If we get a span like 6..6, we
                 // want to just display a `^` at 6, so convert that to
                 // 6..7. This is degenerate input, but it's best to degrade
                 // gracefully -- and the parser likes to supply a span like
                 // that for EOF, in particular.
-                if start_col == end_col {
-                    end_col.0 += 1;
+                if lo.col == hi.col {
+                    hi.col = CharPos(lo.col.0 + 1);
                 }
 
                 add_annotation_to_file(&mut output,
@@ -530,7 +531,7 @@ fn emit_message_default(&mut self,
                 buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber);
                 let loc = primary_lo.clone();
                 buffer.append(buffer_msg_line_offset,
-                                &format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0),
+                                &format!("{}:{}:{}", loc.file.name, loc.line, loc.col.0 + 1),
                                 Style::LineAndColumn);
                 for i in 0..max_line_num_len {
                     buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle);
@@ -593,6 +594,10 @@ fn emit_message_default(&mut self,
             }
         }
 
+        if let Some(ref primary_span) = msp.primary_span().as_ref() {
+            self.render_macro_backtrace_old_school(primary_span, &mut buffer)?;
+        }
+
         // final step: take our styled buffer, render it, then output it
         emit_to_destination(&buffer.render(), level, &mut self.dst);
 
@@ -1180,7 +1185,7 @@ fn render_macro_backtrace_old_school(&mut self,
                 }
                 let snippet = cm.span_to_string(trace.call_site);
                 buffer.append(line_offset, &format!("{} ", snippet), Style::NoStyle);
-                buffer.append(line_offset, "Note", Style::Level(Level::Note));
+                buffer.append(line_offset, "note", Style::Level(Level::Note));
                 buffer.append(line_offset, ": ", Style::NoStyle);
                 buffer.append(line_offset, &diag_string, Style::OldSchoolNoteText);
             }
index c00594a59c1150fc6f8dde664fcf3b440a736c4b..63f2ab4d7c6bf2db1c359587945a0de724c7db9f 100644 (file)
@@ -1,15 +1,16 @@
-error: mismatched types [--explain E0308]
+error[E0308]: mismatched types
   --> $DIR/issue-26480.rs:27:19
-   |>
-27 |>                   $arr.len() * size_of($arr[0]));
-   |>                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
-$DIR/issue-26480.rs:38:5: 38:19: note: in this expansion of write! (defined in $DIR/issue-26480.rs)
+   | 
+27 |                   $arr.len() * size_of($arr[0]));
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
+$DIR/issue-26480.rs:38:5: 38:19 note: in this expansion of write! (defined in $DIR/issue-26480.rs)
 
 error: non-scalar cast: `_` as `()`
   --> $DIR/issue-26480.rs:33:19
-   |>
-33 |>     ($x:expr) => ($x as ())
-   |>                   ^^^^^^^^
-$DIR/issue-26480.rs:39:5: 39:14: note: in this expansion of cast! (defined in $DIR/issue-26480.rs)
+   | 
+33 |     ($x:expr) => ($x as ())
+   |                   ^^^^^^^^
+$DIR/issue-26480.rs:39:5: 39:14 note: in this expansion of cast! (defined in $DIR/issue-26480.rs)
 
 error: aborting due to 2 previous errors
+
index 1af332ee5bea7036b7f216bb554b6c3420a4f67e..ae1d417eca9ee938d3951a9b28e6f4a427979c65 100644 (file)
@@ -1,9 +1,11 @@
-error: mismatched types [--explain E0308]
+error[E0308]: mismatched types
   --> $DIR/main.rs:14:18
-   |>
-14 |>     let x: u32 = (
-   |>                  ^ expected u32, found ()
-note: expected type `u32`
-note:    found type `()`
+   | 
+14 |     let x: u32 = (
+   |                  ^ expected u32, found ()
+   | 
+   = note: expected type `u32`
+   = note:    found type `()`
 
 error: aborting due to previous error
+