Skip to content

Commit ae5a1fd

Browse files
committed
Prevent duplication of rust-ap-syntax
author: alexcrichton
1 parent b6d0514 commit ae5a1fd

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/tools/tidy/src/deps.rs

+30-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Check license of third-party deps by inspecting src/vendor
1212
13-
use std::collections::{BTreeSet, HashSet};
13+
use std::collections::{BTreeSet, HashSet, HashMap};
1414
use std::fs::File;
1515
use std::io::Read;
1616
use std::path::Path;
@@ -242,6 +242,8 @@ pub fn check_whitelist(path: &Path, cargo: &Path, bad: &mut bool) {
242242
}
243243
*bad = true;
244244
}
245+
246+
check_crate_duplicate(&resolve, bad);
245247
}
246248

247249
fn check_license(path: &Path) -> bool {
@@ -344,3 +346,30 @@ fn check_crate_whitelist<'a, 'b>(
344346

345347
unapproved
346348
}
349+
350+
fn check_crate_duplicate(resolve: &Resolve, bad: &mut bool) {
351+
const FORBIDDEN_TO_HAVE_DUPLICATES: &[&str] = &[
352+
// These two crates take quite a long time to build, let's not let two
353+
// versions of them accidentally sneak into our dependency graph to
354+
// ensure we keep our CI times under control
355+
// "cargo", // FIXME(#53005)
356+
// "rustc-ap-syntax", // FIXME(#53006)
357+
];
358+
let mut name_to_id = HashMap::new();
359+
for node in resolve.nodes.iter() {
360+
name_to_id.entry(node.id.split_whitespace().next().unwrap())
361+
.or_insert(Vec::new())
362+
.push(&node.id);
363+
}
364+
365+
for name in FORBIDDEN_TO_HAVE_DUPLICATES {
366+
if name_to_id[name].len() <= 1 {
367+
continue
368+
}
369+
println!("crate `{}` is duplicated in `Cargo.lock`", name);
370+
for id in name_to_id[name].iter() {
371+
println!(" * {}", id);
372+
}
373+
*bad = true;
374+
}
375+
}

0 commit comments

Comments
 (0)