Skip to content

Commit af33587

Browse files
authored
Rollup merge of #102468 - RalfJung:tidy, r=jyn514
tidy: make rustc dependency error less confusing The current wording leads to very confusing messages: ``` tidy error: Dependencies for main workspace not explicitly permitted: * unicode-ident 1.0.4 (registry+https://github.com/rust-lang/crates.io-index) ``` Miri is part of that workspace, and there never was a problem adding Miri dependencies. The actual error is that due to a crate bump this now showed up as a rustc dependency, and *those* are restricted.
2 parents 8a73397 + 79ad594 commit af33587

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

src/tools/tidy/src/deps.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,11 @@ const EXCEPTIONS_BOOTSTRAP: &[(&str, &str)] = &[
7373
/// these and all their dependencies *must not* be in the exception list.
7474
const RUNTIME_CRATES: &[&str] = &["std", "core", "alloc", "test", "panic_abort", "panic_unwind"];
7575

76-
/// Crates whose dependencies must be explicitly permitted.
77-
const RESTRICTED_DEPENDENCY_CRATES: &[&str] = &["rustc_driver", "rustc_codegen_llvm"];
78-
7976
/// Crates rustc is allowed to depend on. Avoid adding to the list if possible.
8077
///
8178
/// This list is here to provide a speed-bump to adding a new dependency to
8279
/// rustc. Please check with the compiler team before adding an entry.
83-
const PERMITTED_DEPENDENCIES: &[&str] = &[
80+
const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
8481
"addr2line",
8582
"adler",
8683
"ahash",
@@ -307,7 +304,7 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
307304
];
308305

309306
const FORBIDDEN_TO_HAVE_DUPLICATES: &[&str] = &[
310-
// These two crates take quite a long time to build, so don't allow two versions of them
307+
// This crate takes quite a long time to build, so don't allow two versions of them
311308
// to accidentally sneak into our dependency graph, in order to ensure we keep our CI times
312309
// under control.
313310
"cargo",
@@ -324,12 +321,12 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
324321
.features(cargo_metadata::CargoOpt::AllFeatures);
325322
let metadata = t!(cmd.exec());
326323
let runtime_ids = compute_runtime_crates(&metadata);
327-
check_exceptions(&metadata, EXCEPTIONS, runtime_ids, bad);
328-
check_dependencies(
324+
check_license_exceptions(&metadata, EXCEPTIONS, runtime_ids, bad);
325+
check_permitted_dependencies(
329326
&metadata,
330-
"main workspace",
331-
PERMITTED_DEPENDENCIES,
332-
RESTRICTED_DEPENDENCY_CRATES,
327+
"rustc",
328+
PERMITTED_RUSTC_DEPENDENCIES,
329+
&["rustc_driver", "rustc_codegen_llvm"],
333330
bad,
334331
);
335332
check_crate_duplicate(&metadata, FORBIDDEN_TO_HAVE_DUPLICATES, bad);
@@ -342,8 +339,8 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
342339
.features(cargo_metadata::CargoOpt::AllFeatures);
343340
let metadata = t!(cmd.exec());
344341
let runtime_ids = HashSet::new();
345-
check_exceptions(&metadata, EXCEPTIONS_CRANELIFT, runtime_ids, bad);
346-
check_dependencies(
342+
check_license_exceptions(&metadata, EXCEPTIONS_CRANELIFT, runtime_ids, bad);
343+
check_permitted_dependencies(
347344
&metadata,
348345
"cranelift",
349346
PERMITTED_CRANELIFT_DEPENDENCIES,
@@ -358,13 +355,13 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
358355
.features(cargo_metadata::CargoOpt::AllFeatures);
359356
let metadata = t!(cmd.exec());
360357
let runtime_ids = HashSet::new();
361-
check_exceptions(&metadata, EXCEPTIONS_BOOTSTRAP, runtime_ids, bad);
358+
check_license_exceptions(&metadata, EXCEPTIONS_BOOTSTRAP, runtime_ids, bad);
362359
}
363360

364361
/// Check that all licenses are in the valid list in `LICENSES`.
365362
///
366-
/// Packages listed in `EXCEPTIONS` are allowed for tools.
367-
fn check_exceptions(
363+
/// Packages listed in `exceptions` are allowed for tools.
364+
fn check_license_exceptions(
368365
metadata: &Metadata,
369366
exceptions: &[(&str, &str)],
370367
runtime_ids: HashSet<&PackageId>,
@@ -434,11 +431,11 @@ fn check_exceptions(
434431
}
435432
}
436433

437-
/// Checks the dependency of `RESTRICTED_DEPENDENCY_CRATES` at the given path. Changes `bad` to
434+
/// Checks the dependency of `restricted_dependency_crates` at the given path. Changes `bad` to
438435
/// `true` if a check failed.
439436
///
440-
/// Specifically, this checks that the dependencies are on the `PERMITTED_DEPENDENCIES`.
441-
fn check_dependencies(
437+
/// Specifically, this checks that the dependencies are on the `permitted_dependencies`.
438+
fn check_permitted_dependencies(
442439
metadata: &Metadata,
443440
descr: &str,
444441
permitted_dependencies: &[&'static str],

0 commit comments

Comments
 (0)