about summary refs log tree commit diff
path: root/src/libsyntax/errors/snippet/mod.rs
diff options
context:
space:
mode:
authorJonathan Turner <jturner@mozilla.com>2016-05-16 08:50:01 -0400
committerJonathan Turner <jturner@mozilla.com>2016-05-17 06:46:08 -0400
commitae1e73affed86261c25d78a83559ece534bbde21 (patch)
tree3045720ef30bcf1594895df02995ce6e5135b0ee /src/libsyntax/errors/snippet/mod.rs
parent5743564f2d0139b8249d2ede4e720a6452d9c1d9 (diff)
downloadrust-ae1e73affed86261c25d78a83559ece534bbde21.tar.gz
rust-ae1e73affed86261c25d78a83559ece534bbde21.zip
Print secondary labels as notes in old skool mode
Diffstat (limited to 'src/libsyntax/errors/snippet/mod.rs')
-rw-r--r--src/libsyntax/errors/snippet/mod.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libsyntax/errors/snippet/mod.rs b/src/libsyntax/errors/snippet/mod.rs
index 092effbb2f6..3b7e2f30706 100644
--- a/src/libsyntax/errors/snippet/mod.rs
+++ b/src/libsyntax/errors/snippet/mod.rs
@@ -90,6 +90,7 @@ pub enum Style {
     UnderlineSecondary,
     LabelPrimary,
     LabelSecondary,
+    OldSkoolNote,
     NoStyle,
 }
 
@@ -497,6 +498,28 @@ impl FileInfo {
                     match self.primary_span {
                         Some(span) => {
                             let lo = codemap.lookup_char_pos(span.lo);
+                            //Before each secondary line in old skool-mode, print the label
+                            //as an old-style note
+                            if !line.annotations[0].is_primary {
+                                if let Some(ann) = line.annotations[0].label.clone() {
+                                    output.push(RenderedLine {
+                                        text: vec![StyledString {
+                                            text: lo.file.name.clone(),
+                                            style: Style::FileNameStyle,
+                                        }, StyledString {
+                                            text: format!(":{}:{}: ", lo.line, lo.col.0 + 1),
+                                            style: Style::LineAndColumn,
+                                        }, StyledString {
+                                            text: format!("note: "),
+                                            style: Style::LabelSecondary,
+                                        }, StyledString {
+                                            text: format!("{}", ann),
+                                            style: Style::OldSkoolNote,
+                                        }],
+                                        kind: RenderedLineKind::Annotations,
+                                    });
+                                }
+                            }
                             rendered_lines[0].text.insert(0, StyledString {
                                 text: format!(":{} ", lo.line),
                                 style: Style::LineAndColumn,