refactor(ir,common): move ModulePass tier from common to ir - #19
Open
Boreas618 wants to merge 2 commits into
Open
refactor(ir,common): move ModulePass tier from common to ir#19Boreas618 wants to merge 2 commits into
Boreas618 wants to merge 2 commits into
Conversation
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
force-pushed
the
refactor/pass-traits-in-ir
branch
from
August 1, 2026 11:00
b3f02c5 to
37ddfe4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the layering inversion found by the cross-layer audit:
common::passdefined both tiers of the pass family, making the supposedly layer-neutralcommondepend upward onir(IrGenerator,ir::Error).ModulePass+ModulePassManager) moves to a newsrc/ir/pass.rs, re-exported asir::ModulePass;FunctionPass/FunctionPassManagerstay incommon::pass.FunctionPassis infallible by contract (a panic is a compiler bug),ModulePassis fallible (Result<(), Error>).common::pass's docs acknowledge its remaining ir-coupling throughFunction— accepted, sincecommonis crate-internal.Verified: default and
--features return-type-inferencebuilds clean;cargo test30/30 green.