about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-09-17 14:10:48 -0700
committerGitHub <noreply@github.com>2019-09-17 14:10:48 -0700
commitffee7bbf9a3ae1cff2bdf3cb17d3f5d8b01951c0 (patch)
tree80c46ed4e03560b875ef34b0ccbade2e9757a56d /src/librustc_errors
parentec905cf9e5b8fea647ba49bf781366addef8f7e2 (diff)
parent02c1b892c1dfa6d0f00254f9c058ce7595921d61 (diff)
downloadrust-ffee7bbf9a3ae1cff2bdf3cb17d3f5d8b01951c0.tar.gz
rust-ffee7bbf9a3ae1cff2bdf3cb17d3f5d8b01951c0.zip
Rollup merge of #64429 - afnanenayet:afnan/fix-failure-note-json-level, r=Mark-Simulacrum
Fix failure note `to_str` implementation

Serialize the level to something a little more useful for a failure note struct. This fixes #60425.
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/emitter.rs15
-rw-r--r--src/librustc_errors/lib.rs2
2 files changed, 10 insertions, 7 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 66608361c8d..d238de2a17e 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -1144,15 +1144,18 @@ impl EmitterWriter {
                 buffer.prepend(0, " ", Style::NoStyle);
             }
             draw_note_separator(&mut buffer, 0, max_line_num_len + 1);
-            let level_str = level.to_string();
-            if !level_str.is_empty() {
-                buffer.append(0, &level_str, Style::MainHeaderMsg);
-                buffer.append(0, ": ", Style::NoStyle);
+            if *level != Level::FailureNote {
+                let level_str = level.to_string();
+                if !level_str.is_empty() {
+                    buffer.append(0, &level_str, Style::MainHeaderMsg);
+                    buffer.append(0, ": ", Style::NoStyle);
+                }
             }
             self.msg_to_buffer(&mut buffer, msg, max_line_num_len, "note", None);
         } else {
             let level_str = level.to_string();
-            if !level_str.is_empty() {
+            // The failure note level itself does not provide any useful diagnostic information
+            if *level != Level::FailureNote && !level_str.is_empty() {
                 buffer.append(0, &level_str, Style::Level(level.clone()));
             }
             // only render error codes, not lint codes
@@ -1161,7 +1164,7 @@ impl EmitterWriter {
                 buffer.append(0, &code, Style::Level(level.clone()));
                 buffer.append(0, "]", Style::Level(level.clone()));
             }
-            if !level_str.is_empty() {
+            if *level != Level::FailureNote && !level_str.is_empty() {
                 buffer.append(0, ": ", header_style);
             }
             for &(ref text, _) in msg.iter() {
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index c1fba416d64..8b543be6e64 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -833,7 +833,7 @@ impl Level {
             Warning => "warning",
             Note => "note",
             Help => "help",
-            FailureNote => "",
+            FailureNote => "failure-note",
             Cancelled => panic!("Shouldn't call on cancelled error"),
         }
     }