Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adjust for ruff return value
  • Loading branch information
ShaharNaveh committed Dec 2, 2025
commit e6d999d4647bc0bd06bbd52795d1ae83557179d0
38 changes: 20 additions & 18 deletions crates/compiler-core/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ impl fmt::Display for ConvertValueOparg {
}
}

impl OpArgType for ConvertValueOparg {
#[inline]
fn from_op_arg(x: u32) -> Option<Self> {
Some(match x {
// Ruff `ConversionFlag::None` is `-1i8`,
// when its converted to `u8` its value is `u8::MAX`
0 | 255 => Self::None,
1 => Self::Str,
2 => Self::Repr,
3 => Self::Ascii,
_ => return None,
})
}

#[inline]
fn to_op_arg(self) -> u32 {
self as u32
}
}

/// Resume type for the RESUME instruction
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
#[repr(u32)]
Expand Down Expand Up @@ -514,24 +534,6 @@ impl fmt::Display for Label {
}
}

impl OpArgType for ConvertValueOparg {
#[inline]
fn from_op_arg(x: u32) -> Option<Self> {
Some(match x {
0 => Self::None,
1 => Self::Str,
2 => Self::Repr,
3 => Self::Ascii,
_ => return None,
})
}

#[inline]
fn to_op_arg(self) -> u32 {
self as u32
}
}

op_arg_enum!(
/// The kind of Raise that occurred.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down
Loading