diff options
| author | aur-build <aur-build@localhost> | 2026-11-21 15:50:41 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-21 15:50:41 +0000 |
| commit | f5d970494f77d39dadf7c7d5a6a3d70221ca2da2 (patch) | |
| tree | 13c9943c6e3740e1f829d038f48418097f05da04 /tests/architecture.rs | |
| parent | 92742f0e5d336547d8d72464e2df0ff1c4f2d337 (diff) | |
| download | aur-build-f5d970494f77d39dadf7c7d5a6a3d70221ca2da2.tar.gz aur-build-f5d970494f77d39dadf7c7d5a6a3d70221ca2da2.zip | |
src,sandbox,http: three more fields nobody read, and the check that missed them
A field scan that printed its first thirty lines missed the rest. Three `pub`
fields were written and never read: `SandboxSpec::disk_mb`, copied off
`cfg.min_free_disk_mb` into a spec no backend consulted — the dispatcher already
checks the disk itself, so the knob stayed live and the plumbing around it was
dead; `SandboxInfo::warm`, computed three ways by three backends and read by
nobody; and `Server::handle`, a `JoinHandle` stored and never joined, which is
what detaching a thread means and so was never load-bearing. All three are gone,
their construction sites with them.
Four more are written-but-never-read on purpose and now say so where they are
declared: `Identity::upstream_pins` and `source_digests` reach the identity
digest through `canonical_json`, not through a name; `VirtualClock::_owner` is
the lease, and holding it unread is the whole mechanism; the `Ab`/`Ba` pair in
`hash`'s canonical-json test exist to be serialized.
`the_test_helpers_are_used` only looked at `pub` items, which left the blanket
`allow(dead_code)` in `tests/common` exactly as able to hide a private helper as
a public one — the objection was fair, and planting
`fn planted_private_helper_never_used()` proved it passed while a dead private
helper sat in the file. It now scans private declarations too, and fails on both
the planted function and a planted struct.
Diffstat (limited to 'tests/architecture.rs')
| -rw-r--r-- | tests/architecture.rs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/architecture.rs b/tests/architecture.rs index b8de0ce..3eafcdc 100644 --- a/tests/architecture.rs +++ b/tests/architecture.rs @@ -883,6 +883,11 @@ fn the_dead_code_allowlist_names_real_items() { /// declaration. A type whose name nobody writes is still used if a field or /// method of it is: `Web::raw_request` hands back a `Raw` no test names, and /// reading `.status` off it is a use of the type. +/// +/// Private items are checked too. The blanket allowance in `tests/common` +/// excuses a private helper exactly as thoroughly as a public one, and a +/// private helper called by nothing is the harder case to notice, not the +/// easier one. #[test] fn the_test_helpers_are_used() { let common = root().join("tests/common/mod.rs"); @@ -895,9 +900,15 @@ fn the_test_helpers_are_used() { let lines: Vec<&str> = text.lines().collect(); let mut unused = Vec::new(); for (i, line) in lines.iter().enumerate() { + // `pub` and private alike: the blanket `allow(dead_code)` at the top of + // the file excuses both, so a private helper nobody calls is exactly as + // dead as a public one, and just as invisible to the compiler here. let t = line.trim_start(); - let Some(rest) = t.strip_prefix("pub ") else { continue }; - let rest = rest.trim_start(); + let indent = line.len() - t.len(); + if indent > 4 { + continue; + } + let rest = t.strip_prefix("pub ").unwrap_or(t); let Some(kind) = ["fn ", "struct ", "enum ", "const ", "static ", "type ", "trait "] .into_iter() .find(|k| rest.starts_with(k)) @@ -909,7 +920,9 @@ fn the_test_helpers_are_used() { continue; } // Everything this declaration introduces, minus the declaration itself. - let mut corpus = others.replace(&format!("pub {kind}{name}"), ""); + let mut corpus = others + .replace(&format!("pub {kind}{name}"), "") + .replace(&format!("{kind}{name}"), ""); if kind != "fn " { // Members of a struct or enum count as uses of the type. let mut depth = 0; |
