File tree 3 files changed +42
-1
lines changed 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -318,6 +318,7 @@ pub struct CliUnstable {
318
318
pub advanced_env : bool ,
319
319
pub config_profile : bool ,
320
320
pub compile_progress : bool ,
321
+ pub allow_yanked_deps : bool ,
321
322
}
322
323
323
324
impl CliUnstable {
@@ -355,6 +356,7 @@ impl CliUnstable {
355
356
"advanced-env" => self . advanced_env = true ,
356
357
"config-profile" => self . config_profile = true ,
357
358
"compile-progress" => self . compile_progress = true ,
359
+ "allow-yanked-deps" => self . allow_yanked_deps = true ,
358
360
_ => bail ! ( "unknown `-Z` flag specified: {}" , k) ,
359
361
}
360
362
Original file line number Diff line number Diff line change @@ -268,12 +268,15 @@ impl<'cfg> RegistryIndex<'cfg> {
268
268
load : & mut RegistryData ,
269
269
f : & mut FnMut ( Summary ) ,
270
270
) -> CargoResult < ( ) > {
271
+ let allow_yanked_deps = self . config . cli_unstable ( ) . allow_yanked_deps ;
271
272
let source_id = self . source_id . clone ( ) ;
272
273
let name = dep. package_name ( ) . as_str ( ) ;
273
274
let summaries = self . summaries ( name, load) ?;
274
275
let summaries = summaries
275
276
. iter ( )
276
- . filter ( |& & ( _, yanked) | dep. source_id ( ) . precise ( ) . is_some ( ) || !yanked)
277
+ . filter ( |& & ( _, yanked) | {
278
+ dep. source_id ( ) . precise ( ) . is_some ( ) || allow_yanked_deps || !yanked
279
+ } )
277
280
. map ( |s| s. 0 . clone ( ) ) ;
278
281
279
282
// Handle `cargo update --precise` here. If specified, our own source
Original file line number Diff line number Diff line change @@ -523,6 +523,42 @@ required by package `bar v0.0.1`
523
523
) . run ( ) ;
524
524
}
525
525
526
+ #[ test]
527
+ fn yanks_are_used_with_z_flag ( ) {
528
+ let p = project ( )
529
+ . file (
530
+ "Cargo.toml" ,
531
+ r#"
532
+ [project]
533
+ name = "foo"
534
+ version = "0.0.1"
535
+ authors = []
536
+
537
+ [dependencies]
538
+ bar = "*"
539
+ "# ,
540
+ ) . file ( "src/main.rs" , "fn main() {}" )
541
+ . build ( ) ;
542
+
543
+ Package :: new ( "baz" , "0.0.1" ) . publish ( ) ;
544
+ Package :: new ( "baz" , "0.0.2" ) . yanked ( true ) . publish ( ) ;
545
+ Package :: new ( "bar" , "0.0.1" ) . dep ( "baz" , "=0.0.2" ) . publish ( ) ;
546
+
547
+ p. cargo ( "build -Zallow-yanked-deps" )
548
+ . masquerade_as_nightly_cargo ( )
549
+ . with_stderr ( & format ! (
550
+ "\
551
+ [UPDATING] registry `[..]`
552
+ [DOWNLOADING] [..] (registry `file://[..]`)
553
+ [DOWNLOADING] [..] (registry `file://[..]`)
554
+ [COMPILING] baz v0.0.2
555
+ [COMPILING] bar v0.0.1
556
+ [COMPILING] foo v0.0.1 (CWD)
557
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
558
+ " ,
559
+ ) ) . run ( ) ;
560
+ }
561
+
526
562
#[ test]
527
563
fn yanks_in_lockfiles_are_ok ( ) {
528
564
let p = project ( )
You can’t perform that action at this time.
0 commit comments