@@ -15,14 +15,47 @@ use super::config::write_config_toml;
15
15
16
16
// An arbitrary lint (unused_variables) that triggers a lint.
17
17
// We use a special flag to force it to generate a report.
18
- const FUTURE_EXAMPLE : & ' static str = "fn main () { let x = 1; }" ;
18
+ const FUTURE_EXAMPLE : & ' static str = "pub fn foo () { let x = 1; }" ;
19
19
// Some text that will be displayed when the lint fires.
20
20
const FUTURE_OUTPUT : & ' static str = "[..]unused variable[..]" ;
21
21
22
- fn simple_project ( ) -> Project {
22
+ /// A project with a future-incompat error in the local package.
23
+ fn local_project ( ) -> Project {
23
24
project ( )
24
25
. file ( "Cargo.toml" , & basic_manifest ( "foo" , "0.0.0" ) )
25
- . file ( "src/main.rs" , FUTURE_EXAMPLE )
26
+ . file ( "src/lib.rs" , FUTURE_EXAMPLE )
27
+ . build ( )
28
+ }
29
+
30
+ /// A project with a future-incompat error in a dependency.
31
+ fn dependency_project ( ) -> Project {
32
+ Package :: new ( "bar" , "1.0.0" )
33
+ . file (
34
+ "Cargo.toml" ,
35
+ r#"
36
+ [package]
37
+ name = "bar"
38
+ version = "1.0.0"
39
+ edition = "2015"
40
+ repository = "https://example.com/"
41
+ "# ,
42
+ )
43
+ . file ( "src/lib.rs" , FUTURE_EXAMPLE )
44
+ . publish ( ) ;
45
+ project ( )
46
+ . file (
47
+ "Cargo.toml" ,
48
+ r#"
49
+ [package]
50
+ name = "foo"
51
+ version = "1.0.0"
52
+ edition = "2015"
53
+
54
+ [dependencies]
55
+ bar = "1.0"
56
+ "# ,
57
+ )
58
+ . file ( "src/lib.rs" , "" )
26
59
. build ( )
27
60
}
28
61
@@ -31,7 +64,7 @@ fn simple_project() -> Project {
31
64
reason = "-Zfuture-incompat-test requires nightly (permanently)"
32
65
) ]
33
66
fn output_on_stable ( ) {
34
- let p = simple_project ( ) ;
67
+ let p = local_project ( ) ;
35
68
36
69
p. cargo ( "check" )
37
70
. env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
@@ -48,7 +81,7 @@ fn output_on_stable() {
48
81
// This feature is stable, and should not be gated
49
82
#[ cargo_test]
50
83
fn no_gate_future_incompat_report ( ) {
51
- let p = simple_project ( ) ;
84
+ let p = local_project ( ) ;
52
85
53
86
p. cargo ( "check --future-incompat-report" )
54
87
. with_status ( 0 )
@@ -98,7 +131,7 @@ fn test_zero_future_incompat() {
98
131
reason = "-Zfuture-incompat-test requires nightly (permanently)"
99
132
) ]
100
133
fn test_single_crate ( ) {
101
- let p = simple_project ( ) ;
134
+ let p = local_project ( ) ;
102
135
103
136
for command in & [ "build" , "check" , "rustc" , "test" ] {
104
137
let check_has_future_compat = || {
@@ -315,7 +348,7 @@ The package `second-dep v0.0.2` currently triggers the following future incompat
315
348
reason = "-Zfuture-incompat-test requires nightly (permanently)"
316
349
) ]
317
350
fn color ( ) {
318
- let p = simple_project ( ) ;
351
+ let p = local_project ( ) ;
319
352
320
353
p. cargo ( "check" )
321
354
. env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
@@ -337,7 +370,7 @@ fn color() {
337
370
reason = "-Zfuture-incompat-test requires nightly (permanently)"
338
371
) ]
339
372
fn bad_ids ( ) {
340
- let p = simple_project ( ) ;
373
+ let p = local_project ( ) ;
341
374
342
375
p. cargo ( "report future-incompatibilities --id 1" )
343
376
. with_status ( 101 )
@@ -451,3 +484,75 @@ with_updates v1.0.0 has the following newer versions available: 1.0.1, 1.0.2, 3.
451
484
"# ] ] )
452
485
. run ( ) ;
453
486
}
487
+
488
+ #[ cargo_test(
489
+ nightly,
490
+ reason = "-Zfuture-incompat-test requires nightly (permanently)"
491
+ ) ]
492
+ fn correct_report_id_when_cached ( ) {
493
+ // Checks for a bug where the `--id` value was off-by-one when the report
494
+ // is already cached.
495
+ let p = dependency_project ( ) ;
496
+
497
+ p. cargo ( "check --future-incompat-report" )
498
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
499
+ . with_stderr_data ( str![ [ r#"
500
+ [UPDATING] `dummy-registry` index
501
+ [LOCKING] 1 package to latest compatible version
502
+ [DOWNLOADING] crates ...
503
+ [DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
504
+ [CHECKING] bar v1.0.0
505
+ [CHECKING] foo v1.0.0 ([ROOT]/foo)
506
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
507
+ [WARNING] the following packages contain code that will be rejected by a future version of Rust: bar v1.0.0
508
+ [NOTE]
509
+ To solve this problem, you can try the following approaches:
510
+
511
+
512
+ - If the issue is not solved by updating the dependencies, a fix has to be
513
+ implemented by those dependencies. You can help with that by notifying the
514
+ maintainers of this problem (e.g. by creating a bug report) or by proposing a
515
+ fix to the maintainers (e.g. by creating a pull request):
516
+
517
+ - bar@1.0.0
518
+ - Repository: https://example.com/
519
+ - Detailed warning command: `cargo report future-incompatibilities --id 1 --package bar@1.0.0`
520
+
521
+ - If waiting for an upstream fix is not an option, you can use the `[patch]`
522
+ section in `Cargo.toml` to use your own version of the dependency. For more
523
+ information, see:
524
+ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
525
+
526
+ [NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
527
+
528
+ "# ] ] )
529
+ . run ( ) ;
530
+
531
+ p. cargo ( "check --future-incompat-report" )
532
+ . env ( "RUSTFLAGS" , "-Zfuture-incompat-test" )
533
+ . with_stderr_data ( str![ [ r#"
534
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
535
+ [WARNING] the following packages contain code that will be rejected by a future version of Rust: bar v1.0.0
536
+ [NOTE]
537
+ To solve this problem, you can try the following approaches:
538
+
539
+
540
+ - If the issue is not solved by updating the dependencies, a fix has to be
541
+ implemented by those dependencies. You can help with that by notifying the
542
+ maintainers of this problem (e.g. by creating a bug report) or by proposing a
543
+ fix to the maintainers (e.g. by creating a pull request):
544
+
545
+ - bar@1.0.0
546
+ - Repository: https://example.com/
547
+ - Detailed warning command: `cargo report future-incompatibilities --id 2 --package bar@1.0.0`
548
+
549
+ - If waiting for an upstream fix is not an option, you can use the `[patch]`
550
+ section in `Cargo.toml` to use your own version of the dependency. For more
551
+ information, see:
552
+ https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
553
+
554
+ [NOTE] this report can be shown with `cargo report future-incompatibilities --id 1`
555
+
556
+ "# ] ] )
557
+ . run ( ) ;
558
+ }
0 commit comments