From 0629b82536e9fdd9579584c0dd2bddf7ab105744 Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Sun, 19 Apr 2026 01:48:20 -0700 Subject: [PATCH] refactor(hir): audit #[allow(dead_code)] stubs per #2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #2 --- compiler-rs/crates/cssl-hir/src/cap_check.rs | 14 ++++++++++++-- compiler-rs/crates/cssl-hir/src/lower.rs | 5 +---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/compiler-rs/crates/cssl-hir/src/cap_check.rs b/compiler-rs/crates/cssl-hir/src/cap_check.rs index 8ac0d412..43a2804b 100644 --- a/compiler-rs/crates/cssl-hir/src/cap_check.rs +++ b/compiler-rs/crates/cssl-hir/src/cap_check.rs @@ -134,7 +134,14 @@ impl CapCtx { } } - #[allow(dead_code)] // reserved for T3.4-phase-2.5 expression walk + // Reserved for the deferred T3.4-phase-2.5 body-walk slice of cap_check. + // The signature-level minimum-viable check landed in DECISIONS.md § T5-D3 + // (Cap-check pass sig-level only for stage-0 ; full expr walk deferred), + // which explicitly defers "full linear-use tracking through every + // expression" + "handler-one-shot enforcement" to T3.4-phase-2.5. This + // helper will be wired in when that slice lands; until then, cargo + // -D warnings needs the allow. + #[allow(dead_code)] // T5-D3: wired in at T3.4-phase-2.5 fn emit(&mut self, message: impl Into, span: Span) { self.diagnostics .push(Diagnostic::error(message).with_span(span)); @@ -228,7 +235,10 @@ impl CapCtx { } } - #[allow(dead_code)] // reserved for T3.4-phase-2.5 expression walk + // See `emit` above for the DECISIONS.md § T5-D3 tracking note -- matrix() is + // the AliasMatrix accessor the deferred T3.4-phase-2.5 body-walk needs to + // run `AliasMatrix::can_pass_through`/`param_subtype_check` at call sites. + #[allow(dead_code)] // T5-D3: wired in at T3.4-phase-2.5 fn matrix(&self) -> &AliasMatrix { &self.matrix } diff --git a/compiler-rs/crates/cssl-hir/src/lower.rs b/compiler-rs/crates/cssl-hir/src/lower.rs index 99dc906a..f224b286 100644 --- a/compiler-rs/crates/cssl-hir/src/lower.rs +++ b/compiler-rs/crates/cssl-hir/src/lower.rs @@ -18,7 +18,7 @@ //! `HirExprKind::Compound` with the operator-class preserved. use cssl_ast::cst; -use cssl_ast::{DiagnosticBag, Ident, Module as CstModule, SourceFile, Span}; +use cssl_ast::{DiagnosticBag, Ident, Module as CstModule, SourceFile}; use crate::arena::{DefId, HirArena, HirId}; use crate::attr::{HirAttr, HirAttrArg, HirAttrKind}; @@ -1267,9 +1267,6 @@ fn resolve_struct_body(b: &mut HirStructBody, scope: &ScopeMap) { } } -/// Hide the empty Span+SourceFile re-export so the `Span` import doesn't show as unused. -#[allow(dead_code)] -const fn _span_referenced(_: Span) {} #[cfg(test)] mod tests {