about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2017-01-11 13:55:41 -0800
committerEsteban Küber <esteban@kuber.com.ar>2017-01-17 14:28:53 -0800
commitfc774e629fd805ef46566894da482ed8be680303 (patch)
tree04e098b9d07adac374ea2cfe041c64df788d1430 /src
parentbd8e9b0c828bce489eb948853a6cf86b69b26799 (diff)
downloadrust-fc774e629fd805ef46566894da482ed8be680303.tar.gz
rust-fc774e629fd805ef46566894da482ed8be680303.zip
Teach Diagnostics to highlight text
Diffstat (limited to 'src')
-rw-r--r--src/librustc/lint/context.rs2
-rw-r--r--src/librustc_driver/test.rs4
-rw-r--r--src/librustc_errors/diagnostic.rs56
-rw-r--r--src/librustc_errors/emitter.rs101
-rw-r--r--src/librustc_errors/snippet.rs1
-rw-r--r--src/librustc_trans/back/write.rs4
-rw-r--r--src/libsyntax/json.rs20
-rw-r--r--src/test/compile-fail-fulldeps/proc-macro/signature.rs1
-rw-r--r--src/test/compile-fail/issue-27942.rs2
-rw-r--r--src/test/compile-fail/issue-37884.rs1
-rw-r--r--src/test/ui/compare-method/reordered-type-param.stderr2
-rw-r--r--src/test/ui/mismatched_types/E0053.rs (renamed from src/test/compile-fail/E0053.rs)0
-rw-r--r--src/test/ui/mismatched_types/E0053.stderr23
-rw-r--r--src/test/ui/mismatched_types/E0409.rs (renamed from src/test/compile-fail/E0409.rs)0
-rw-r--r--src/test/ui/mismatched_types/E0409.stderr19
-rw-r--r--src/test/ui/mismatched_types/issue-19109.rs (renamed from src/test/compile-fail/issue-19109.rs)0
-rw-r--r--src/test/ui/mismatched_types/issue-19109.stderr11
-rw-r--r--src/test/ui/mismatched_types/issue-35030.stderr2
-rw-r--r--src/test/ui/mismatched_types/issue-38371.stderr6
-rw-r--r--src/test/ui/mismatched_types/main.stderr2
-rw-r--r--src/test/ui/mismatched_types/overloaded-calls-bad.rs (renamed from src/test/compile-fail/overloaded-calls-bad.rs)0
-rw-r--r--src/test/ui/mismatched_types/overloaded-calls-bad.stderr23
-rw-r--r--src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs (renamed from src/test/compile-fail/trait-bounds-cant-coerce.rs)0
-rw-r--r--src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr11
-rw-r--r--src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr2
-rw-r--r--src/test/ui/resolve/token-error-correct-3.stderr2
-rw-r--r--src/test/ui/span/coerce-suggestions.stderr10
-rw-r--r--src/test/ui/span/issue-27522.stderr2
-rw-r--r--src/test/ui/span/move-closure.stderr2
29 files changed, 242 insertions, 67 deletions
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index 7d85f3607b5..4b731ed7a70 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -562,7 +562,7 @@ pub trait LintContext<'tcx>: Sized {
         let span = early_lint.diagnostic.span.primary_span().expect("early lint w/o primary span");
         let mut err = self.struct_span_lint(early_lint.id.lint,
                                             span,
-                                            &early_lint.diagnostic.message);
+                                            &early_lint.diagnostic.message());
         err.copy_details_not_message(&early_lint.diagnostic);
         err.emit();
     }
diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs
index ede35d052ad..4ce5f96f171 100644
--- a/src/librustc_driver/test.rs
+++ b/src/librustc_driver/test.rs
@@ -79,9 +79,9 @@ fn remove_message(e: &mut ExpectErrorEmitter, msg: &str, lvl: Level) {
 
 impl Emitter for ExpectErrorEmitter {
     fn emit(&mut self, db: &DiagnosticBuilder) {
-        remove_message(self, &db.message, db.level);
+        remove_message(self, &db.message(), db.level);
         for child in &db.children {
-            remove_message(self, &child.message, child.level);
+            remove_message(self, &child.message(), child.level);
         }
     }
 }
diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs
index 730ca8f9e2e..ac39af20189 100644
--- a/src/librustc_errors/diagnostic.rs
+++ b/src/librustc_errors/diagnostic.rs
@@ -14,12 +14,13 @@ use RenderSpan;
 use RenderSpan::Suggestion;
 use std::fmt;
 use syntax_pos::{MultiSpan, Span};
+use snippet::Style;
 
 #[must_use]
 #[derive(Clone, Debug, PartialEq)]
 pub struct Diagnostic {
     pub level: Level,
-    pub message: String,
+    pub message: Vec<(String, Style)>,
     pub code: Option<String>,
     pub span: MultiSpan,
     pub children: Vec<SubDiagnostic>,
@@ -29,7 +30,7 @@ pub struct Diagnostic {
 #[derive(Clone, Debug, PartialEq)]
 pub struct SubDiagnostic {
     pub level: Level,
-    pub message: String,
+    pub message: Vec<(String, Style)>,
     pub span: MultiSpan,
     pub render_span: Option<RenderSpan>,
 }
@@ -42,7 +43,7 @@ impl Diagnostic {
     pub fn new_with_code(level: Level, code: Option<String>, message: &str) -> Self {
         Diagnostic {
             level: level,
-            message: message.to_owned(),
+            message: vec![(message.to_owned(), Style::NoStyle)],
             code: code,
             span: MultiSpan::new(),
             children: vec![],
@@ -96,8 +97,14 @@ impl Diagnostic {
                                      -> &mut Self
     {
         // For now, just attach these as notes
-        self.note(&format!("expected {} `{}`{}", label, expected, expected_extra));
-        self.note(&format!("   found {} `{}`{}", label, found, found_extra));
+        self.highlighted_note(vec![
+            (format!("expected {} `", label), Style::NoStyle),
+            (format!("{}", expected), Style::Highlight),
+            (format!("`{}\n", expected_extra), Style::NoStyle),
+            (format!("   found {} `", label), Style::NoStyle),
+            (format!("{}", found), Style::Highlight),
+            (format!("`{}", found_extra), Style::NoStyle),
+        ]);
         self
     }
 
@@ -106,6 +113,11 @@ impl Diagnostic {
         self
     }
 
+    pub fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self {
+        self.sub_with_highlights(Level::Note, msg, MultiSpan::new(), None);
+        self
+    }
+
     pub fn span_note<S: Into<MultiSpan>>(&mut self,
                                          sp: S,
                                          msg: &str)
@@ -168,7 +180,11 @@ impl Diagnostic {
         self
     }
 
-    pub fn message(&self) -> &str {
+    pub fn message(&self) -> String {
+        self.message.iter().map(|i| i.0.to_owned()).collect::<String>()
+    }
+
+    pub fn styled_message(&self) -> &Vec<(String, Style)> {
         &self.message
     }
 
@@ -193,10 +209,36 @@ impl Diagnostic {
            render_span: Option<RenderSpan>) {
         let sub = SubDiagnostic {
             level: level,
-            message: message.to_owned(),
+            message: vec![(message.to_owned(), Style::NoStyle)],
             span: span,
             render_span: render_span,
         };
         self.children.push(sub);
     }
+
+    /// Convenience function for internal use, clients should use one of the
+    /// public methods above.
+    fn sub_with_highlights(&mut self,
+                           level: Level,
+                           message: Vec<(String, Style)>,
+                           span: MultiSpan,
+                           render_span: Option<RenderSpan>) {
+        let sub = SubDiagnostic {
+            level: level,
+            message: message,
+            span: span,
+            render_span: render_span,
+        };
+        self.children.push(sub);
+    }
+}
+
+impl SubDiagnostic {
+    pub fn message(&self) -> String {
+        self.message.iter().map(|i| i.0.to_owned()).collect::<String>()
+    }
+
+    pub fn styled_message(&self) -> &Vec<(String, Style)> {
+        &self.message
+    }
 }
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 77c6c368364..5d758d322c7 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -33,7 +33,11 @@ impl Emitter for EmitterWriter {
         let mut primary_span = db.span.clone();
         let mut children = db.children.clone();
         self.fix_multispans_in_std_macros(&mut primary_span, &mut children);
-        self.emit_messages_default(&db.level, &db.message, &db.code, &primary_span, &children);
+        self.emit_messages_default(&db.level,
+                                   &db.styled_message(),
+                                   &db.code,
+                                   &primary_span,
+                                   &children);
     }
 }
 
@@ -695,8 +699,8 @@ impl EmitterWriter {
         if spans_updated {
             children.push(SubDiagnostic {
                 level: Level::Note,
-                message: "this error originates in a macro outside of the current crate"
-                    .to_string(),
+                message: vec![("this error originates in a macro outside of the current crate"
+                    .to_string(), Style::NoStyle)],
                 span: MultiSpan::new(),
                 render_span: None,
             });
@@ -704,8 +708,14 @@ impl EmitterWriter {
     }
 
     /// Add a left margin to every line but the first, given a padding length and the label being
-    /// displayed.
-    fn msg_with_padding(&self, msg: &str, padding: usize, label: &str) -> String {
+    /// displayed, keeping the provided highlighting.
+    fn msg_to_buffer(&self,
+                     buffer: &mut StyledBuffer,
+                     msg: &Vec<(String, Style)>,
+                     padding: usize,
+                     label: &str,
+                     override_style: Option<Style>) {
+
         // The extra 5 ` ` is padding that's always needed to align to the `note: `:
         //
         //   error: message
@@ -726,20 +736,56 @@ impl EmitterWriter {
             .map(|_| " ")
             .collect::<String>();
 
-        msg.split('\n').enumerate().fold("".to_owned(), |mut acc, x| {
-            if x.0 != 0 {
-                acc.push_str("\n");
-                // Align every line with first one.
-                acc.push_str(&padding);
+        /// Return wether `style`, or the override if present and the style is `NoStyle`.
+        fn style_or_override(style: Style, override_style: Option<Style>) -> Style {
+            if let Some(o) = override_style {
+                if style == Style::NoStyle {
+                    return o;
+                }
+            }
+            style
+        }
+
+        let mut line_number = 0;
+
+        // Provided the following diagnostic message:
+        //
+        //     let msg = vec![
+        //       ("
+        //       ("highlighted multiline\nstring to\nsee how it ", Style::NoStyle),
+        //       ("looks", Style::Highlight),
+        //       ("with\nvery ", Style::NoStyle),
+        //       ("weird", Style::Highlight),
+        //       (" formats\n", Style::NoStyle),
+        //       ("see?", Style::Highlight),
+        //     ];
+        //
+        // the expected output on a note is (* surround the  highlighted text)
+        //
+        //        = note: highlighted multiline
+        //                string to
+        //                see how it *looks* with
+        //                very *weird* formats
+        //                see?
+        for &(ref text, ref style) in msg.iter() {
+            let lines = text.split('\n').collect::<Vec<_>>();
+            if lines.len() > 1 {
+                for (i, line) in lines.iter().enumerate() {
+                    if i != 0 {
+                        line_number += 1;
+                        buffer.append(line_number, &padding, Style::NoStyle);
+                    }
+                    buffer.append(line_number, line, style_or_override(*style, override_style));
+                }
+            } else {
+                buffer.append(line_number, text, style_or_override(*style, override_style));
             }
-            acc.push_str(&x.1);
-            acc
-        })
+        }
     }
 
     fn emit_message_default(&mut self,
                             msp: &MultiSpan,
-                            msg: &str,
+                            msg: &Vec<(String, Style)>,
                             code: &Option<String>,
                             level: &Level,
                             max_line_num_len: usize,
@@ -755,9 +801,7 @@ impl EmitterWriter {
             draw_note_separator(&mut buffer, 0, max_line_num_len + 1);
             buffer.append(0, &level.to_string(), Style::HeaderMsg);
             buffer.append(0, ": ", Style::NoStyle);
-
-            let message = self.msg_with_padding(msg, max_line_num_len, "note");
-            buffer.append(0, &message, Style::NoStyle);
+            self.msg_to_buffer(&mut buffer, msg, max_line_num_len, "note", None);
         } else {
             buffer.append(0, &level.to_string(), Style::Level(level.clone()));
             match code {
@@ -769,7 +813,9 @@ impl EmitterWriter {
                 _ => {}
             }
             buffer.append(0, ": ", Style::HeaderMsg);
-            buffer.append(0, msg, Style::HeaderMsg);
+            for &(ref text, _) in msg.iter() {
+                buffer.append(0, text, Style::HeaderMsg);
+            }
         }
 
         // Preprocess all the annotations so that they are grouped by file and by line number
@@ -879,7 +925,7 @@ impl EmitterWriter {
     fn emit_suggestion_default(&mut self,
                                suggestion: &CodeSuggestion,
                                level: &Level,
-                               msg: &str,
+                               msg: &Vec<(String, Style)>,
                                max_line_num_len: usize)
                                -> io::Result<()> {
         use std::borrow::Borrow;
@@ -890,9 +936,11 @@ impl EmitterWriter {
 
             buffer.append(0, &level.to_string(), Style::Level(level.clone()));
             buffer.append(0, ": ", Style::HeaderMsg);
-
-            let message = self.msg_with_padding(msg, max_line_num_len, "suggestion");
-            buffer.append(0, &message, Style::HeaderMsg);
+            self.msg_to_buffer(&mut buffer,
+                               msg,
+                               max_line_num_len,
+                               "suggestion",
+                               Some(Style::HeaderMsg));
 
             let lines = cm.span_to_lines(primary_span).unwrap();
 
@@ -921,7 +969,7 @@ impl EmitterWriter {
     }
     fn emit_messages_default(&mut self,
                              level: &Level,
-                             message: &String,
+                             message: &Vec<(String, Style)>,
                              code: &Option<String>,
                              span: &MultiSpan,
                              children: &Vec<SubDiagnostic>) {
@@ -942,7 +990,7 @@ impl EmitterWriter {
                     match child.render_span {
                         Some(FullSpan(ref msp)) => {
                             match self.emit_message_default(msp,
-                                                            &child.message,
+                                                            &child.styled_message(),
                                                             &None,
                                                             &child.level,
                                                             max_line_num_len,
@@ -954,7 +1002,7 @@ impl EmitterWriter {
                         Some(Suggestion(ref cs)) => {
                             match self.emit_suggestion_default(cs,
                                                                &child.level,
-                                                               &child.message,
+                                                               &child.styled_message(),
                                                                max_line_num_len) {
                                 Err(e) => panic!("failed to emit error: {}", e),
                                 _ => ()
@@ -962,7 +1010,7 @@ impl EmitterWriter {
                         },
                         None => {
                             match self.emit_message_default(&child.span,
-                                                            &child.message,
+                                                            &child.styled_message(),
                                                             &None,
                                                             &child.level,
                                                             max_line_num_len,
@@ -1197,6 +1245,7 @@ impl Destination {
                 self.start_attr(term::Attr::Bold)?;
                 self.start_attr(term::Attr::ForegroundColor(l.color()))?;
             }
+            Style::Highlight => self.start_attr(term::Attr::Bold)?,
         }
         Ok(())
     }
diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs
index b8c1726443d..18e7b324f08 100644
--- a/src/librustc_errors/snippet.rs
+++ b/src/librustc_errors/snippet.rs
@@ -185,4 +185,5 @@ pub enum Style {
     NoStyle,
     ErrorCode,
     Level(Level),
+    Highlight,
 }
diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs
index dac1e3b8dc1..96045c6c079 100644
--- a/src/librustc_trans/back/write.rs
+++ b/src/librustc_trans/back/write.rs
@@ -121,13 +121,13 @@ impl SharedEmitter {
 impl Emitter for SharedEmitter {
     fn emit(&mut self, db: &DiagnosticBuilder) {
         self.buffer.lock().unwrap().push(Diagnostic {
-            msg: db.message.to_string(),
+            msg: db.message(),
             code: db.code.clone(),
             lvl: db.level,
         });
         for child in &db.children {
             self.buffer.lock().unwrap().push(Diagnostic {
-                msg: child.message.to_string(),
+                msg: child.message(),
                 code: None,
                 lvl: child.level,
             });
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs
index a1c273baeea..27ecd23eb42 100644
--- a/src/libsyntax/json.rs
+++ b/src/libsyntax/json.rs
@@ -74,15 +74,15 @@ impl Emitter for JsonEmitter {
 // The following data types are provided just for serialisation.
 
 #[derive(RustcEncodable)]
-struct Diagnostic<'a> {
+struct Diagnostic {
     /// The primary error message.
-    message: &'a str,
+    message: String,
     code: Option<DiagnosticCode>,
     /// "error: internal compiler error", "error", "warning", "note", "help".
     level: &'static str,
     spans: Vec<DiagnosticSpan>,
     /// Associated diagnostic messages.
-    children: Vec<Diagnostic<'a>>,
+    children: Vec<Diagnostic>,
     /// The message as rustc would render it. Currently this is only
     /// `Some` for "suggestions", but eventually it will include all
     /// snippets.
@@ -148,12 +148,12 @@ struct DiagnosticCode {
     explanation: Option<&'static str>,
 }
 
-impl<'a> Diagnostic<'a> {
-    fn from_diagnostic_builder<'c>(db: &'c DiagnosticBuilder,
-                                   je: &JsonEmitter)
-                                   -> Diagnostic<'c> {
+impl Diagnostic {
+    fn from_diagnostic_builder(db: &DiagnosticBuilder,
+                               je: &JsonEmitter)
+                               -> Diagnostic {
         Diagnostic {
-            message: &db.message,
+            message: db.message(),
             code: DiagnosticCode::map_opt_string(db.code.clone(), je),
             level: db.level.to_str(),
             spans: DiagnosticSpan::from_multispan(&db.span, je),
@@ -164,9 +164,9 @@ impl<'a> Diagnostic<'a> {
         }
     }
 
-    fn from_sub_diagnostic<'c>(db: &'c SubDiagnostic, je: &JsonEmitter) -> Diagnostic<'c> {
+    fn from_sub_diagnostic(db: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic {
         Diagnostic {
-            message: &db.message,
+            message: db.message(),
             code: None,
             level: db.level.to_str(),
             spans: db.render_span.as_ref()
diff --git a/src/test/compile-fail-fulldeps/proc-macro/signature.rs b/src/test/compile-fail-fulldeps/proc-macro/signature.rs
index 6d6b5a23e94..e249c9e9aa2 100644
--- a/src/test/compile-fail-fulldeps/proc-macro/signature.rs
+++ b/src/test/compile-fail-fulldeps/proc-macro/signature.rs
@@ -18,6 +18,5 @@ pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
     //~^ ERROR: mismatched types
     //~| NOTE: expected normal fn, found unsafe fn
     //~| NOTE: expected type `fn(proc_macro::TokenStream) -> proc_macro::TokenStream`
-    //~| NOTE: found type `unsafe extern "C" fn(i32, u32) -> u32 {foo}`
     loop {}
 }
diff --git a/src/test/compile-fail/issue-27942.rs b/src/test/compile-fail/issue-27942.rs
index b8552794eb5..595e4bfb0d7 100644
--- a/src/test/compile-fail/issue-27942.rs
+++ b/src/test/compile-fail/issue-27942.rs
@@ -15,13 +15,11 @@ pub trait Buffer<'a, R: Resources<'a>> {
     //~^ ERROR mismatched types
     //~| lifetime mismatch
     //~| NOTE expected type `Resources<'_>`
-    //~| NOTE    found type `Resources<'a>`
     //~| NOTE the lifetime 'a as defined on the method body at 14:4...
     //~| NOTE ...does not necessarily outlive the anonymous lifetime #1 defined on the method body
     //~| ERROR mismatched types
     //~| lifetime mismatch
     //~| NOTE expected type `Resources<'_>`
-    //~| NOTE    found type `Resources<'a>`
     //~| NOTE the anonymous lifetime #1 defined on the method body at 14:4...
     //~| NOTE ...does not necessarily outlive the lifetime 'a as defined on the method body
 }
diff --git a/src/test/compile-fail/issue-37884.rs b/src/test/compile-fail/issue-37884.rs
index a73b1dbe34c..6e1b9b2fbed 100644
--- a/src/test/compile-fail/issue-37884.rs
+++ b/src/test/compile-fail/issue-37884.rs
@@ -16,7 +16,6 @@ impl<'a, T: 'a> Iterator for RepeatMut<'a, T> {
     //~^ ERROR method not compatible with trait
     //~| lifetime mismatch
     //~| NOTE expected type `fn(&mut RepeatMut<'a, T>) -> std::option::Option<&mut T>`
-    //~| NOTE    found type `fn(&'a mut RepeatMut<'a, T>) -> std::option::Option<&mut T>`
     {
     //~^ NOTE the anonymous lifetime #1 defined on the body
     //~| NOTE ...does not necessarily outlive the lifetime 'a as defined on the body
diff --git a/src/test/ui/compare-method/reordered-type-param.stderr b/src/test/ui/compare-method/reordered-type-param.stderr
index 985b85cc4ec..4620248e2ef 100644
--- a/src/test/ui/compare-method/reordered-type-param.stderr
+++ b/src/test/ui/compare-method/reordered-type-param.stderr
@@ -8,7 +8,7 @@ error[E0053]: method `b` has an incompatible type for trait
    |                              ^ expected type parameter, found a different type parameter
    |
    = note: expected type `fn(&E, F) -> F`
-   = note:    found type `fn(&E, G) -> G`
+              found type `fn(&E, G) -> G`
 
 error: aborting due to previous error
 
diff --git a/src/test/compile-fail/E0053.rs b/src/test/ui/mismatched_types/E0053.rs
index 933462e553e..933462e553e 100644
--- a/src/test/compile-fail/E0053.rs
+++ b/src/test/ui/mismatched_types/E0053.rs
diff --git a/src/test/ui/mismatched_types/E0053.stderr b/src/test/ui/mismatched_types/E0053.stderr
new file mode 100644
index 00000000000..b6e3d663e36
--- /dev/null
+++ b/src/test/ui/mismatched_types/E0053.stderr
@@ -0,0 +1,23 @@
+error[E0053]: method `foo` has an incompatible type for trait
+  --> $DIR/E0053.rs:19:15
+   |
+12 |     fn foo(x: u16); //~ NOTE type in trait
+   |               --- type in trait
+...
+19 |     fn foo(x: i16) { }
+   |               ^^^ expected u16, found i16
+
+error[E0053]: method `bar` has an incompatible type for trait
+  --> $DIR/E0053.rs:22:12
+   |
+13 |     fn bar(&self); //~ NOTE type in trait
+   |            ----- type in trait
+...
+22 |     fn bar(&mut self) { }
+   |            ^^^^^^^^^ types differ in mutability
+   |
+   = note: expected type `fn(&Bar)`
+              found type `fn(&mut Bar)`
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/compile-fail/E0409.rs b/src/test/ui/mismatched_types/E0409.rs
index e89cc9ea5cb..e89cc9ea5cb 100644
--- a/src/test/compile-fail/E0409.rs
+++ b/src/test/ui/mismatched_types/E0409.rs
diff --git a/src/test/ui/mismatched_types/E0409.stderr b/src/test/ui/mismatched_types/E0409.stderr
new file mode 100644
index 00000000000..251e247fa28
--- /dev/null
+++ b/src/test/ui/mismatched_types/E0409.stderr
@@ -0,0 +1,19 @@
+error[E0409]: variable `y` is bound with different mode in pattern #2 than in pattern #1
+  --> $DIR/E0409.rs:15:23
+   |
+15 |         (0, ref y) | (y, 0) => {} //~ ERROR E0409
+   |                 -     ^ bound in different ways
+   |                 |
+   |                 first binding
+
+error[E0308]: mismatched types
+  --> $DIR/E0409.rs:15:23
+   |
+15 |         (0, ref y) | (y, 0) => {} //~ ERROR E0409
+   |                       ^ expected &{integer}, found integral variable
+   |
+   = note: expected type `&{integer}`
+              found type `{integer}`
+
+error: aborting due to previous error
+
diff --git a/src/test/compile-fail/issue-19109.rs b/src/test/ui/mismatched_types/issue-19109.rs
index 580684e2e14..580684e2e14 100644
--- a/src/test/compile-fail/issue-19109.rs
+++ b/src/test/ui/mismatched_types/issue-19109.rs
diff --git a/src/test/ui/mismatched_types/issue-19109.stderr b/src/test/ui/mismatched_types/issue-19109.stderr
new file mode 100644
index 00000000000..4067507c964
--- /dev/null
+++ b/src/test/ui/mismatched_types/issue-19109.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-19109.rs:14:5
+   |
+14 |     t as *mut Trait
+   |     ^^^^^^^^^^^^^^^ expected (), found *-ptr
+   |
+   = note: expected type `()`
+              found type `*mut Trait`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/mismatched_types/issue-35030.stderr b/src/test/ui/mismatched_types/issue-35030.stderr
index aa017297a4e..46d690c5f03 100644
--- a/src/test/ui/mismatched_types/issue-35030.stderr
+++ b/src/test/ui/mismatched_types/issue-35030.stderr
@@ -5,7 +5,7 @@ error[E0308]: mismatched types
    |              ^^^^ expected type parameter, found bool
    |
    = note: expected type `bool` (type parameter)
-   = note:    found type `bool` (bool)
+              found type `bool` (bool)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/mismatched_types/issue-38371.stderr b/src/test/ui/mismatched_types/issue-38371.stderr
index b0e56094fcf..9efee4cc559 100644
--- a/src/test/ui/mismatched_types/issue-38371.stderr
+++ b/src/test/ui/mismatched_types/issue-38371.stderr
@@ -5,7 +5,7 @@ error[E0308]: mismatched types
    |        ^^^^ expected struct `Foo`, found reference
    |
    = note: expected type `Foo`
-   = note:    found type `&_`
+              found type `&_`
    = help: did you mean `foo: &Foo`?
 
 error[E0308]: mismatched types
@@ -15,7 +15,7 @@ error[E0308]: mismatched types
    |         ^^^^ expected u32, found reference
    |
    = note: expected type `u32`
-   = note:    found type `&_`
+              found type `&_`
 
 error[E0308]: mismatched types
   --> $DIR/issue-38371.rs:31:8
@@ -24,7 +24,7 @@ error[E0308]: mismatched types
    |        ^^^^^ expected u32, found reference
    |
    = note: expected type `u32`
-   = note:    found type `&_`
+              found type `&_`
 
 error[E0529]: expected an array or slice, found `u32`
   --> $DIR/issue-38371.rs:34:9
diff --git a/src/test/ui/mismatched_types/main.stderr b/src/test/ui/mismatched_types/main.stderr
index c87b635521e..5dd124ebcdf 100644
--- a/src/test/ui/mismatched_types/main.stderr
+++ b/src/test/ui/mismatched_types/main.stderr
@@ -7,7 +7,7 @@ error[E0308]: mismatched types
    | |_____^ ...ending here: expected u32, found ()
    |
    = note: expected type `u32`
-   = note:    found type `()`
+              found type `()`
 
 error: aborting due to previous error
 
diff --git a/src/test/compile-fail/overloaded-calls-bad.rs b/src/test/ui/mismatched_types/overloaded-calls-bad.rs
index 3295e2bebd2..3295e2bebd2 100644
--- a/src/test/compile-fail/overloaded-calls-bad.rs
+++ b/src/test/ui/mismatched_types/overloaded-calls-bad.rs
diff --git a/src/test/ui/mismatched_types/overloaded-calls-bad.stderr b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr
new file mode 100644
index 00000000000..cd05684f15d
--- /dev/null
+++ b/src/test/ui/mismatched_types/overloaded-calls-bad.stderr
@@ -0,0 +1,23 @@
+error[E0308]: mismatched types
+  --> $DIR/overloaded-calls-bad.rs:38:17
+   |
+38 |     let ans = s("what");    //~ ERROR mismatched types
+   |                 ^^^^^^ expected isize, found reference
+   |
+   = note: expected type `isize`
+              found type `&'static str`
+
+error[E0057]: this function takes 1 parameter but 0 parameters were supplied
+  --> $DIR/overloaded-calls-bad.rs:42:15
+   |
+42 |     let ans = s();
+   |               ^^^ expected 1 parameter
+
+error[E0057]: this function takes 1 parameter but 2 parameters were supplied
+  --> $DIR/overloaded-calls-bad.rs:45:17
+   |
+45 |     let ans = s("burma", "shave");
+   |                 ^^^^^^^^^^^^^^^^ expected 1 parameter
+
+error: aborting due to 3 previous errors
+
diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs
index 9f832c7b6e5..9f832c7b6e5 100644
--- a/src/test/compile-fail/trait-bounds-cant-coerce.rs
+++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.rs
diff --git a/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr
new file mode 100644
index 00000000000..c47975b0135
--- /dev/null
+++ b/src/test/ui/mismatched_types/trait-bounds-cant-coerce.stderr
@@ -0,0 +1,11 @@
+error[E0308]: mismatched types
+  --> $DIR/trait-bounds-cant-coerce.rs:24:7
+   |
+24 |     a(x); //~ ERROR mismatched types [E0308]
+   |       ^ expected trait `Foo + std::marker::Send`, found trait `Foo`
+   |
+   = note: expected type `Box<Foo + std::marker::Send + 'static>`
+              found type `Box<Foo + 'static>`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr
index 4a0ccc46525..991197c2afb 100644
--- a/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr
+++ b/src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr
@@ -17,7 +17,7 @@ error[E0053]: method `bar` has an incompatible type for trait
    |                            ^^^^ types differ in mutability
    |
    = note: expected type `fn(&mut Bar, &mut Bar)`
-   = note:    found type `fn(&mut Bar, &Bar)`
+              found type `fn(&mut Bar, &Bar)`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr
index adb88ab572c..56e36889575 100644
--- a/src/test/ui/resolve/token-error-correct-3.stderr
+++ b/src/test/ui/resolve/token-error-correct-3.stderr
@@ -35,7 +35,7 @@ error[E0308]: mismatched types
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `std::result::Result`
    |
    = note: expected type `()`
-   = note:    found type `std::result::Result<bool, std::io::Error>`
+              found type `std::result::Result<bool, std::io::Error>`
    = help: here are some functions which might fulfill your needs:
            - .unwrap()
            - .unwrap_err()
diff --git a/src/test/ui/span/coerce-suggestions.stderr b/src/test/ui/span/coerce-suggestions.stderr
index ed1bcd318a4..c32fefcd0d6 100644
--- a/src/test/ui/span/coerce-suggestions.stderr
+++ b/src/test/ui/span/coerce-suggestions.stderr
@@ -5,7 +5,7 @@ error[E0308]: mismatched types
    |                    ^^^^^^^^^^^^^ expected usize, found struct `std::string::String`
    |
    = note: expected type `usize`
-   = note:    found type `std::string::String`
+              found type `std::string::String`
    = help: here are some functions which might fulfill your needs:
            - .capacity()
            - .len()
@@ -17,7 +17,7 @@ error[E0308]: mismatched types
    |                   ^^^^^^^^^^^^^ expected &str, found struct `std::string::String`
    |
    = note: expected type `&str`
-   = note:    found type `std::string::String`
+              found type `std::string::String`
    = help: here are some functions which might fulfill your needs:
            - .as_str()
            - .trim()
@@ -31,7 +31,7 @@ error[E0308]: mismatched types
    |          ^^ types differ in mutability
    |
    = note: expected type `&mut std::string::String`
-   = note:    found type `&std::string::String`
+              found type `&std::string::String`
 
 error[E0308]: mismatched types
   --> $DIR/coerce-suggestions.rs:36:11
@@ -40,7 +40,7 @@ error[E0308]: mismatched types
    |           ^^ types differ in mutability
    |
    = note: expected type `&mut i32`
-   = note:    found type `&std::string::String`
+              found type `&std::string::String`
 
 error[E0308]: mismatched types
   --> $DIR/coerce-suggestions.rs:42:9
@@ -49,7 +49,7 @@ error[E0308]: mismatched types
    |         ^^^^^ cyclic type of infinite size
    |
    = note: expected type `_`
-   = note:    found type `Box<_>`
+              found type `Box<_>`
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/span/issue-27522.stderr b/src/test/ui/span/issue-27522.stderr
index 71130f4947a..117b109780b 100644
--- a/src/test/ui/span/issue-27522.stderr
+++ b/src/test/ui/span/issue-27522.stderr
@@ -5,7 +5,7 @@ error[E0308]: mismatched method receiver
    |                      ^^^^^^^^^ expected Self, found struct `SomeType`
    |
    = note: expected type `&Self`
-   = note:    found type `&SomeType`
+              found type `&SomeType`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/span/move-closure.stderr b/src/test/ui/span/move-closure.stderr
index 251feded167..2294e6476d6 100644
--- a/src/test/ui/span/move-closure.stderr
+++ b/src/test/ui/span/move-closure.stderr
@@ -5,7 +5,7 @@ error[E0308]: mismatched types
    |                 ^^^^^^^^^^ expected (), found closure
    |
    = note: expected type `()`
-   = note:    found type `[closure@$DIR/move-closure.rs:15:17: 15:27]`
+              found type `[closure@$DIR/move-closure.rs:15:17: 15:27]`
 
 error: aborting due to previous error