Skip to content

Commit 3f45da0

Browse files
committed
tidy: Check if exceptions are no longer used.
1 parent 349fcb9 commit 3f45da0

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/tools/tidy/src/deps.rs

+23-12
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,14 @@ const EXCEPTIONS: &[&str] = &[
2626
"openssl", // BSD+advertising clause, cargo, mdbook
2727
"pest", // MPL2, mdbook via handlebars
2828
"arrayref", // BSD-2-Clause, mdbook via handlebars via pest
29-
"thread-id", // Apache-2.0, mdbook
3029
"toml-query", // MPL-2.0, mdbook
3130
"toml-query_derive", // MPL-2.0, mdbook
3231
"is-match", // MPL-2.0, mdbook
33-
"cssparser", // MPL-2.0, rustdoc
3432
"smallvec", // MPL-2.0, rustdoc
3533
"rdrand", // ISC, mdbook, rustfmt
3634
"fuchsia-cprng", // BSD-3-Clause, mdbook, rustfmt
3735
"fuchsia-zircon-sys", // BSD-3-Clause, rustdoc, rustc, cargo
3836
"fuchsia-zircon", // BSD-3-Clause, rustdoc, rustc, cargo (jobserver & tempdir)
39-
"cssparser-macros", // MPL-2.0, rustdoc
40-
"selectors", // MPL-2.0, rustdoc
4137
"clippy_lints", // MPL-2.0, rls
4238
"colored", // MPL-2.0, rustfmt
4339
"ordslice", // Apache-2.0, rls
@@ -74,7 +70,6 @@ const WHITELIST: &[&str] = &[
7470
"backtrace",
7571
"backtrace-sys",
7672
"bitflags",
77-
"build_const",
7873
"byteorder",
7974
"c2-chacha",
8075
"cc",
@@ -84,7 +79,6 @@ const WHITELIST: &[&str] = &[
8479
"cloudabi",
8580
"cmake",
8681
"compiler_builtins",
87-
"crc",
8882
"crc32fast",
8983
"crossbeam-deque",
9084
"crossbeam-epoch",
@@ -118,12 +112,9 @@ const WHITELIST: &[&str] = &[
118112
"memchr",
119113
"memmap",
120114
"memoffset",
121-
"miniz-sys",
122115
"miniz_oxide",
123-
"miniz_oxide_c_api",
124116
"nodrop",
125117
"num_cpus",
126-
"owning_ref",
127118
"parking_lot",
128119
"parking_lot_core",
129120
"pkg-config",
@@ -162,7 +153,6 @@ const WHITELIST: &[&str] = &[
162153
"synstructure",
163154
"tempfile",
164155
"termcolor",
165-
"terminon",
166156
"termion",
167157
"termize",
168158
"thread_local",
@@ -172,11 +162,9 @@ const WHITELIST: &[&str] = &[
172162
"unicode-security",
173163
"unicode-width",
174164
"unicode-xid",
175-
"unreachable",
176165
"utf8-ranges",
177166
"vcpkg",
178167
"version_check",
179-
"void",
180168
"wasi",
181169
"winapi",
182170
"winapi-build",
@@ -205,6 +193,18 @@ pub fn check(path: &Path, cargo: &Path, bad: &mut bool) {
205193
///
206194
/// Packages listed in `EXCEPTIONS` are allowed for tools.
207195
fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
196+
// Check that the EXCEPTIONS list does not have unused entries.
197+
for exception in EXCEPTIONS {
198+
if !metadata.packages.iter().any(|p| p.name == *exception) {
199+
println!(
200+
"could not find exception package `{}`\n\
201+
Remove from EXCEPTIONS list if it is no longer used.",
202+
exception
203+
);
204+
*bad = true;
205+
}
206+
}
207+
// Check if any package does not have a valid license.
208208
for pkg in &metadata.packages {
209209
if pkg.source.is_none() {
210210
// No need to check local packages.
@@ -233,6 +233,17 @@ fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
233233
///
234234
/// Specifically, this checks that the dependencies are on the `WHITELIST`.
235235
fn check_whitelist(metadata: &Metadata, bad: &mut bool) {
236+
// Check that the WHITELIST does not have unused entries.
237+
for name in WHITELIST {
238+
if !metadata.packages.iter().any(|p| p.name == *name) {
239+
println!(
240+
"could not find whitelisted package `{}`\n\
241+
Remove from WHITELIST list if it is no longer used.",
242+
name
243+
);
244+
*bad = true;
245+
}
246+
}
236247
// Get the whitelist in a convenient form.
237248
let whitelist: HashSet<_> = WHITELIST.iter().cloned().collect();
238249

0 commit comments

Comments
 (0)