-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle structs as scrutinee for match expressions #2958
Conversation
gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (check_match_scrutinee): Handle structs Signed-off-by: Nobel Singh <nobel2073@gmail.com>
You're right, adding a matching test would be great. Even more if you already have one at hand! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct, thanks! I agree with @dkm that we would require a testcase in that instance, so that we can ensure we don't introduce regressions later on. I'd also like to see an execution testcase to check if we do match properly on structures (let me know if you need help with that)
Sure, I'm on it! Also, @CohenArthur, I'm not very familiar with execution test cases (are these supposed to differ from other test cases?). Any help you could offer would be greatly appreciated! |
they differ in that they're in a different folder in the testsuite, and they will usually have an extra |
gcc/testsuite/ChangeLog: * rust/compile/issue-2906.rs: New test. * rust/execute/torture/issue-2906.rs: New test. Signed-off-by: Nobel Singh <nobel2073@gmail.com>
@CohenArthur please LMK if these test cases are enough or not. Also, a question not related to this thread. Have we implemented immutability/mutability for variables yet? because while writing these tests I was able to mutate a variable without declaring it mutable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
gcc/rust/ChangeLog:
fixes #2906
We should now be able to use struct as scrutinee. I tested the code locally and it ran without issues but I was wondering if this patch also required a test case along with it.