Newtype for [ir::Block]#8142
Conversation
📝 WalkthroughWalkthroughIntroduces a ChangesBlocks Newtype Refactor
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/codegen/src/ir.rs (1)
757-808: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueConsider consistent indexing style.
This function uses
blocks[block_idx.idx()](usize indexing via.idx()) throughout, while other functions likebasicblock_append_block_instructionsuseblocks[block_idx]directly. Both patterns work correctly due to the dualIndeximplementations, but consistent use of directBlockIdxindexing would be cleaner and leverage the newtype's purpose.Not blocking since both patterns are functionally correct.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/codegen/src/ir.rs` around lines 757 - 808, The function cfg_to_instruction_sequence uses inconsistent indexing style by calling .idx() on BlockIdx values (like blocks[block_idx.idx()]) while other functions use direct indexing with the BlockIdx newtype (like blocks[block_idx]). Replace all instances of blocks[block_idx.idx()], blocks[target_block.idx()], and blocks[handler.handler_block.idx()] throughout the function to use direct BlockIdx indexing without calling .idx(), such as blocks[block_idx], blocks[target_block], and blocks[handler.handler_block], to maintain consistency with the codebase and properly leverage the BlockIdx newtype's Index trait implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/codegen/src/ir.rs`:
- Around line 757-808: The function cfg_to_instruction_sequence uses
inconsistent indexing style by calling .idx() on BlockIdx values (like
blocks[block_idx.idx()]) while other functions use direct indexing with the
BlockIdx newtype (like blocks[block_idx]). Replace all instances of
blocks[block_idx.idx()], blocks[target_block.idx()], and
blocks[handler.handler_block.idx()] throughout the function to use direct
BlockIdx indexing without calling .idx(), such as blocks[block_idx],
blocks[target_block], and blocks[handler.handler_block], to maintain consistency
with the codebase and properly leverage the BlockIdx newtype's Index trait
implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 06947e9b-5ad8-4d27-9ce6-c20a4f72b915
📒 Files selected for processing (2)
crates/codegen/src/compile.rscrates/codegen/src/ir.rs
Summary
Summary by CodeRabbit