Skip to content

Commit 30fa518

Browse files
committed
tidy: Add check against proc macros as standard library dependencies
They would break cross-compilation.
1 parent 812c93e commit 30fa518

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/tools/tidy/src/deps.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ pub fn check(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {
593593
if workspace == "library" {
594594
check_runtime_license_exceptions(&metadata, bad);
595595
check_runtime_no_duplicate_dependencies(&metadata, bad);
596+
check_runtime_no_proc_macros(&metadata, bad);
596597
checked_runtime_licenses = true;
597598
}
598599
}
@@ -808,6 +809,20 @@ fn check_runtime_no_duplicate_dependencies(metadata: &Metadata, bad: &mut bool)
808809
}
809810
}
810811

812+
fn check_runtime_no_proc_macros(metadata: &Metadata, bad: &mut bool) {
813+
for pkg in &metadata.packages {
814+
if pkg.targets.iter().any(|target| target.is_proc_macro()) {
815+
tidy_error!(
816+
bad,
817+
"proc macro `{}` is not allowed as standard library dependency.\n\
818+
Using proc macros in the standard library would break cross-compilation \
819+
as proc-macros don't get shipped for the host tuple.",
820+
pkg.name
821+
);
822+
}
823+
}
824+
}
825+
811826
/// Checks the dependency of `restricted_dependency_crates` at the given path. Changes `bad` to
812827
/// `true` if a check failed.
813828
///

0 commit comments

Comments
 (0)