Skip to content

Fix all clippy suggestions in ir.rs#8162

Open
ShaharNaveh wants to merge 2 commits into
RustPython:mainfrom
ShaharNaveh:ir-cleanup-clippy
Open

Fix all clippy suggestions in ir.rs#8162
ShaharNaveh wants to merge 2 commits into
RustPython:mainfrom
ShaharNaveh:ir-cleanup-clippy

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Summary by CodeRabbit

  • Refactor

    • Simplified control-flow and instruction-sequence processing to be more direct and consistent.
    • Streamlined several internal loops and block lookups for clearer, more efficient handling.
  • Bug Fixes

    • Improved jump and label handling during code generation.
    • Made exception-stack processing more robust by removing unnecessary failure paths.
  • Chores

    • Updated related debug and test call sites to match the revised behavior.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 03e480a3-403e-456f-83ce-f095f6f9a2e3

📥 Commits

Reviewing files that changed from the base of the PR and between 870ad2d and 4db90b2.

📒 Files selected for processing (1)
  • crates/codegen/src/ir.rs

📝 Walkthrough

Walkthrough

This PR updates crates/codegen/src/ir.rs so several CFG and instruction-sequence helpers become infallible, adjusts the corresponding callers, and refactors some label, block-indexing, and loop-based updates across codegen and exception-stack handling.

Changes

Codegen IR control-flow refactor

Layer / File(s) Summary
Label map remapping
crates/codegen/src/ir.rs
instruction_sequence_use_label(), instruction_sequence_insert_instruction(), and instruction_sequence_apply_label_map() remap labels without InternalResult, and CFG materialization now applies the label map directly.
Exception handling and pipeline wiring
crates/codegen/src/ir.rs
prepare_cfg_from_codegen() and optimize_code_unit() call mark_except_handlers() and insert_superinstructions() directly, while exception-stack helpers and tests adopt the infallible signatures.
Jump and NOP cleanup
crates/codegen/src/ir.rs
resolve_unconditional_jumps(), resolve_jump_offsets(), and the redundant-NOP passes drop Result wrappers, and finalize_code(), optimize_cfg(), and debug tracing call the updated helpers directly.
Indexing and loop simplifications
crates/codegen/src/ir.rs
Several helpers switch to direct Blocks[...] access or iterator-based updates, including constant removal, stack-effect scans, pseudo-op conversion, cell-offset fixes, and location-info assembly.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

I hopped through labels, neat and small,
and nops went poof along the wall. 🐇
The stacks held steady, jumps fell in line,
while CFG moons kept shining fine.
Thump-thump—bytecode sings tonight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 74.55% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: a Clippy-driven cleanup in ir.rs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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