diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-08-21 17:57:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-21 17:57:53 -0400 |
| commit | 5619a465acc5efeadf1f8d25033a25562ffaa21e (patch) | |
| tree | fc3752468dec1cfaf3d3baa2ba38769a786a73a3 | |
| parent | f49d69093ec31583b055615bb07e056fc9fc0ee3 (diff) | |
| parent | 30fa518c612a037ebeb411439ab6b3c7d89807d1 (diff) | |
| download | rust-5619a465acc5efeadf1f8d25033a25562ffaa21e.tar.gz rust-5619a465acc5efeadf1f8d25033a25562ffaa21e.zip | |
Rollup merge of #145648 - bjorn3:tidy_deps_stricter, r=davidtwco
Add two tidy dependency checks Deny duplicate dependencies for the standard library as it would almost certainly bloat executables. And deny proc-macro dependencies for the standard library as they would break cross-compilation.
| -rw-r--r-- | src/tools/tidy/src/deps.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 858b058cb7d..80b6d54ce1c 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -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; } } @@ -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; + } + + 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. /// |
