Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ pub fn check(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {

if workspace == "library" {
check_runtime_license_exceptions(&metadata, bad);
check_runtime_no_duplicate_dependencies(&metadata, bad);
check_runtime_no_proc_macros(&metadata, bad);
checked_runtime_licenses = true;
}
}
Expand Down Expand Up @@ -790,6 +792,37 @@ fn check_license_exceptions(
}
}

fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, bad: &mut bool) {
let mut seen_pkgs = HashSet::new();
for pkg in &metadata.packages {
if pkg.source.is_none() {
continue;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have both a windows-targets crate in-tree and depend on windows-targets from crates.io.


if !seen_pkgs.insert(&*pkg.name) {
tidy_error!(
bad,
"duplicate package `{}` is not allowed for the standard library",
pkg.name
);
}
}
}

fn check_runtime_no_proc_macros(metadata: &Metadata, bad: &mut bool) {
for pkg in &metadata.packages {
if pkg.targets.iter().any(|target| target.is_proc_macro()) {
tidy_error!(
bad,
"proc macro `{}` is not allowed as standard library dependency.\n\
Using proc macros in the standard library would break cross-compilation \
as proc-macros don't get shipped for the host tuple.",
pkg.name
);
}
}
}

/// Checks the dependency of `restricted_dependency_crates` at the given path. Changes `bad` to
/// `true` if a check failed.
///
Expand Down
Loading