Skip to content

Commit 636fcac

Browse files
committed
Add -Zfuture-incompat-test to assist with testing future-incompat reports.
1 parent a08f25a commit 636fcac

File tree

8 files changed

+36
-17
lines changed

8 files changed

+36
-17
lines changed

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ fn test_debugging_options_tracking_hash() {
633633
untracked!(dump_mir_graphviz, true);
634634
untracked!(emit_future_incompat_report, true);
635635
untracked!(emit_stack_sizes, true);
636+
untracked!(future_incompat_test, true);
636637
untracked!(hir_stats, true);
637638
untracked!(identify_regions, true);
638639
untracked!(incremental_ignore_spans, true);

compiler/rustc_middle/src/lint.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir::HirId;
88
use rustc_index::vec::IndexVec;
99
use rustc_session::lint::{
1010
builtin::{self, FORBIDDEN_LINT_GROUPS},
11-
FutureIncompatibilityReason, FutureIncompatibleInfo, Level, Lint, LintId,
11+
FutureIncompatibilityReason, Level, Lint, LintId,
1212
};
1313
use rustc_session::{DiagnosticMessageId, Session};
1414
use rustc_span::hygiene::MacroKind;
@@ -223,12 +223,12 @@ pub fn struct_lint_level<'s, 'd>(
223223
let lint_id = LintId::of(lint);
224224
let future_incompatible = lint.future_incompatible;
225225

226-
let has_future_breakage = matches!(
227-
future_incompatible,
228-
Some(FutureIncompatibleInfo {
229-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
230-
..
231-
})
226+
let has_future_breakage = future_incompatible.map_or(
227+
// Default allow lints trigger too often for testing.
228+
sess.opts.debugging_opts.future_incompat_test && lint.default_level != Level::Allow,
229+
|incompat| {
230+
matches!(incompat.reason, FutureIncompatibilityReason::FutureReleaseErrorReportNow)
231+
},
232232
);
233233

234234
let mut err = match (level, span) {

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@ options! {
10841084
"set the optimization fuel quota for a crate"),
10851085
function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
10861086
"whether each function should go in its own section"),
1087+
future_incompat_test: bool = (false, parse_bool, [UNTRACKED],
1088+
"forces all lints to be future incompatible, used for internal testing (default: no)"),
10871089
gcc_ld: Option<LdImpl> = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"),
10881090
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
10891091
"use dark-themed colors in graphviz output (default: no)"),
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: -Zfuture-incompat-test -Zemit-future-incompat-report
2+
// check-pass
3+
4+
// The `-Zfuture-incompat-test flag causes any normal warning to be included
5+
// in the future-incompatible report. The stderr output here should mention
6+
// the future incompatible report (as extracted by compiletest).
7+
8+
fn main() {
9+
let x = 1;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Future incompatibility report: Future breakage diagnostic:
2+
warning: unused variable: `x`
3+
--> $DIR/future-incompat-test.rs:9:9
4+
|
5+
LL | let x = 1;
6+
| ^ help: if this is intentional, prefix it with an underscore: `_x`
7+
|
8+
= note: `-A unused-variables` implied by `-A unused`
9+

src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ LL | tuple_from_req!(Foo);
8181

8282
warning: 5 warnings emitted
8383

84-
Future incompatibility report: Future breakage date: None, diagnostic:
84+
Future incompatibility report: Future breakage diagnostic:
8585
warning: using an old version of `time-macros-impl`
8686
--> $DIR/time-macros-impl/src/lib.rs:5:32
8787
|
@@ -99,7 +99,7 @@ LL | impl_macros!(Foo);
9999
= note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
100100
= note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
101101

102-
Future breakage date: None, diagnostic:
102+
Future breakage diagnostic:
103103
warning: using an old version of `time-macros-impl`
104104
--> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32
105105
|
@@ -116,7 +116,7 @@ LL | impl_macros!(Foo);
116116
= note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
117117
= note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
118118

119-
Future breakage date: None, diagnostic:
119+
Future breakage diagnostic:
120120
warning: using an old version of `js-sys`
121121
--> $DIR/js-sys-0.3.17/src/lib.rs:5:32
122122
|
@@ -133,7 +133,7 @@ LL | arrays!(Foo);
133133
= note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above
134134
= note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)
135135

136-
Future breakage date: None, diagnostic:
136+
Future breakage diagnostic:
137137
warning: using an old version of `actix-web`
138138
--> $DIR/actix-web/src/extract.rs:5:34
139139
|
@@ -150,7 +150,7 @@ LL | tuple_from_req!(Foo);
150150
= note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
151151
= note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
152152

153-
Future breakage date: None, diagnostic:
153+
Future breakage diagnostic:
154154
warning: using an old version of `actix-web`
155155
--> $DIR/actix-web-2.0.0/src/extract.rs:5:34
156156
|

src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | enum ProceduralMasqueradeDummyType {
1111

1212
warning: 1 warning emitted
1313

14-
Future incompatibility report: Future breakage date: None, diagnostic:
14+
Future incompatibility report: Future breakage diagnostic:
1515
warning: using `procedural-masquerade` crate
1616
--> $DIR/issue-73933-procedural-masquerade.rs:8:6
1717
|

src/tools/compiletest/src/json.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct FutureIncompatReport {
4343

4444
#[derive(Deserialize)]
4545
struct FutureBreakageItem {
46-
future_breakage_date: Option<String>,
4746
diagnostic: Diagnostic,
4847
}
4948

@@ -104,9 +103,7 @@ pub fn extract_rendered(output: &str) -> String {
104103
.into_iter()
105104
.map(|item| {
106105
format!(
107-
"Future breakage date: {}, diagnostic:\n{}",
108-
item.future_breakage_date
109-
.unwrap_or_else(|| "None".to_string()),
106+
"Future breakage diagnostic:\n{}",
110107
item.diagnostic
111108
.rendered
112109
.unwrap_or_else(|| "Not rendered".to_string())

0 commit comments

Comments
 (0)