diff --git a/crates/codegen/src/ir.rs b/crates/codegen/src/ir.rs index 8d5fbdb8bd..67c60dd561 100644 --- a/crates/codegen/src/ir.rs +++ b/crates/codegen/src/ir.rs @@ -342,7 +342,7 @@ impl CodeInfo { } } - let mut block_to_offset = vec![Label(0); blocks.len()]; + let mut block_to_offset = vec![Label::new(0); blocks.len()]; // block_to_index: maps block idx to instruction index (for exception table) // This is the index into the final instructions array, including EXTENDED_ARG and CACHE let mut block_to_index = vec![0u32; blocks.len()]; @@ -351,7 +351,7 @@ impl CodeInfo { loop { let mut num_instructions = 0; for (idx, block) in iter_blocks(&blocks) { - block_to_offset[idx.idx()] = Label(num_instructions as u32); + block_to_offset[idx.idx()] = Label::new(num_instructions as u32); // block_to_index uses the same value as block_to_offset but as u32 // because lasti in frame.rs is the index into instructions array // and instructions array index == byte offset (each instruction is 1 CodeUnit) @@ -369,7 +369,7 @@ impl CodeInfo { while next_block != BlockIdx::NULL { let block = &mut blocks[next_block]; // Track current instruction offset for jump direction resolution - let mut current_offset = block_to_offset[next_block.idx()].0; + let mut current_offset = block_to_offset[next_block.idx()].as_u32(); for info in &mut block.instructions { let target = info.target; let mut op = info.instr.expect_real(); @@ -380,7 +380,7 @@ impl CodeInfo { let offset_after = current_offset + old_arg_size as u32 + old_cache_entries; if target != BlockIdx::NULL { - let target_offset = block_to_offset[target.idx()].0; + let target_offset = block_to_offset[target.idx()].as_u32(); // Direction must be based on concrete instruction offsets. // Empty blocks can share offsets, so block-order-based resolution // may classify some jumps incorrectly. diff --git a/crates/compiler-core/src/bytecode.rs b/crates/compiler-core/src/bytecode.rs index 80cf01bc02..169d4e8e53 100644 --- a/crates/compiler-core/src/bytecode.rs +++ b/crates/compiler-core/src/bytecode.rs @@ -1024,7 +1024,7 @@ impl CodeObject { } // arrow and offset - let arrow = if label_targets.contains(&Label(offset as u32)) { + let arrow = if label_targets.contains(&Label::new(offset as u32)) { ">>" } else { " " diff --git a/crates/compiler-core/src/bytecode/instruction.rs b/crates/compiler-core/src/bytecode/instruction.rs index 7b3f2c816b..16b9f1f960 100644 --- a/crates/compiler-core/src/bytecode/instruction.rs +++ b/crates/compiler-core/src/bytecode/instruction.rs @@ -1105,13 +1105,7 @@ impl InstructionMetadata for Instruction { }; ($variant:ident, $map:ident = $arg_marker:expr) => {{ let arg = $arg_marker.get(arg); - write!( - f, - "{:pad$}({}, {})", - stringify!($variant), - u32::from(arg), - $map(arg) - ) + write!(f, "{:pad$}({}, {})", stringify!($variant), arg, $map(arg)) }}; ($variant:ident, $arg_marker:expr) => { write!(f, "{:pad$}({})", stringify!($variant), $arg_marker.get(arg)) diff --git a/crates/compiler-core/src/bytecode/oparg.rs b/crates/compiler-core/src/bytecode/oparg.rs index 2cb7921312..b73ea1e89e 100644 --- a/crates/compiler-core/src/bytecode/oparg.rs +++ b/crates/compiler-core/src/bytecode/oparg.rs @@ -293,77 +293,6 @@ pub type NameIdx = u32; impl OpArgType for u32 {} -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] -#[repr(transparent)] -pub struct Label(pub u32); - -impl Label { - pub const fn new(value: u32) -> Self { - Self(value) - } -} - -impl From for Label { - fn from(value: u32) -> Self { - Self::new(value) - } -} - -impl From