@@ -335,13 +335,6 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
335
335
"windows_x86_64_msvc" ,
336
336
] ;
337
337
338
- const FORBIDDEN_TO_HAVE_DUPLICATES : & [ & str ] = & [
339
- // This crate takes quite a long time to build, so don't allow two versions of them
340
- // to accidentally sneak into our dependency graph, in order to ensure we keep our CI times
341
- // under control.
342
- "cargo" ,
343
- ] ;
344
-
345
338
/// Dependency checks.
346
339
///
347
340
/// `root` is path to the directory with the root `Cargo.toml` (for the workspace). `cargo` is path
@@ -361,7 +354,6 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
361
354
& [ "rustc_driver" , "rustc_codegen_llvm" ] ,
362
355
bad,
363
356
) ;
364
- check_crate_duplicate ( & metadata, & [ ] , bad) ;
365
357
366
358
// Check cargo independently as it has it's own workspace.
367
359
let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
@@ -371,7 +363,6 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
371
363
let cargo_metadata = t ! ( cmd. exec( ) ) ;
372
364
let runtime_ids = HashSet :: new ( ) ;
373
365
check_license_exceptions ( & cargo_metadata, EXCEPTIONS_CARGO , runtime_ids, bad) ;
374
- check_crate_duplicate ( & cargo_metadata, FORBIDDEN_TO_HAVE_DUPLICATES , bad) ;
375
366
check_rustfix ( & metadata, & cargo_metadata, bad) ;
376
367
377
368
// Check rustc_codegen_cranelift independently as it has it's own workspace.
@@ -389,7 +380,6 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
389
380
& [ "rustc_codegen_cranelift" ] ,
390
381
bad,
391
382
) ;
392
- check_crate_duplicate ( & metadata, & [ ] , bad) ;
393
383
394
384
let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
395
385
cmd. cargo_path ( cargo)
@@ -535,40 +525,6 @@ fn check_permitted_dependencies(
535
525
}
536
526
}
537
527
538
- /// Prevents multiple versions of some expensive crates.
539
- fn check_crate_duplicate (
540
- metadata : & Metadata ,
541
- forbidden_to_have_duplicates : & [ & str ] ,
542
- bad : & mut bool ,
543
- ) {
544
- for & name in forbidden_to_have_duplicates {
545
- let matches: Vec < _ > = metadata. packages . iter ( ) . filter ( |pkg| pkg. name == name) . collect ( ) ;
546
- match matches. len ( ) {
547
- 0 => {
548
- tidy_error ! (
549
- bad,
550
- "crate `{}` is missing, update `check_crate_duplicate` \
551
- if it is no longer used",
552
- name
553
- ) ;
554
- }
555
- 1 => { }
556
- _ => {
557
- tidy_error ! (
558
- bad,
559
- "crate `{}` is duplicated in `Cargo.lock`, \
560
- it is too expensive to build multiple times, \
561
- so make sure only one version appears across all dependencies",
562
- name
563
- ) ;
564
- for pkg in matches {
565
- println ! ( " * {}" , pkg. id) ;
566
- }
567
- }
568
- }
569
- }
570
- }
571
-
572
528
/// Finds a package with the given name.
573
529
fn pkg_from_name < ' a > ( metadata : & ' a Metadata , name : & ' static str ) -> & ' a Package {
574
530
let mut i = metadata. packages . iter ( ) . filter ( |p| p. name == name) ;
@@ -618,18 +574,23 @@ fn deps_of_filtered<'a>(
618
574
}
619
575
}
620
576
621
- fn direct_deps_of < ' a > ( metadata : & ' a Metadata , pkg_id : & ' a PackageId ) -> impl Iterator < Item = & ' a Package > {
577
+ fn direct_deps_of < ' a > (
578
+ metadata : & ' a Metadata ,
579
+ pkg_id : & ' a PackageId ,
580
+ ) -> impl Iterator < Item = & ' a Package > {
622
581
let resolve = metadata. resolve . as_ref ( ) . unwrap ( ) ;
623
582
let node = resolve. nodes . iter ( ) . find ( |n| & n. id == pkg_id) . unwrap ( ) ;
624
583
node. deps . iter ( ) . map ( |dep| pkg_from_id ( metadata, & dep. pkg ) )
625
584
}
626
585
627
586
fn check_rustfix ( rust_metadata : & Metadata , cargo_metadata : & Metadata , bad : & mut bool ) {
628
587
let cargo = pkg_from_name ( cargo_metadata, "cargo" ) ;
629
- let cargo_rustfix = direct_deps_of ( cargo_metadata, & cargo. id ) . find ( |p| p. name == "rustfix" ) . unwrap ( ) ;
588
+ let cargo_rustfix =
589
+ direct_deps_of ( cargo_metadata, & cargo. id ) . find ( |p| p. name == "rustfix" ) . unwrap ( ) ;
630
590
631
591
let compiletest = pkg_from_name ( rust_metadata, "compiletest" ) ;
632
- let compiletest_rustfix = direct_deps_of ( rust_metadata, & compiletest. id ) . find ( |p| p. name == "rustfix" ) . unwrap ( ) ;
592
+ let compiletest_rustfix =
593
+ direct_deps_of ( rust_metadata, & compiletest. id ) . find ( |p| p. name == "rustfix" ) . unwrap ( ) ;
633
594
634
595
if cargo_rustfix. version != compiletest_rustfix. version {
635
596
tidy_error ! (
0 commit comments