Skip to content

Commit 2d52006

Browse files
committed
Make parse_json return JsonConfig
1 parent 3f2ca47 commit 2d52006

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,11 +1251,18 @@ pub fn parse_color(matches: &getopts::Matches) -> ColorConfig {
12511251
}
12521252
}
12531253

1254+
/// Possible json config files
1255+
pub struct JsonConfig {
1256+
pub json_rendered: HumanReadableErrorType,
1257+
pub json_artifact_notifications: bool,
1258+
pub json_unused_externs: bool,
1259+
}
1260+
12541261
/// Parse the `--json` flag.
12551262
///
12561263
/// The first value returned is how to render JSON diagnostics, and the second
12571264
/// is whether or not artifact notifications are enabled.
1258-
pub fn parse_json(matches: &getopts::Matches) -> (HumanReadableErrorType, bool, bool) {
1265+
pub fn parse_json(matches: &getopts::Matches) -> JsonConfig {
12591266
let mut json_rendered: fn(ColorConfig) -> HumanReadableErrorType =
12601267
HumanReadableErrorType::Default;
12611268
let mut json_color = ColorConfig::Never;
@@ -1285,7 +1292,12 @@ pub fn parse_json(matches: &getopts::Matches) -> (HumanReadableErrorType, bool,
12851292
}
12861293
}
12871294
}
1288-
(json_rendered(json_color), json_artifact_notifications, json_unused_externs)
1295+
1296+
JsonConfig {
1297+
json_rendered: json_rendered(json_color),
1298+
json_artifact_notifications,
1299+
json_unused_externs,
1300+
}
12891301
}
12901302

12911303
/// Parses the `--error-format` flag.
@@ -1863,7 +1875,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
18631875

18641876
let edition = parse_crate_edition(matches);
18651877

1866-
let (json_rendered, json_artifact_notifications, json_unused_externs) = parse_json(matches);
1878+
let JsonConfig { json_rendered, json_artifact_notifications, json_unused_externs } =
1879+
parse_json(matches);
18671880

18681881
let error_format = parse_error_format(matches, color, json_rendered);
18691882

src/librustdoc/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl Options {
323323
}
324324

325325
let color = config::parse_color(&matches);
326-
let (json_rendered, ..) = config::parse_json(&matches);
326+
let config::JsonConfig { json_rendered, .. } = config::parse_json(&matches);
327327
let error_format = config::parse_error_format(&matches, color, json_rendered);
328328

329329
let codegen_options = build_codegen_options(matches, error_format);

0 commit comments

Comments
 (0)