Skip to content

refactor(hir): audit #[allow(dead_code)] stubs in cssl-hir#7

Open
tmchow wants to merge 1 commit intoApocky:mainfrom
tmchow:osc/2-audit-dead-code
Open

refactor(hir): audit #[allow(dead_code)] stubs in cssl-hir#7
tmchow wants to merge 1 commit intoApocky:mainfrom
tmchow:osc/2-audit-dead-code

Conversation

@tmchow
Copy link
Copy Markdown

@tmchow tmchow commented Apr 19, 2026

Summary

Closes #2. Audits the three #[allow(dead_code)] items in cssl-hir against "has the T3.4-phase-2.5 work landed or is it still pending" per the issue's decision tree, and applies the follow-up the issue prescribes for each case.

Outcome per item

1. compiler-rs/crates/cssl-hir/src/cap_check.rs:137fn emit(..., span: Span)

Pending. DECISIONS.md § T5-D3 (Cap-check pass sig-level only for stage-0; full expr walk deferred) explicitly defers "full linear-use tracking through every expression" and "handler-one-shot enforcement" to T3.4-phase-2.5. The Session-1 STATUS line lists T3.4-phase-2-refinement / T3.4-phase-3-AD-legality / T3.4-phase-3-IFC as ✓, but not T3.4-phase-2.5.

Per the issue: "If the work is still pending: add a tracking comment with the DECISIONS.md entry it's waiting on." Upgraded the bare // reserved for T3.4-phase-2.5 expression walk to an explicit pointer to § T5-D3 so the next person opening cap_check.rs lands on the actual DECISIONS entry instead of having to grep for T5-D3 themselves. #[allow(dead_code)] kept.

2. compiler-rs/crates/cssl-hir/src/cap_check.rs:231fn matrix(...) -> &AliasMatrix

Same dependency as (1). matrix() is the accessor the deferred body walk needs to call AliasMatrix::can_pass_through / param_subtype_check at call sites (per § T5-D3's "ready for use when T3.4-phase-2.5 walks call-args" note). Same tracker comment upgrade.

3. compiler-rs/crates/cssl-hir/src/lower.rs:1271const fn _span_referenced(_: Span) {}

Genuinely dead. The stub exists only so Span in the use cssl_ast::{...} line doesn't trip -D warnings. Grepping lower.rs for �Span� returns exactly three hits: the import on line 21, the stub's /// comment on line 1270, and the stub's signature on line 1272. Nothing outside the stub uses Span.

Per the issue's guidance: "If the work is complete and the function is genuinely unused: remove it, or wire it up if it was meant to be called." Removed both the stub and Span from the import. SourceFile stays in the import — it IS used at lines 49, 56, and 919.

Verification

$ cargo build --workspace
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 14.62s

$ cargo test -p cssl-hir
test result: ok. 195 passed; 0 failed; 0 ignored

Clean compile across the workspace (no new unused_imports warning from the Span removal), all 195 cssl-hir tests pass.

Scope note

The issue lists three items. This PR addresses exactly those three — no opportunistic removal of other #[allow(dead_code)]s elsewhere in cssl-hir. If the project wants a broader sweep later, it's a follow-up issue's scope.

Closes #2


This contribution was developed with AI assistance (Claude Code).

Three `#[allow(dead_code)]` items in cssl-hir reviewed against the
issue's "work pending vs landed" question:

1) compiler-rs/crates/cssl-hir/src/cap_check.rs:137 `fn emit(...)`
   T3.4-phase-2.5 (the body-walk slice this helper was reserved for)
   is still listed under "Deferred" in DECISIONS.md § T5-D3 and is
   not in the Session-1 STATUS line. The function stays; its tracking
   comment is upgraded from the bare "reserved for T3.4-phase-2.5
   expression walk" hint to an explicit reference to DECISIONS.md
   § T5-D3 (which is where "full linear-use tracking through every
   expression" + "handler-one-shot enforcement" are formally deferred).

2) compiler-rs/crates/cssl-hir/src/cap_check.rs:231 `fn matrix(...)`
   Same DECISIONS.md § T5-D3 dependency -- it's the AliasMatrix
   accessor the deferred body walk needs in order to call
   `AliasMatrix::can_pass_through` / `param_subtype_check` at call
   sites. Comment upgraded to the same T5-D3 tracker; `#[allow]`
   kept.

3) compiler-rs/crates/cssl-hir/src/lower.rs:1271 `const fn _span_referenced`
   The stub existed solely to keep the `Span` import from flagging as
   unused under cargo -D warnings. Searching lower.rs for other `Span`
   uses shows none outside the stub (3 matches: the import, the
   stub's comment, and the stub's signature). The stub is dead code
   that props up a dead import, so both the stub and the `Span` entry
   in `use cssl_ast::{...}` are removed. `SourceFile` remains since
   it IS used at lines 49/56/919.

`cargo build --workspace` is clean. `cargo test -p cssl-hir` passes
(195 tests).

Closes Apocky#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audit and resolve #[allow(dead_code)] stubs in cssl-hir

1 participant