about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-09-25 03:48:32 +0200
committerGitHub <noreply@github.com>2019-09-25 03:48:32 +0200
commitfa6dfc995e2b0719d874d0f29352657814ef0873 (patch)
treec22d390654ed86c407d5c5ed67489da0f2a5934d
parent5ed746b55287690ee26b2d494a022bd0ffecdc11 (diff)
parent6d07874e883ae4334b42ef3ab04cc3f52ee711ee (diff)
downloadrust-fa6dfc995e2b0719d874d0f29352657814ef0873.tar.gz
rust-fa6dfc995e2b0719d874d0f29352657814ef0873.zip
Rollup merge of #64753 - ehuss:json-short-explain, r=Mark-Simulacrum
Don't emit explain with json short messages.

This fixes an issue where `--error-format=json --json=diagnostic-short` would emit the "For more information about this error" message, which doesn't match the behavior of `--error-format=short` which explicitly excludes it.
-rw-r--r--src/libsyntax/json.rs7
-rw-r--r--src/test/ui/json-short.stderr2
2 files changed, 7 insertions, 2 deletions
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs
index 5cdea3aabbe..2423e1070fc 100644
--- a/src/libsyntax/json.rs
+++ b/src/libsyntax/json.rs
@@ -112,6 +112,13 @@ impl Emitter for JsonEmitter {
             panic!("failed to print notification: {:?}", e);
         }
     }
+
+    fn should_show_explain(&self) -> bool {
+        match self.json_rendered {
+            HumanReadableErrorType::Short(_) => false,
+            _ => true,
+        }
+    }
 }
 
 // The following data types are provided just for serialisation.
diff --git a/src/test/ui/json-short.stderr b/src/test/ui/json-short.stderr
index 0a1fb567714..d9f68023ce7 100644
--- a/src/test/ui/json-short.stderr
+++ b/src/test/ui/json-short.stderr
@@ -15,5 +15,3 @@ started: https://doc.rust-lang.org/book/
 "}
 {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error
 "}
-{"message":"For more information about this error, try `rustc --explain E0601`.","code":null,"level":"failure-note","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0601`.
-"}