Skip to content

🧹 Refactor overly long lower_expr function in lower_core.rs - #325

Open
undivisible wants to merge 1 commit into
masterfrom
jules-code-health-refactor-lower-expr-17815256096972707046
Open

🧹 Refactor overly long lower_expr function in lower_core.rs#325
undivisible wants to merge 1 commit into
masterfrom
jules-code-health-refactor-lower-expr-17815256096972707046

Conversation

@undivisible

@undivisible undivisible commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 What:
The lower_expr function in in-cli/src/lower_core.rs was overly long (exceeding 150 lines), serving as a monolithic dispatch and implementation function for lowering core IR expressions into textual SIL. This PR extracts the specific logic for each Expr variant into distinct, well-named helper functions (e.g., lower_int_lit, lower_binary, lower_call), leaving lower_expr as a clean, purely delegating match statement.

💡 Why:
Breaking up the massive lower_expr function drastically improves readability and maintainability. It isolates the state and control flow required for lowering individual AST nodes, reducing the cognitive load required to understand or modify specific expression lowerings in the future.

Verification:

  • Verified the exact logic was preserved by strictly extracting without behavior changes.
  • Executed cd in-cli && cargo check successfully.
  • Executed cd in-cli && cargo test successfully, proving no regressions.
  • Verified code health and style via cd in-cli && cargo clippy --all-targets --features extended --locked -- -D warnings and cargo fmt.

Result:
The lower_expr function is now extremely concise and readable, and the implementation details for lowering specific expression variants are properly encapsulated in targeted helper functions, significantly boosting the codebase's long-term maintainability.


PR created automatically by Jules for task 17815256096972707046 started by @undivisible


Note

Low Risk
Mechanical extraction in the compiler lowering path with tests reported passing; risk is limited to accidental copy-paste divergence, not new features or security surface.

Overview
Refactors the monolithic lower_expr in lower_core.rs by splitting each Expr lowering path into dedicated helpers (lower_int_lit, lower_ident, lower_unary, lower_binary, lower_struct_init, lower_call, etc.).

lower_expr is now a thin match that delegates to those functions; constant folding in unary/binary lowering reuses the new literal helpers instead of inlining SSA emission. No intended change to emitted SIL—structure and readability only.

Reviewed by Cursor Bugbot for commit 5a31467. Configure here.

Extracted the body of `lower_expr` in `in-cli/src/lower_core.rs` into specialized helper functions per `Expr` variant (e.g., `lower_int_lit`, `lower_binary`, `lower_call`, etc.), streamlining the match dispatcher.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_4336c98a-dd8e-459d-a911-b9037c9eb03a)

@mergify

mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

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