@@ -287,6 +287,7 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
287287 check_exceptions ( & metadata, EXCEPTIONS , runtime_ids, bad) ;
288288 check_dependencies ( & metadata, PERMITTED_DEPENDENCIES , RESTRICTED_DEPENDENCY_CRATES , bad) ;
289289 check_crate_duplicate ( & metadata, FORBIDDEN_TO_HAVE_DUPLICATES , bad) ;
290+ check_rustfix ( & metadata, bad) ;
290291
291292 // Check rustc_codegen_cranelift independently as it has it's own workspace.
292293 let mut cmd = cargo_metadata:: MetadataCommand :: new ( ) ;
@@ -547,3 +548,22 @@ fn normal_deps_of_r<'a>(
547548 normal_deps_of_r ( resolve, & dep. pkg , result) ;
548549 }
549550}
551+
552+ fn check_rustfix ( metadata : & Metadata , bad : & mut bool ) {
553+ let cargo = pkg_from_name ( metadata, "cargo" ) ;
554+ let compiletest = pkg_from_name ( metadata, "compiletest" ) ;
555+ let cargo_deps = deps_of ( metadata, & cargo. id ) ;
556+ let compiletest_deps = deps_of ( metadata, & compiletest. id ) ;
557+ let cargo_rustfix = cargo_deps. iter ( ) . find ( |p| p. name == "rustfix" ) . unwrap ( ) ;
558+ let compiletest_rustfix = compiletest_deps. iter ( ) . find ( |p| p. name == "rustfix" ) . unwrap ( ) ;
559+ if cargo_rustfix. version != compiletest_rustfix. version {
560+ tidy_error ! (
561+ bad,
562+ "cargo's rustfix version {} does not match compiletest's rustfix version {}\n \
563+ rustfix should be kept in sync, update the cargo side first, and then update \
564+ compiletest along with cargo.",
565+ cargo_rustfix. version,
566+ compiletest_rustfix. version
567+ ) ;
568+ }
569+ }
0 commit comments