From 63523e4d1c2fe6683b035c6818cafa9f77614711 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 4 Dec 2021 14:34:20 -0500 Subject: [PATCH] Stabilize `-Z emit-future-incompat` as `--json future-incompat` --- compiler/rustc_interface/src/tests.rs | 1 - compiler/rustc_session/src/config.rs | 14 ++++++++++++-- compiler/rustc_session/src/options.rs | 5 +++-- compiler/rustc_session/src/session.rs | 2 +- src/test/ui/lint/future-incompat-test.rs | 2 +- src/tools/compiletest/src/runtest.rs | 3 ++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 6147311af61..c651feaaa66 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -651,7 +651,6 @@ macro_rules! untracked { untracked!(dump_mir_dir, String::from("abc")); untracked!(dump_mir_exclude_pass_number, true); untracked!(dump_mir_graphviz, true); - untracked!(emit_future_incompat_report, true); untracked!(emit_stack_sizes, true); untracked!(future_incompat_test, true); untracked!(hir_stats, true); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 16b68d95858..87e8e576117 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -746,6 +746,7 @@ fn default() -> Options { edition: DEFAULT_EDITION, json_artifact_notifications: false, json_unused_externs: false, + json_future_incompat: false, pretty: None, working_dir: RealFileName::LocalPath(std::env::current_dir().unwrap()), } @@ -1257,6 +1258,7 @@ pub struct JsonConfig { pub json_rendered: HumanReadableErrorType, pub json_artifact_notifications: bool, pub json_unused_externs: bool, + pub json_future_incompat: bool, } /// Parse the `--json` flag. @@ -1269,6 +1271,7 @@ pub fn parse_json(matches: &getopts::Matches) -> JsonConfig { let mut json_color = ColorConfig::Never; let mut json_artifact_notifications = false; let mut json_unused_externs = false; + let mut json_future_incompat = 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 @@ -1286,6 +1289,7 @@ pub fn parse_json(matches: &getopts::Matches) -> JsonConfig { "diagnostic-rendered-ansi" => json_color = ColorConfig::Always, "artifacts" => json_artifact_notifications = true, "unused-externs" => json_unused_externs = true, + "future-incompat" => json_future_incompat = true, s => early_error( ErrorOutputType::default(), &format!("unknown `--json` option `{}`", s), @@ -1298,6 +1302,7 @@ pub fn parse_json(matches: &getopts::Matches) -> JsonConfig { json_rendered: json_rendered(json_color), json_artifact_notifications, json_unused_externs, + json_future_incompat, } } @@ -2011,8 +2016,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let edition = parse_crate_edition(matches); - let JsonConfig { json_rendered, json_artifact_notifications, json_unused_externs } = - parse_json(matches); + let JsonConfig { + json_rendered, + json_artifact_notifications, + json_unused_externs, + json_future_incompat, + } = parse_json(matches); let error_format = parse_error_format(matches, color, json_rendered); @@ -2248,6 +2257,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { edition, json_artifact_notifications, json_unused_externs, + json_future_incompat, pretty, working_dir, } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 779f29e3dfe..8610d8c64bd 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -205,6 +205,9 @@ pub struct Options { /// `true` if we're emitting a JSON blob containing the unused externs json_unused_externs: bool [UNTRACKED], + /// `true` if we're emitting a JSON job containg a future-incompat report for lints + json_future_incompat: bool [TRACKED], + pretty: Option [UNTRACKED], /// The (potentially remapped) working directory @@ -1124,8 +1127,6 @@ mod parse { computed `block` spans (one span encompassing a block's terminator and \ all statements). If `-Z instrument-coverage` is also enabled, create \ an additional `.html` file showing the computed coverage spans."), - emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED], - "emits a future-incompatibility report for lints (RFC 2834)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), fewer_names: Option = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 54109559a3b..3f15de3ba69 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -280,7 +280,7 @@ pub fn finish_diagnostics(&self, registry: &Registry) { } fn emit_future_breakage(&self) { - if !self.opts.debugging_opts.emit_future_incompat_report { + if !self.opts.json_future_incompat { return; } diff --git a/src/test/ui/lint/future-incompat-test.rs b/src/test/ui/lint/future-incompat-test.rs index ce8c118dab2..c5f477cc450 100644 --- a/src/test/ui/lint/future-incompat-test.rs +++ b/src/test/ui/lint/future-incompat-test.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zfuture-incompat-test -Zemit-future-incompat-report +// compile-flags: -Zfuture-incompat-test // check-pass // The `-Zfuture-incompat-test flag causes any normal warning to be included diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 727eecbb732..f1f285ace17 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1802,6 +1802,7 @@ fn make_compile_args( // patterns still match the raw compiler output. if self.props.error_patterns.is_empty() { rustc.args(&["--error-format", "json"]); + rustc.args(&["--json", "future-incompat"]); } rustc.arg("-Zui-testing"); rustc.arg("-Zdeduplicate-diagnostics=no"); @@ -1809,11 +1810,11 @@ fn make_compile_args( Ui => { if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) { rustc.args(&["--error-format", "json"]); + rustc.args(&["--json", "future-incompat"]); } rustc.arg("-Ccodegen-units=1"); rustc.arg("-Zui-testing"); rustc.arg("-Zdeduplicate-diagnostics=no"); - rustc.arg("-Zemit-future-incompat-report"); } MirOpt => { rustc.args(&[