Skip to content

fix(lint): gate var_table freshness accessors on debug_assertions - #4261

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/var-table-freshness-cfg-gates
Nov 28, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/var-table-freshness-cfg-gates

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

Gate VarTable::track_cell and VarTable::stale_names (src/shell/var_table.rs) on their consumers' cfg, so a release-profile lib build no longer reports them as dead code. This is the remaining half of the niubash main CI red (companion to #4258, which gated Executor::owns_process_image).

UNVERIFIED-BY-CAPTAIN — code-only lane delivery; captain verification pending.

Root cause

Both methods' only live consumers sit behind #[cfg(debug_assertions)] in src/executor/variable_state.rs:

  • track_cell (var_table.rs:298): called at variable_state.rs:1212 (verify_typed_cells_impl, wholly #[cfg(debug_assertions)]) and :1287 (a #[cfg(debug_assertions)] block in note_typed_cell_synced); additionally called directly by var_table's own unit tests.
  • stale_names (var_table.rs:341): called only at variable_state.rs:1185, inside the same debug verifier.

In a release-profile build (debug_assertions off, non-test) neither method has a live call site → dead_code. niubash CI builds the vendored rubash in release with -D warnings, so it has been red on this since 2026-11-27. This is a build-profile difference, not a feature-set one (rubash's features do not touch var_table).

Fix (single mechanism, mirroring #4258)

Gate each method on its consumers' cfg — no #[allow(dead_code)], no deletion (the debug verifier is a live consumer), following the in-file precedent of untrack_cell/mark_cell_synced (#[cfg(test)]):

  • track_cell → #[cfg(any(debug_assertions, test))] (test must be included: unit tests call it directly, otherwise cargo test --release fails to compile)
  • stale_names → #[cfg(debug_assertions)]

Attribution: the fix lands in rubash; niubash picks it up on its next vendored sync. No niubash change needed.

No behavior change: in release builds the tracked set is always empty already (its only inserter's callers are all on the debug surface), and the sibling surface stays live and untouched — cell_is_fresh and mirror_epoch_of have non-gated call sites, and the freshness fields are held by live code (note_mirror_write / cell_is_fresh).

What this PR deletes

Nothing. Net diff: +2 lines (two cfg attribute lines), 0 deletions, one file. The gated methods are not a second path: each remains the single implementation, compiled exactly when its consumers are compiled.

Verification (devin-mac, tree based on 8407b40; file blob identical on current master)

  • Repro (before fix): RUSTFLAGS="-D warnings" cargo check --release --lib --locked → exactly one error: methods track_cell and stale_names are never used (var_table.rs:298).
  • After fix: release -D warnings check green; debug -D warnings check green; clippy scan shows 0 dead_code hits.
  • cargo test --release --lib var_table: compiles and 12/12 pass (proves the test leg of the gate — tracked_write_marks_stale_and_sync_clears exercises track_cell with debug_assertions off).
  • cargo test --lib full: 1337 passed / 0 failed / 4 ignored (the one initial failure, issue2875_input_procsub_child_runs_as_rubash_shell, is a documented missing-bin precondition on a fresh target; green once cargo build --bin rubash has run).
  • Fail-first both ways: gates reverted → the dead_code error returns and the release check fails; gates restored → green.

track_cell and stale_names are consumed only by the debug_assertions
boundary verifier in executor/variable_state.rs (plus var_table unit
tests for track_cell). In a release-profile lib build both are dead
code, which turns niubash CI red: it builds the vendored rubash in
release with -D warnings. Gate each method on its consumers cfg,
mirroring #4258: track_cell on any(debug_assertions, test),
stale_names on debug_assertions. No behavior change: in release the
tracked set is always empty already.
@caomengxuan666
caomengxuan666 merged commit f9c2b95 into master Nov 28, 2026
11 of 13 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/var-table-freshness-cfg-gates branch November 28, 2026 04:17
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.

1 participant