diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-08-20 10:02:14 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2025-08-20 10:02:14 +0000 |
| commit | 30fa518c612a037ebeb411439ab6b3c7d89807d1 (patch) | |
| tree | 0c7eec72755791cafe1b9cc8aeae49b1b48912e7 | |
| parent | 812c93e7ee82b7f0292cc3f9f6d220cdf1e01198 (diff) | |
| download | rust-30fa518c612a037ebeb411439ab6b3c7d89807d1.tar.gz rust-30fa518c612a037ebeb411439ab6b3c7d89807d1.zip | |
tidy: Add check against proc macros as standard library dependencies
They would break cross-compilation.
| -rw-r--r-- | src/tools/tidy/src/deps.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 2987f18c880..80b6d54ce1c 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -593,6 +593,7 @@ 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; } } @@ -808,6 +809,20 @@ fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, bad: &mut bool) } } +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. /// |
