remap_path_prefix: Vec::new(),
edition: DEFAULT_EDITION,
json_artifact_notifications: false,
+ json_unused_externs: false,
pretty: None,
}
}
///
/// 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) {
+pub fn parse_json(matches: &getopts::Matches) -> (HumanReadableErrorType, bool, bool) {
let mut json_rendered: fn(ColorConfig) -> HumanReadableErrorType =
HumanReadableErrorType::Default;
let mut json_color = ColorConfig::Never;
let mut json_artifact_notifications = false;
+ let mut json_unused_externs = false;
for option in matches.opt_strs("json") {
// For now conservatively forbid `--color` with `--json` since `--json`
// won't actually be emitting any colors and anything colorized is
"diagnostic-short" => json_rendered = HumanReadableErrorType::Short,
"diagnostic-rendered-ansi" => json_color = ColorConfig::Always,
"artifacts" => json_artifact_notifications = true,
+ "unused-externs" => json_unused_externs = true,
s => early_error(
ErrorOutputType::default(),
&format!("unknown `--json` option `{}`", s),
}
}
}
- (json_rendered(json_color), json_artifact_notifications)
+ (json_rendered(json_color), json_artifact_notifications, json_unused_externs)
}
/// Parses the `--error-format` flag.
let edition = parse_crate_edition(matches);
- let (json_rendered, json_artifact_notifications) = parse_json(matches);
+ let (json_rendered, json_artifact_notifications, json_unused_externs) = parse_json(matches);
let error_format = parse_error_format(matches, color, json_rendered);
let mut debugging_opts = build_debugging_options(matches, error_format);
check_debug_option_stability(&debugging_opts, error_format, json_rendered);
+ if !debugging_opts.unstable_options && json_unused_externs {
+ early_error(
+ error_format,
+ "the `-Z unstable-options` flag must also be passed to enable \
+ the flag `--json=unused-externs`",
+ );
+ }
+
let output_types = parse_output_types(&debugging_opts, matches, error_format);
let mut cg = build_codegen_options(matches, error_format);
remap_path_prefix,
edition,
json_artifact_notifications,
+ json_unused_externs,
pretty,
}
}