chore: delete 257 lines of dead code, and the 25 allows that were hiding nothing - #422
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR removes stale #[allow(dead_code)] suppressions and deletes now-unreachable code paths, tightening the project’s “every allow must be justified” rule and reducing the surface area where regressions can hide behind blanket lints.
Changes:
- Removed 25
#[allow(dead_code)]attributes that were no longer suppressing anything across core/frontend/PPU code. - Deleted an unreachable “LockstepBus DMA service” island in
rustynes-core(including an already-emptydrain_dmaand its call sites). - Deleted an unreachable DMC-abort scheduling island in
rustynes-apu.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rustynes-ppu/src/ppu.rs | Removes an unnecessary dead_code allow on a live PPU struct field. |
| crates/rustynes-frontend/src/save_states_ui.rs | Removes an unnecessary dead_code allow from a public save-state slot path helper. |
| crates/rustynes-frontend/src/save_state.rs | Removes stale dead_code allows from save-state helper APIs. |
| crates/rustynes-frontend/src/input.rs | Removes an unnecessary dead_code allow from a test-used defaults constructor. |
| crates/rustynes-frontend/src/gfx.rs | Removes unnecessary dead_code allows from post-processing disable helpers. |
| crates/rustynes-frontend/src/debugger/mod.rs | Removes unnecessary dead_code allows from retained overlay state fields. |
| crates/rustynes-frontend/src/config.rs | Removes unnecessary dead_code allows from config save APIs. |
| crates/rustynes-frontend/src/audio.rs | Removes unnecessary dead_code allows from audio queue/output inspection helpers. |
| crates/rustynes-core/src/bus.rs | Deletes unreachable DMA-service code and removes drain_dma call sites that were no-ops. |
| crates/rustynes-apu/src/apu.rs | Deletes unreachable DMC-abort scheduling helpers and removes a stale dead_code allow. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
9bee157 to
2a05ded
Compare
|
The blocking finding is declined as not reproducible, and the quote it rests on is the false comment this PR removes.
fn drain_dma(&mut self, read_addr: Option<u16>) {
let _ = read_addr;
}Nothing else. Forty lines of comments describing what it used to do, and one statement discarding its argument. Deleting an empty function and its three call sites is three no-ops removed; there is no timing to break because there was no work being done. The sentence you quote is the evidence, not the counter-evidence. "The legacy service below stays active for the default build" refers to the The The suggestion is also measured, not assumed
That was the first thing checked, and it is why only 25 of 29 attributes were removed rather than all of them. Every gated combination was run with And the accuracy battery, after the deletionRe-run after the island and Both Copilot findings on this PR were real and are fixed in |
9374bf6 to
9bb00fd
Compare
|
The blocking finding is not reproducible — Eight attribute lines removed from that file and nothing else — no function deleted, in Worth noting the finding's own internal check would have caught it: it says the deletion "directly contradicts the rationale you used to keep The suggestion is taken (
|
9582fcf to
7c8b4fb
Compare
The project rule is that every local `#[allow]` is justified. This asks the prior question -- is it still doing anything? -- and the answer for almost all of them was no. Method matters here, because a single-combo probe proves nothing. An item can be live by default and dead on wasm or under `--no-default-features`, which is precisely the situation that would have earned the attribute. So every `#[allow(dead_code)]` in the four crates carrying them was stripped and clippy re-run across EVERY gated combination: default, `debug-hooks`, `full`, the `no_std` thumbv7em target, and the four wasm32 variants (default, `wasm-canvas`, `browser-cheevos`, `script-wasm`). Of 29 attributes, 25 suppressed nothing in any combination. Each was a permanently-disabled dead-code check on an item that is used -- the opposite of what it looks like, and a place a future regression could hide. Two genuinely-dead islands remain, both leftovers from the `mc-r1-*` staged master-clock migration whose cargo features no longer exist anywhere in the workspace. The APU pair (`dmc_abort_delay_for` + `schedule_explicit_dmc_abort_if_needed`) is DELETED. Its own comment said it was "retained for the flag-off path", and that flag was removed in #237 (v2.0.1); the master-clock scheduler has been the only path since v2.0.0, so the path it was retained for cannot be taken. Thirty-four self-contained lines, and git keeps them. The four `LockstepBus` DMA-service methods are KEPT, with a corrected justification. They form a CLOSED ISLAND -- they call each other and nothing outside calls any of them, which is why removing one attribute makes all four report at once and why grepping a single name finds a caller and looks reassuring. Cutting four methods out of `bus.rs` is a larger and riskier edit than the sweep that found them justifies, and unreferenced code cannot change behaviour, so this is a maintenance question rather than a correctness one. The note also corrects a nearby comment claiming "the legacy service below stays active for the default build", which has been false since v2.0.0. `rustynes-apu` changes, so the accuracy battery is VERIFIED rather than asserted: AccuracyCoin (RAM) 100.00% over 141 assigned tests -- the authoritative decoder, quoted case-sensitively, since the framebuffer decoder reports 120 and is known-buggy -- and nestest passes. Both run with a confirmed non-zero test count.
… behind Maintainer call: take the dead code out rather than annotate it. The four `LockstepBus` methods -- `clock_oam_dma_cycle`, `service_dmc_dma`, `service_dmc_abort` and `service_dmc_dma_during_oam` -- are the legacy bus-side DMA service from the `mc-r1-*` staged master-clock migration. Those cargo features exist nowhere in the workspace and the master-clock scheduler has been the only path since v2.0.0, so nothing can reach them. They formed a closed island: each called the next and nothing outside called any, which is why grepping a single name found a caller and looked reassuring, and why removing one `#[allow(dead_code)]` made all four report at once. 183 lines. Removing them exposed the more interesting half. `drain_dma` -- called on every CPU read, every CPU write, and every bus cycle -- had already been reduced to an empty body: `let _ = read_addr;` and forty lines of comments describing what it used to do. Its `#[allow]` list (`unused_self`, `needless_pass_by_ref_mut`, `missing_const_for_fn`) was the tell: those three fire together exactly when a method does nothing. Its comments still claimed "the legacy service below stays active for the default build", which had not been true since v2.0.0, and it read at the call site as though DMA were being serviced there. Deleted with its three call sites. Behaviour is unchanged by construction -- an empty function called three times is three no-ops -- and the compiler proves the island was unreachable, which is what made it dead in the first place. `rustynes-core` changes, so the accuracy battery is VERIFIED rather than asserted: AccuracyCoin (RAM) 100.00% over 141 assigned tests, the authoritative decoder, plus nestest; `no_std` cross-compile, workspace clippy and every crate suite clean. Fifteen comments across `rustynes-core`, `rustynes-cpu` and `rustynes-apu` still name the removed functions while describing the historical mechanism. They are left as-is deliberately: rewriting fifteen technical comments to avoid a name risks changing what they say about the hardware, which is a worse trade than a reader grepping and finding the explanation in this commit.
Both found by review, and both are the same class this sweep exists to find -- prose describing a state that no longer holds. `slot_exists`'s note said "we allow `dead_code` rather than wait to land it", referring to an attribute this change removes. It also had the reason backwards: the item is `pub` in a lib target, and `pub` items are exempt from dead-code analysis, so it never needed the attribute at all. The anticipated Sprint 5-3 "recently used slots" indicator was never built; the comment now says that plainly and points at the test that does exercise it. `slot_path_for`'s doc claimed it was "re-exported for the app to log / inspect". There is no in-repo call site. Reworded to what is true -- a thin wrapper available to external and diagnostic callers -- and kept rather than deleted, because unlike the dead code this change removes it is `pub` and part of the module's surface, not an unreachable island.
Review is right that the rewrite kept more history than a docstring needs. What a reader has to know is the mechanism -- `pub` items in a lib target are exempt from dead-code analysis, so neither item needs an attribute -- not how many attributes this pass removed or which review prompted the wording. Both notes now say the former and drop the latter.
7c8b4fb to
7985ad3
Compare
Antigravity review (Gemini via Ultra)This PR removes 257 lines of unused legacy DMA/scheduling logic and drops 25 Blocking issuesNone found. Suggestions
Nitpicks
Automated first-pass review by |
A remediation pass over the project's dead-code suppressions. 257 lines removed, nothing added.
The question, and why the method matters
The project rule is that every local
#[allow]is justified. This asks the prior question — is it still doing anything? — by stripping every#[allow(dead_code)]and re-running clippy.A single-combo probe would prove nothing. An item can be live by default and dead on wasm or under
--no-default-features, which is precisely the situation that would have earned the attribute in the first place. So every combination this repo gates was run: default,debug-hooks,full, theno_stdthumbv7em target, and all four wasm32 variants (default,wasm-canvas,browser-cheevos,script-wasm).Of 29 attributes, 25 suppressed nothing in any combination. Each was a permanently-disabled dead-code check on an item that is used — the opposite of what it looks like, and a place a future regression could hide unnoticed.
The two islands that were real
Both are leftovers from the
mc-r1-*staged master-clock migration, whose cargo features exist nowhere in the workspace.The APU pair (
dmc_abort_delay_for+schedule_explicit_dmc_abort_if_needed) — its own comment said it was "retained for the flag-off path", and that flag was removed in #237 (v2.0.1). 34 lines.The four
LockstepBusDMA-service methods — a closed island: each called the next and nothing outside called any. That is why grepping a single name found a caller and looked reassuring, and why removing one attribute made all four report at once. 183 lines.What deleting the island exposed
drain_dma— called on every CPU read, every CPU write, and every bus cycle — had already been reduced to an empty body:let _ = read_addr;and forty lines of comments describing what it used to do.Its
#[allow]list was the tell:unused_self,needless_pass_by_ref_mutandmissing_const_for_fnfire together exactly when a method does nothing. Its comments still claimed "the legacy service below stays active for the default build" — untrue since v2.0.0 — and at the call site it read as though DMA were being serviced there. Deleted with its three call sites.Verification
rustynes-apuandrustynes-coreboth change, so the accuracy battery is VERIFIED, not asserted — and re-run after the island deletion, not only after the first commit:That is the authoritative decoder, quoted case-sensitively; the framebuffer decoder reports 120 and is known-buggy.
nestestpasses. Both with a confirmed non-zero test count, since a filter matching nothing exits 0.Also clean:
no_stdcross-compile, workspace clippy,debug-hooks,full, all four wasm32 combos, rustdoc, and every crate suite.Behaviour is unchanged by construction: the compiler proves the island was unreachable — that is what made it dead — and an empty function called three times is three no-ops.
Left alone deliberately
Fifteen comments across
rustynes-core,rustynes-cpuandrustynes-apustill name the removed functions while describing the historical mechanism. Rewriting fifteen technical comments to avoid a name risks changing what they say about the hardware, which is a worse trade than a reader grepping and finding the explanation here.