11//! Tests for future-incompat-report messages
2+ //!
3+ //! Note that these tests use the -Zfuture-incompat-test for rustc.
4+ //! This causes rustc to treat *every* lint as future-incompatible.
5+ //! This is done because future-incompatible lints are inherently
6+ //! ephemeral, but we don't want to continually update these tests.
7+ //! So we pick some random lint that will likely always be the same
8+ //! over time.
29
310use cargo_test_support:: registry:: Package ;
411use cargo_test_support:: { basic_manifest, is_nightly, project, Project } ;
512
6- // An arbitrary lint (array_into_iter) that triggers a report.
7- const FUTURE_EXAMPLE : & ' static str = "fn main() { [true].into_iter(); }" ;
13+ // An arbitrary lint (unused_variables) that triggers a lint.
14+ // We use a special flag to force it to generate a report.
15+ const FUTURE_EXAMPLE : & ' static str = "fn main() { let x = 1; }" ;
816// Some text that will be displayed when the lint fires.
9- const FUTURE_OUTPUT : & ' static str = "[..]array_into_iter [..]" ;
17+ const FUTURE_OUTPUT : & ' static str = "[..]unused_variables [..]" ;
1018
1119fn simple_project ( ) -> Project {
1220 project ( )
@@ -17,9 +25,15 @@ fn simple_project() -> Project {
1725
1826#[ cargo_test]
1927fn no_output_on_stable ( ) {
28+ if !is_nightly ( ) {
29+ // -Zfuture-incompat-test requires nightly (permanently)
30+ return ;
31+ }
2032 let p = simple_project ( ) ;
2133
22- p. cargo ( "build" )
34+ p. cargo ( "check" )
35+ // Even though rustc emits the report, cargo ignores it without -Z.
36+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
2337 . with_stderr_contains ( FUTURE_OUTPUT )
2438 . with_stderr_does_not_contain ( "[..]cargo report[..]" )
2539 . run ( ) ;
@@ -58,6 +72,7 @@ fn gate_future_incompat_report() {
5872#[ cargo_test]
5973fn test_zero_future_incompat ( ) {
6074 if !is_nightly ( ) {
75+ // -Zfuture-incompat-test requires nightly (permanently)
6176 return ;
6277 }
6378
@@ -69,6 +84,7 @@ fn test_zero_future_incompat() {
6984 // No note if --future-incompat-report is not specified.
7085 p. cargo ( "build -Z future-incompat-report" )
7186 . masquerade_as_nightly_cargo ( )
87+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
7288 . with_stderr (
7389 "\
7490 [COMPILING] foo v0.0.0 [..]
@@ -79,6 +95,7 @@ fn test_zero_future_incompat() {
7995
8096 p. cargo ( "build --future-incompat-report -Z unstable-options -Z future-incompat-report" )
8197 . masquerade_as_nightly_cargo ( )
98+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
8299 . with_stderr (
83100 "\
84101 [FINISHED] [..]
@@ -89,9 +106,9 @@ note: 0 dependencies had future-incompatible warnings
89106}
90107
91108#[ cargo_test]
92- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
93109fn test_single_crate ( ) {
94110 if !is_nightly ( ) {
111+ // -Zfuture-incompat-test requires nightly (permanently)
95112 return ;
96113 }
97114
@@ -100,13 +117,15 @@ fn test_single_crate() {
100117 for command in & [ "build" , "check" , "rustc" , "test" ] {
101118 p. cargo ( command) . arg ( "-Zfuture-incompat-report" )
102119 . masquerade_as_nightly_cargo ( )
120+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
103121 . with_stderr_contains ( FUTURE_OUTPUT )
104122 . with_stderr_contains ( "warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]" )
105123 . with_stderr_does_not_contain ( "[..]incompatibility[..]" )
106124 . run ( ) ;
107125
108126 p. cargo ( command) . arg ( "-Zfuture-incompat-report" ) . arg ( "-Zunstable-options" ) . arg ( "--future-incompat-report" )
109127 . masquerade_as_nightly_cargo ( )
128+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
110129 . with_stderr_contains ( FUTURE_OUTPUT )
111130 . with_stderr_contains ( "warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]" )
112131 . with_stderr_contains ( "The package `foo v0.0.0 ([..])` currently triggers the following future incompatibility lints:" )
@@ -115,9 +134,9 @@ fn test_single_crate() {
115134}
116135
117136#[ cargo_test]
118- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
119137fn test_multi_crate ( ) {
120138 if !is_nightly ( ) {
139+ // -Zfuture-incompat-test requires nightly (permanently)
121140 return ;
122141 }
123142
@@ -147,6 +166,7 @@ fn test_multi_crate() {
147166 for command in & [ "build" , "check" , "rustc" , "test" ] {
148167 p. cargo ( command) . arg ( "-Zfuture-incompat-report" )
149168 . masquerade_as_nightly_cargo ( )
169+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
150170 . with_stderr_does_not_contain ( FUTURE_OUTPUT )
151171 . with_stderr_contains ( "warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2" )
152172 // Check that we don't have the 'triggers' message shown at the bottom of this loop
@@ -155,6 +175,7 @@ fn test_multi_crate() {
155175
156176 p. cargo ( command) . arg ( "-Zunstable-options" ) . arg ( "-Zfuture-incompat-report" ) . arg ( "--future-incompat-report" )
157177 . masquerade_as_nightly_cargo ( )
178+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
158179 . with_stderr_contains ( "warning: the following packages contain code that will be rejected by a future version of Rust: first-dep v0.0.1, second-dep v0.0.2" )
159180 . with_stderr_contains ( "The package `first-dep v0.0.1` currently triggers the following future incompatibility lints:" )
160181 . with_stderr_contains ( "The package `second-dep v0.0.2` currently triggers the following future incompatibility lints:" )
@@ -164,6 +185,7 @@ fn test_multi_crate() {
164185 // Test that passing the correct id via '--id' doesn't generate a warning message
165186 let output = p
166187 . cargo ( "build -Z future-incompat-report" )
188+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
167189 . masquerade_as_nightly_cargo ( )
168190 . exec_with_output ( )
169191 . unwrap ( ) ;
@@ -223,15 +245,16 @@ fn test_multi_crate() {
223245}
224246
225247#[ cargo_test]
226- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
227248fn color ( ) {
228249 if !is_nightly ( ) {
250+ // -Zfuture-incompat-test requires nightly (permanently)
229251 return ;
230252 }
231253
232254 let p = simple_project ( ) ;
233255
234256 p. cargo ( "check -Zfuture-incompat-report" )
257+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
235258 . masquerade_as_nightly_cargo ( )
236259 . run ( ) ;
237260
@@ -248,9 +271,9 @@ fn color() {
248271}
249272
250273#[ cargo_test]
251- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
252274fn bad_ids ( ) {
253275 if !is_nightly ( ) {
276+ // -Zfuture-incompat-test requires nightly (permanently)
254277 return ;
255278 }
256279
@@ -263,6 +286,7 @@ fn bad_ids() {
263286 . run ( ) ;
264287
265288 p. cargo ( "check -Zfuture-incompat-report" )
289+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
266290 . masquerade_as_nightly_cargo ( )
267291 . run ( ) ;
268292
@@ -285,9 +309,9 @@ Available IDs are: 1
285309}
286310
287311#[ cargo_test]
288- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
289312fn suggestions_for_updates ( ) {
290313 if !is_nightly ( ) {
314+ // -Zfuture-incompat-test requires nightly (permanently)
291315 return ;
292316 }
293317
@@ -341,6 +365,7 @@ fn suggestions_for_updates() {
341365
342366 p. cargo ( "check -Zfuture-incompat-report" )
343367 . masquerade_as_nightly_cargo ( )
368+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
344369 . with_stderr_contains ( "[..]cargo report future-incompatibilities --id 1[..]" )
345370 . run ( ) ;
346371
0 commit comments