about summary refs log tree commit diff
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2020-07-05 19:35:46 +0200
committerest31 <MTest31@outlook.com>2021-03-08 08:17:48 +0100
commit2d5200605f18717efcb5483cfd2aece167cab7ce (patch)
tree01747dd2aab9560865e395124d3bbb5d96cdd463
parent3f2ca47a79911d422fd47ee2a23dd08a9fa42aa9 (diff)
downloadrust-2d5200605f18717efcb5483cfd2aece167cab7ce.tar.gz
rust-2d5200605f18717efcb5483cfd2aece167cab7ce.zip
Make parse_json return JsonConfig
-rw-r--r--compiler/rustc_session/src/config.rs19
-rw-r--r--src/librustdoc/config.rs2
2 files changed, 17 insertions, 4 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index a66201953d6..433b87aa3c6 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -1251,11 +1251,18 @@ pub fn parse_color(matches: &getopts::Matches) -> ColorConfig {
     }
 }
 
+/// Possible json config files
+pub struct JsonConfig {
+    pub json_rendered: HumanReadableErrorType,
+    pub json_artifact_notifications: bool,
+    pub json_unused_externs: bool,
+}
+
 /// Parse the `--json` flag.
 ///
 /// The first value returned is how to render JSON diagnostics, and the second
 /// is whether or not artifact notifications are enabled.
-pub fn parse_json(matches: &getopts::Matches) -> (HumanReadableErrorType, bool, bool) {
+pub fn parse_json(matches: &getopts::Matches) -> JsonConfig {
     let mut json_rendered: fn(ColorConfig) -> HumanReadableErrorType =
         HumanReadableErrorType::Default;
     let mut json_color = ColorConfig::Never;
@@ -1285,7 +1292,12 @@ pub fn parse_json(matches: &getopts::Matches) -> (HumanReadableErrorType, bool,
             }
         }
     }
-    (json_rendered(json_color), json_artifact_notifications, json_unused_externs)
+
+    JsonConfig {
+        json_rendered: json_rendered(json_color),
+        json_artifact_notifications,
+        json_unused_externs,
+    }
 }
 
 /// Parses the `--error-format` flag.
@@ -1863,7 +1875,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
     let edition = parse_crate_edition(matches);
 
-    let (json_rendered, json_artifact_notifications, json_unused_externs) = parse_json(matches);
+    let JsonConfig { json_rendered, json_artifact_notifications, json_unused_externs } =
+        parse_json(matches);
 
     let error_format = parse_error_format(matches, color, json_rendered);
 
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 5d6d5aaec14..112fe230916 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -323,7 +323,7 @@ impl Options {
         }
 
         let color = config::parse_color(&matches);
-        let (json_rendered, ..) = config::parse_json(&matches);
+        let config::JsonConfig { json_rendered, .. } = config::parse_json(&matches);
         let error_format = config::parse_error_format(&matches, color, json_rendered);
 
         let codegen_options = build_codegen_options(matches, error_format);