Resume opcode to hold ResumeType by ShaharNaveh · Pull Request #7465 · RustPython/RustPython
📝 Walkthrough
Walkthrough
Refactored the Instruction::Resume opcode's operand type from Arg<u32> to Arg<oparg::ResumeType>, replacing the auto-generated ResumeType enum with a manually defined variant that includes a catch-all Other(u32) case, and updated all emission sites to pass enum values directly.
Changes
| Cohort / File(s) | Summary |
|---|---|
ResumeType Enum Redefinition crates/compiler-core/src/bytecode/oparg.rs |
Replaced auto-generated ResumeType with manual enum definition featuring named variants (AtFuncStart, AfterYield, AfterYieldFrom, AfterAwait) plus Other(u32) catch-all; added bidirectional From<u32> and From<ResumeType> for u32 conversions, Display trait, and OpArgType implementation. |
Instruction Type Update crates/compiler-core/src/bytecode/instruction.rs |
Changed Instruction::Resume { context: Arg<u32> } field type to Arg<oparg::ResumeType>, updating the typed interpretation of the RESUME opcode operand. |
Emission Site Updates crates/codegen/src/compile.rs |
Updated four Resume instruction emission sites to pass ResumeType enum variants directly instead of converting them via u32::from(...), affecting yield-from/await sequences and generator-expression resume paths. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
- RustPython/RustPython#6322: Modifies Instruction::Resume operand typing and updates corresponding emission sites.
- RustPython/RustPython#7032: Changes ResumeType representation and bidirectional conversions in the bytecode layer.
- RustPython/RustPython#5944: Introduced the initial Resume instruction variant and ResumeType enum definition.
Suggested reviewers
- youknowone
Poem
🐰 A rabbit hops through bytecode neat,
No more raw u32s to compete—
Resume now carries types so fine,
Each variant dancing in perfect line,
Enums and conversions align! 🎯
🚥 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 summarizes the main change: updating the Resume opcode's context field from u32 to hold ResumeType enum values directly. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
📝 Coding Plan
- Generate coding plan for human review comments
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.