Skip to content

cleanup(codegen): delete dead emit_struct_literal and two stale dead_code allows - #2872

Open
gertybotbot wants to merge 1 commit into
hew-lang:mainfrom
gertybotbot:cleanup/dead-codegen-substrate
Open

cleanup(codegen): delete dead emit_struct_literal and two stale dead_code allows#2872
gertybotbot wants to merge 1 commit into
hew-lang:mainfrom
gertybotbot:cleanup/dead-codegen-substrate

Conversation

@gertybotbot

Copy link
Copy Markdown
Contributor

Picks up the "dead code" lane of #1885 (the "near-free" starter), re-derived against current main (d4793f894) rather than taken from the audit text — the line numbers there have drifted and the claimed "8 stale suppressions" is now 2, but the substantive finding holds and one part of it turned out to be the opposite of what was filed.

Genuinely dead: emit_struct_literal

No production consumer. Its only caller was a unit test of the helper itself, and its own docstring already recorded why: monitor() builds MonitorRef { ref_id } through Instr::RecordInitlower_record_init directly, reaching the same underlying path without the wrapper.

Deleted the function, that test, and fixture_monitor_ref_layout — the fixture had no other caller and clippy flagged it the instant the test was removed, which is exactly the restored dead-code signal this lane is about.

Stale, and masking live code

The other two #[allow(dead_code)] attributes in llvm.rs were annotated W2.004 Stage 1 substrate; consumers in Stage 2/3 + W2.005. Those consumers have landed, so the suppressions were no longer describing dead code at all:

helper production call sites
emit_result_err suspend.rs:6095,6152; runtime_abi.rs:1005,1151 (9 total)
emit_enum_variant_literal layout.rs:4717,4725,4850,4858 (14 total)

Both removed. cargo clippy -p hew-codegen-rs --lib --all-features --all-targets is clean, which is the proof neither was load-bearing — had either still been dead, -D warnings would have caught it.

This is worth noting for #1885 generally: the audit's dead-code section assumed the suppressions were stale because the helpers were still dead. For two of three, they were stale because the helpers came alive and nobody removed the annotation.

Also

Updated the substrate header comment (llvm.rs:~24885) from "Four substrate helpers" to three, dropped the emit_struct_literal precedent bullet, and removed the now-orphaned signature-rationale block that explained its FieldOffset/struct_name choices.

Verification

  • cargo clippy -p hew-codegen-rs --lib --all-features --all-targets — clean, no warnings
  • cargo test -p hew-codegen-rs --lib239 passed, 0 failed

No behavior change; deletions only (+2/−106).

Does not close #1885 (the duplication lanes and the MembershipCallbackGeneration decision-gated item remain).

…d_code allows

Part of hew-lang#1885's dead-code lane, re-derived against current main
(d4793f8) — the audit's line numbers and its claim of "8 stale
suppressions" no longer hold, but the underlying finding does.

`emit_struct_literal` has no production consumer: its only caller was a
unit test exercising the helper itself, and its own docstring recorded
that `monitor()` reaches `lower_record_init` directly without it.
Deleted along with that test and `fixture_monitor_ref_layout`, which
existed solely to feed it (clippy flagged the fixture the moment the
test went, which is the dead-code signal this lane is meant to restore).

The other two `#[allow(dead_code)]` attributes in llvm.rs were annotated
"consumers in Stage 2/3 + W2.005". Those consumers have since landed, so
the suppressions were masking live code:

  emit_result_err           -> suspend.rs:6095,6152; runtime_abi.rs:1005,1151
  emit_enum_variant_literal -> layout.rs:4717,4725,4850,4858

Both removed; clippy is clean with `-D warnings`, confirming neither was
load-bearing. Updated the substrate header comment from four helpers to
three and dropped the emit_struct_literal signature rationale.

No behavior change: 239 lib tests pass.
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.

Workspace cleanup: cross-crate duplication + dead code

1 participant