Skip to content

refactor(sugar): factory is the sole dispatch — reroute last decompose_* sites#2206

Merged
TSavo merged 1 commit into
mainfrom
feat/finish-dispatch-plumbing
Jun 15, 2026
Merged

refactor(sugar): factory is the sole dispatch — reroute last decompose_* sites#2206
TSavo merged 1 commit into
mainfrom
feat/finish-dispatch-plumbing

Conversation

@TSavo

@TSavo TSavo commented Jun 15, 2026

Copy link
Copy Markdown
Owner

The four collector/helper verdict-readers that still called decompose_* inline now construct through the factory: closure_adaptor / statement_position / match_scrutinee via thin build_* helpers, and impl_method via a new third registry build_item (ItemRecognizer = fn(&Item,&FactoryCtx)->Option<Box<dyn Sugar>>). decompose_* is no longer called anywhere in lib.rs (doc-comment mentions only). Each construct keeps owning its own recognize+desugar; the factory gained only registry entries + walk fns; no node branches on position.

CallsiteSugar left untouched, by design: it's already the single consolidated inlining engine, but with a bespoke statement-sequence contract (β-reduces a helper body, re-runs collect_assertion_entries in scratch buffers, commits a multi-entry InlineCommit) — incompatible with the expr-in/Box<dyn Sugar>-out factory dispatch. Routing it through build_* would be a category error.

Behavior-preserving — cargo test -p sugar-lift-rust-tests = 533 passed / 0 failed (incl. 302 assertion_lift). Not gated on coretests CID.

🤖 Generated with Claude Code

…hrough the factory

The engine's term/composite dispatch already routes through the recursive
factory (build_term/build_composite over ordered recognizer registries), but
four collector/helper verdict-readers still constructed their node by calling
decompose_* inline. Move construction into the factory so it is the sole
dispatch:

- closure_method_terminal_effect -> sugar::factory::build_closure_adaptor
  (reuses the existing closure_adaptor::recognize_composite single-shape walk).
- statement_position_terminal_effect -> sugar::factory::build_statement_position
  (new statement_position::recognize entry; ctx-independent verdict).
- runtime_match_scrutinee_effect -> sugar::factory::build_match_scrutinee
  (new ctx-free match_scrutinee::recognize over Expr::Match; the factory both
  builds and reduces via the node's syntactic ctx-free reduction, returning
  Outcome directly so the two ctx-less callsites route unchanged).
- impl_method_terminal_effect -> sugar::factory::build_item (new third tiny
  ItemRecognizer registry + build_item, since an impl is a syn::Item, not an
  Expr; impl_method::recognize is its sole entry).

Each construct still owns its own recognize+desugar; the factory gains only
registry entries + walk fns. Non-recognition now flows through the
UnsupportedSugar structural backstop (STRUCTURAL_BACKSTOP_REASON), which the
verdict-reading routers already map to None exactly as the old decompose_*
None bail -- behavior-preserving.

CallsiteSugar (the call-site inlining engine) is left as-is: it is already the
single consolidated inlining engine, does not implement the Sugar trait, and
its decompose/desugar contract (statement-sequence beta-reduction returning a
multi-entry CallsiteOutcome { Dug(InlineCommit) | Bail }) is incompatible with
the expr-in / Sugar-out factory dispatch -- routing it through build_* would be
a category error.

Gated on cargo test staying green: 533 passed / 0 failed (assertion_lift 302/0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TSavo TSavo merged commit eb0ed27 into main Jun 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@TSavo, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 47 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 742f63d4-7e73-4027-871d-abdefce8657d

📥 Commits

Reviewing files that changed from the base of the PR and between 3b898a4 and af04c46.

📒 Files selected for processing (5)
  • implementations/rust/sugar-lift-rust-tests/src/lib.rs
  • implementations/rust/sugar-lift-rust-tests/src/sugar/factory.rs
  • implementations/rust/sugar-lift-rust-tests/src/sugar/impl_method.rs
  • implementations/rust/sugar-lift-rust-tests/src/sugar/match_scrutinee.rs
  • implementations/rust/sugar-lift-rust-tests/src/sugar/statement_position.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/finish-dispatch-plumbing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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