Skip to content

Commit 812c93e

Browse files
committed
tidy: Add a check that there are no duplicate runtime dependencies
1 parent 22a86f8 commit 812c93e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/tools/tidy/src/deps.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ pub fn check(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {
592592

593593
if workspace == "library" {
594594
check_runtime_license_exceptions(&metadata, bad);
595+
check_runtime_no_duplicate_dependencies(&metadata, bad);
595596
checked_runtime_licenses = true;
596597
}
597598
}
@@ -790,6 +791,23 @@ fn check_license_exceptions(
790791
}
791792
}
792793

794+
fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, bad: &mut bool) {
795+
let mut seen_pkgs = HashSet::new();
796+
for pkg in &metadata.packages {
797+
if pkg.source.is_none() {
798+
continue;
799+
}
800+
801+
if !seen_pkgs.insert(&*pkg.name) {
802+
tidy_error!(
803+
bad,
804+
"duplicate package `{}` is not allowed for the standard library",
805+
pkg.name
806+
);
807+
}
808+
}
809+
}
810+
793811
/// Checks the dependency of `restricted_dependency_crates` at the given path. Changes `bad` to
794812
/// `true` if a check failed.
795813
///

0 commit comments

Comments
 (0)