Add const methods for oparg enums by ShaharNaveh · Pull Request #7617 · RustPython/RustPython
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: 8a532544-cefb-40a0-8279-7fe5d1151f8f
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/oparg.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/compiler-core/src/bytecode/oparg.rs
📝 Walkthrough
Walkthrough
Removed alternative literal encodings from oparg_enum!/impl_oparg_enum!. Added inherent conversion helpers (as_u8, as_u32, try_from_u8, try_from_u32) and routed TryFrom/From impls through them. ConvertValueOparg::None encoding changed from 0 | 255 to 0.
Changes
| Cohort / File(s) | Summary |
|---|---|
Macro refactoring & enum conversions crates/compiler-core/src/bytecode/oparg.rs |
Removed support for alternative enum literal encodings in oparg_enum!/impl_oparg_enum!. Added inherent methods as_u8, as_u32, try_from_u8, try_from_u32. TryFrom<u8>/TryFrom<u32> now delegate to the new helpers (with u8::MAX range check for u32). From<Enum> for u8/u32 use as_u8/as_u32. ConvertValueOparg::None literal changed from `0 |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
🐇 I hopped through code at break of dawn,
trimmed old paths that led me wrong.
Now one clear value sings so bright,
helpers guide it into light.
A tiny hop, a tidy song.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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: adding const methods to oparg enums, which matches the primary alteration of introducing const conversion helpers (as_u8, as_u32, try_from_u8, try_from_u32). |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ 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.
Comment @coderabbitai help to get the list of available commands and usage tips.