about summary refs log tree commit diff
path: root/src/libsyntax/errors
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-15 15:08:46 -0700
committerbors <bors@rust-lang.org>2016-05-15 15:08:46 -0700
commit5ebe41835fcc3dbfdbe282a9b4c3780968c0a97a (patch)
tree9a1f7d9e9674e795fae579a23c8ad4626a5cecef /src/libsyntax/errors
parente7420fbbae85a62a62163a2ac5c947b76a8eb62d (diff)
parent65cb5f73789723b5eeb4ba9332e3e034939369c4 (diff)
downloadrust-5ebe41835fcc3dbfdbe282a9b4c3780968c0a97a.tar.gz
rust-5ebe41835fcc3dbfdbe282a9b4c3780968c0a97a.zip
Auto merge of #33619 - jonathandturner:improve_structured_errors, r=nikomatsakis
Batch of improvements to errors for new error format

This is a batch of improvements to existing errors to help get the most out of the new error format.

* Added labels to primary spans (^^^) for a set of errors that didn't currently have them
* Highlight the source blue under the secondary notes for better readability
* Move some of the "Note:" into secondary spans+labels
* Fix span_label to take &mut instead, which makes it work the same as other methods in that set
Diffstat (limited to 'src/libsyntax/errors')
-rw-r--r--src/libsyntax/errors/mod.rs8
-rw-r--r--src/libsyntax/errors/snippet/mod.rs1
2 files changed, 5 insertions, 4 deletions
diff --git a/src/libsyntax/errors/mod.rs b/src/libsyntax/errors/mod.rs
index 04f540c81ae..7592214c0ab 100644
--- a/src/libsyntax/errors/mod.rs
+++ b/src/libsyntax/errors/mod.rs
@@ -235,17 +235,17 @@ impl<'a> DiagnosticBuilder<'a> {
     /// all, and you just supplied a `Span` to create the diagnostic,
     /// then the snippet will just include that `Span`, which is
     /// called the primary span.
-    pub fn span_label(mut self, span: Span, label: &fmt::Display)
-                      -> DiagnosticBuilder<'a> {
+    pub fn span_label(&mut self, span: Span, label: &fmt::Display)
+                      -> &mut DiagnosticBuilder<'a> {
         self.span.push_span_label(span, format!("{}", label));
         self
     }
 
-    pub fn note_expected_found(mut self,
+    pub fn note_expected_found(&mut self,
                                label: &fmt::Display,
                                expected: &fmt::Display,
                                found: &fmt::Display)
-                               -> DiagnosticBuilder<'a>
+                               -> &mut DiagnosticBuilder<'a>
     {
         // For now, just attach these as notes
         self.note(&format!("expected {} `{}`", label, expected));
diff --git a/src/libsyntax/errors/snippet/mod.rs b/src/libsyntax/errors/snippet/mod.rs
index 0699c6f4ac2..092effbb2f6 100644
--- a/src/libsyntax/errors/snippet/mod.rs
+++ b/src/libsyntax/errors/snippet/mod.rs
@@ -618,6 +618,7 @@ impl FileInfo {
                         styled_buffer.set_style(0, p, Style::UnderlinePrimary);
                     } else {
                         styled_buffer.putc(1, p, '-', Style::UnderlineSecondary);
+                        styled_buffer.set_style(0, p, Style::UnderlineSecondary);
                     }
                 }
             }