Skip to content

refactor(ir,common): move ModulePass tier from common to ir - #19

Open
Boreas618 wants to merge 2 commits into
mainfrom
refactor/pass-traits-in-ir
Open

refactor(ir,common): move ModulePass tier from common to ir#19
Boreas618 wants to merge 2 commits into
mainfrom
refactor/pass-traits-in-ir

Conversation

@Boreas618

Copy link
Copy Markdown
Contributor

Fixes the layering inversion found by the cross-layer audit: common::pass defined both tiers of the pass family, making the supposedly layer-neutral common depend upward on ir (IrGenerator, ir::Error).

  • The IR-specific module tier (ModulePass + ModulePassManager) moves to a new src/ir/pass.rs, re-exported as ir::ModulePass; FunctionPass/FunctionPassManager stay in common::pass.
  • Both tiers' docs now spell out the fallibility policy: FunctionPass is infallible by contract (a panic is a compiler bug), ModulePass is fallible (Result<(), Error>).
  • common::pass's docs acknowledge its remaining ir-coupling through Function — accepted, since common is crate-internal.

Verified: default and --features return-type-inference builds clean; cargo test 30/30 green.

common::pass defined both tiers of the pass family, making the
supposedly layer-neutral common layer depend upward on ir
(IrGenerator, ir::Error).  Move the IR-specific module tier
(ModulePass + ModulePassManager) into a new src/ir/pass.rs, declare
pub mod pass; in ir.rs, and re-export ModulePass at the ir root.
FunctionPass/FunctionPassManager stay in common::pass, which remains
IR-coupled through Function — an accepted, now-documented coupling
since common is crate-internal.

Both tiers' module docs now spell out the fallibility split:
FunctionPass is infallible by contract (run returns (); a panic is a
compiler bug), ModulePass is fallible (Result<(), Error>, first error
aborts the pipeline).

Behavior is unchanged: the traits are moved verbatim and all users
(ir::module, experimental::return_infer) are rewired to the new
paths.  ir::gen::module_gen needs no edit — its Pass-2.5 region never
names the pass types directly.
Removed 15 divider banners (§5.4) across common/pass.rs and
experimental/return_infer.rs.
Deleted 12 waste TODO(asmt-2 ...) tag heads per the repo no-issue-ID
rule (§7.2); the recipe content underneath is kept as plain comments,
and the todo!("asmt-2 ...") macros are untouched code.
Rewrote 7 audience-address/teaching-narration passages as facts (§5.5:
"the core invariant you are maintaining", "already implemented for
you", "constraints we need", "step-by-step recipe", "the key
educational point"), and removed 3 historical frames (§3.2:
"pre-asmt-2", "does not support those yet").
Fixed 3 comment placements (§9.1): a stray empty comment line in
ir.rs, a doc-breaking // run in ir/module.rs folded into the doc block,
and an attribute-misattached // in ir.rs promoted to a pub(crate)
doc comment.
Tightened hedged/vague phrasing (§8.1/§8.4) in the fallback/registry
and boolean-walk comments.
No code changes; every diff line is a comment line.
@Boreas618
Boreas618 force-pushed the refactor/pass-traits-in-ir branch from b3f02c5 to 37ddfe4 Compare August 1, 2026 11:00
@Boreas618
Boreas618 changed the base branch from assign3 to main August 1, 2026 11:12
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