@@ -7,6 +7,9 @@ use std::path::Path;
7
7
use build_helper:: ci:: CiEnv ;
8
8
use cargo_metadata:: { Metadata , Package , PackageId } ;
9
9
10
+ #[ path = "../../../bootstrap/src/utils/proc_macro_deps.rs" ]
11
+ mod proc_macro_deps;
12
+
10
13
/// These are licenses that are allowed for all crates, including the runtime,
11
14
/// rustc, tools, etc.
12
15
#[ rustfmt:: skip]
@@ -567,6 +570,8 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
567
570
pub fn check ( root : & Path , cargo : & Path , bad : & mut bool ) {
568
571
let mut checked_runtime_licenses = false ;
569
572
573
+ check_proc_macro_dep_list ( root, cargo, bad) ;
574
+
570
575
for & ( workspace, exceptions, permitted_deps, submodules) in WORKSPACES {
571
576
if has_missing_submodule ( root, submodules) {
572
577
continue ;
@@ -600,6 +605,37 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
600
605
assert ! ( checked_runtime_licenses) ;
601
606
}
602
607
608
+ /// Ensure the list of proc-macro crate transitive dependencies is up to date
609
+ fn check_proc_macro_dep_list ( root : & Path , cargo : & Path , bad : & mut bool ) {
610
+ let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
611
+ cmd. cargo_path ( cargo)
612
+ . manifest_path ( root. join ( "Cargo.toml" ) )
613
+ . features ( cargo_metadata:: CargoOpt :: AllFeatures )
614
+ . other_options ( vec ! [ "--locked" . to_owned( ) ] ) ;
615
+ let metadata = t ! ( cmd. exec( ) ) ;
616
+ let is_proc_macro_pkg =
617
+ |pkg : & & Package | pkg. dependencies . iter ( ) . any ( |dep| dep. name . as_str ( ) == "proc-macro2" ) ;
618
+ let mut proc_macro_deps = HashSet :: new ( ) ;
619
+ for pkg in metadata. packages . iter ( ) . filter ( is_proc_macro_pkg) {
620
+ deps_of ( & metadata, & pkg. id , & mut proc_macro_deps) ;
621
+ }
622
+ let proc_macro_deps: HashSet < _ > =
623
+ proc_macro_deps. into_iter ( ) . map ( |dep| metadata[ dep] . name . clone ( ) ) . collect ( ) ;
624
+ let expected = proc_macro_deps:: CRATES . iter ( ) . map ( |s| s. to_string ( ) ) . collect :: < HashSet < _ > > ( ) ;
625
+ for missing in proc_macro_deps. difference ( & expected) {
626
+ tidy_error ! (
627
+ bad,
628
+ "proc-macro crate dependency `{missing}` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`" ,
629
+ ) ;
630
+ }
631
+ for extra in expected. difference ( & proc_macro_deps) {
632
+ tidy_error ! (
633
+ bad,
634
+ "`{extra}` is not registered in `src/bootstrap/src/utils/proc_macro_deps.rs`, but is not a proc-macro crate dependency" ,
635
+ ) ;
636
+ }
637
+ }
638
+
603
639
/// Used to skip a check if a submodule is not checked out, and not in a CI environment.
604
640
///
605
641
/// This helps prevent enforcing developers to fetch submodules for tidy.
0 commit comments