Cleanup match statement codegen#5700
Merged
coolreader18 merged 10 commits intoRustPython:mainfrom Apr 18, 2025
Merged
Conversation
Contributor
Author
|
Matching classes causes a stack underflow, no clue why. That's for a different pr though. |
coolreader18
approved these changes
Apr 16, 2025
Member
coolreader18
left a comment
There was a problem hiding this comment.
lgtm! lmk when you feel it's ready to be merged.
Comment on lines
+1947
to
+1952
| match n { | ||
| // If no name is provided, simply pop the top of the stack. | ||
| None => { | ||
| emit!(self, Instruction::Pop); | ||
| Ok(()) | ||
| } |
Member
There was a problem hiding this comment.
You could also use let-else, to prevent rightward drift.
let Some(name) = n else {
// If no name is provided, simply pop the top of the stack.
emit!(self, Instruction::Pop);
return Ok(());
};| @@ -2155,10 +2158,7 @@ impl Compiler<'_> { | |||
| for ident in attrs.iter().take(n_attrs).skip(i + 1) { | |||
Member
There was a problem hiding this comment.
I know this isn't the code you changed, but if you're looking to make it more rusty, you could use .enumerate() here for the outer loop (for (i, attr) in attrs.iter().enumerate()) and then just for ident in &attrs[i + 1..] for the inner loop.
youknowone
approved these changes
Apr 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#5628 was a little chaotic.
Instruction::IsOperationtodo!)extra_testsand the test only checks for compile.