Skip to content

refactor(hir): remove dead scaffolding and dedup scope queries#291

Merged
hongjr03 merged 3 commits into
masterfrom
refactor/hir-dead-scaffolding
Jun 27, 2026
Merged

refactor(hir): remove dead scaffolding and dedup scope queries#291
hongjr03 merged 3 commits into
masterfrom
refactor/hir-dead-scaffolding

Conversation

@hongjr03

Copy link
Copy Markdown
Member

Summary

Cleanup follow-up to the merged semantic-foundations stack (#289/#290/#288), addressing the maintainability issues raised in review. Three independent commits, each behavior-preserving.

1. Drop dead DefKind variants

DefId::kind() never produced 11 variants (Class, Covergroup, Checker, Modport, ClockingBlock, Sequence, Property, ClassField, Method, Struct, Enum); they only sat in match arms returning Unknown/empty, which reads as "intentionally unsupported" when it is actually "not yet implemented". DefKind is already #[non_exhaustive], so variants can be reintroduced together with their lowering later and the compiler will force every in-crate match to update then.

2. Drop dead Ty variants and SpecArg

Ty::ClassHandle and Ty::VirtualInterface are never constructed anywhere; they only appear in match arms returning Unknown/empty, alongside the SpecArg enum that exists solely to feed ClassHandle. Class/interface specialization is deferred, so these are forward scaffolding.

3. Deduplicate scope query member insertion

module/generate_block/block/subroutine scope queries each repeated the same decl/typedef/stmt-label insertion loops. Extracted into insert_decls_and_typedefs and insert_stmts so a new declaration category is added in one place, not four. Insertion order preserved (the two helpers bracket the container-specific members).

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace (483 passed, unchanged from baseline)

Notes

Each commit passes the full gate independently. Deliberately left untouched: the unreachable BuiltinDataTy::Event|Chandle|Void arms inside the Ty::Builtin matches of type_class/packed_bit_width — those types are promoted out of Ty::Builtin during normalization, so the arms are unreachable, but removing them would need a _ wildcard (losing exhaustive coverage of BuiltinDataTy) or a larger representation unification; both are poorer tradeoffs than leaving the defensive arms. Flagging it here so it is a conscious decision, not an oversight.

hongjr03 added 3 commits June 27, 2026 13:48
DefKind declared 11 variants that DefId::kind never produces:
Class, Covergroup, Checker, Modport, ClockingBlock, Sequence, Property,
ClassField, Method, Struct, Enum. They only appeared in match arms
returning Unknown/empty, which reads as 'intentionally unsupported'
when it is actually 'not yet implemented'. With #[non_exhaustive] on
DefKind, variants can be added together with their lowering later and
the compiler will force every in-crate match to be updated then; there
is no benefit to pre-declaring them now.
Ty::ClassHandle and Ty::VirtualInterface are never constructed
anywhere in the crate; they only appear in match arms returning
Unknown/empty, alongside the SpecArg enum that exists solely to feed
ClassHandle. Class/interface specialization is deferred per the PR
notes, so these are forward scaffolding that reads as implemented-but-
empty. Drop them now and reintroduce with the class lowering later.
module/generate_block/block/subroutine scope queries each repeated the
same decl, typedef, and stmt-label insertion loops. Extracting them into
insert_decls_and_typedefs and insert_stmts makes a single source of truth
so a new declaration category is added in one place, not four. Insertion
order is preserved: the two helpers are called around the container-
specific members (instances, generate children, ports).
@hongjr03 hongjr03 merged commit d5567d2 into master Jun 27, 2026
18 checks passed
@hongjr03 hongjr03 deleted the refactor/hir-dead-scaffolding branch June 27, 2026 05:57
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