1
1
//! 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.
2
9
3
10
use cargo_test_support:: registry:: Package ;
4
11
use cargo_test_support:: { basic_manifest, is_nightly, project, Project } ;
5
12
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; }" ;
8
16
// 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 [..]" ;
10
18
11
19
fn simple_project ( ) -> Project {
12
20
project ( )
@@ -17,9 +25,15 @@ fn simple_project() -> Project {
17
25
18
26
#[ cargo_test]
19
27
fn no_output_on_stable ( ) {
28
+ if !is_nightly ( ) {
29
+ // -Zfuture-incompat-test requires nightly (permanently)
30
+ return ;
31
+ }
20
32
let p = simple_project ( ) ;
21
33
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" )
23
37
. with_stderr_contains ( FUTURE_OUTPUT )
24
38
. with_stderr_does_not_contain ( "[..]cargo report[..]" )
25
39
. run ( ) ;
@@ -58,6 +72,7 @@ fn gate_future_incompat_report() {
58
72
#[ cargo_test]
59
73
fn test_zero_future_incompat ( ) {
60
74
if !is_nightly ( ) {
75
+ // -Zfuture-incompat-test requires nightly (permanently)
61
76
return ;
62
77
}
63
78
@@ -69,6 +84,7 @@ fn test_zero_future_incompat() {
69
84
// No note if --future-incompat-report is not specified.
70
85
p. cargo ( "build -Z future-incompat-report" )
71
86
. masquerade_as_nightly_cargo ( )
87
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
72
88
. with_stderr (
73
89
"\
74
90
[COMPILING] foo v0.0.0 [..]
@@ -79,6 +95,7 @@ fn test_zero_future_incompat() {
79
95
80
96
p. cargo ( "build --future-incompat-report -Z unstable-options -Z future-incompat-report" )
81
97
. masquerade_as_nightly_cargo ( )
98
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
82
99
. with_stderr (
83
100
"\
84
101
[FINISHED] [..]
@@ -89,9 +106,9 @@ note: 0 dependencies had future-incompatible warnings
89
106
}
90
107
91
108
#[ cargo_test]
92
- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
93
109
fn test_single_crate ( ) {
94
110
if !is_nightly ( ) {
111
+ // -Zfuture-incompat-test requires nightly (permanently)
95
112
return ;
96
113
}
97
114
@@ -100,13 +117,15 @@ fn test_single_crate() {
100
117
for command in & [ "build" , "check" , "rustc" , "test" ] {
101
118
p. cargo ( command) . arg ( "-Zfuture-incompat-report" )
102
119
. masquerade_as_nightly_cargo ( )
120
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
103
121
. with_stderr_contains ( FUTURE_OUTPUT )
104
122
. with_stderr_contains ( "warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]" )
105
123
. with_stderr_does_not_contain ( "[..]incompatibility[..]" )
106
124
. run ( ) ;
107
125
108
126
p. cargo ( command) . arg ( "-Zfuture-incompat-report" ) . arg ( "-Zunstable-options" ) . arg ( "--future-incompat-report" )
109
127
. masquerade_as_nightly_cargo ( )
128
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
110
129
. with_stderr_contains ( FUTURE_OUTPUT )
111
130
. with_stderr_contains ( "warning: the following packages contain code that will be rejected by a future version of Rust: foo v0.0.0 [..]" )
112
131
. with_stderr_contains ( "The package `foo v0.0.0 ([..])` currently triggers the following future incompatibility lints:" )
@@ -115,9 +134,9 @@ fn test_single_crate() {
115
134
}
116
135
117
136
#[ cargo_test]
118
- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
119
137
fn test_multi_crate ( ) {
120
138
if !is_nightly ( ) {
139
+ // -Zfuture-incompat-test requires nightly (permanently)
121
140
return ;
122
141
}
123
142
@@ -147,6 +166,7 @@ fn test_multi_crate() {
147
166
for command in & [ "build" , "check" , "rustc" , "test" ] {
148
167
p. cargo ( command) . arg ( "-Zfuture-incompat-report" )
149
168
. masquerade_as_nightly_cargo ( )
169
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
150
170
. with_stderr_does_not_contain ( FUTURE_OUTPUT )
151
171
. 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" )
152
172
// Check that we don't have the 'triggers' message shown at the bottom of this loop
@@ -155,6 +175,7 @@ fn test_multi_crate() {
155
175
156
176
p. cargo ( command) . arg ( "-Zunstable-options" ) . arg ( "-Zfuture-incompat-report" ) . arg ( "--future-incompat-report" )
157
177
. masquerade_as_nightly_cargo ( )
178
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
158
179
. 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" )
159
180
. with_stderr_contains ( "The package `first-dep v0.0.1` currently triggers the following future incompatibility lints:" )
160
181
. 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() {
164
185
// Test that passing the correct id via '--id' doesn't generate a warning message
165
186
let output = p
166
187
. cargo ( "build -Z future-incompat-report" )
188
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
167
189
. masquerade_as_nightly_cargo ( )
168
190
. exec_with_output ( )
169
191
. unwrap ( ) ;
@@ -223,15 +245,16 @@ fn test_multi_crate() {
223
245
}
224
246
225
247
#[ cargo_test]
226
- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
227
248
fn color ( ) {
228
249
if !is_nightly ( ) {
250
+ // -Zfuture-incompat-test requires nightly (permanently)
229
251
return ;
230
252
}
231
253
232
254
let p = simple_project ( ) ;
233
255
234
256
p. cargo ( "check -Zfuture-incompat-report" )
257
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
235
258
. masquerade_as_nightly_cargo ( )
236
259
. run ( ) ;
237
260
@@ -248,9 +271,9 @@ fn color() {
248
271
}
249
272
250
273
#[ cargo_test]
251
- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
252
274
fn bad_ids ( ) {
253
275
if !is_nightly ( ) {
276
+ // -Zfuture-incompat-test requires nightly (permanently)
254
277
return ;
255
278
}
256
279
@@ -263,6 +286,7 @@ fn bad_ids() {
263
286
. run ( ) ;
264
287
265
288
p. cargo ( "check -Zfuture-incompat-report" )
289
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
266
290
. masquerade_as_nightly_cargo ( )
267
291
. run ( ) ;
268
292
@@ -285,9 +309,9 @@ Available IDs are: 1
285
309
}
286
310
287
311
#[ cargo_test]
288
- #[ ignore] // Waiting on https://github.com/rust-lang/rust/pull/86478
289
312
fn suggestions_for_updates ( ) {
290
313
if !is_nightly ( ) {
314
+ // -Zfuture-incompat-test requires nightly (permanently)
291
315
return ;
292
316
}
293
317
@@ -341,6 +365,7 @@ fn suggestions_for_updates() {
341
365
342
366
p. cargo ( "check -Zfuture-incompat-report" )
343
367
. masquerade_as_nightly_cargo ( )
368
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
344
369
. with_stderr_contains ( "[..]cargo report future-incompatibilities --id 1[..]" )
345
370
. run ( ) ;
346
371
0 commit comments