gccrs
                                
                                 gccrs copied to clipboard
                                
                                    gccrs copied to clipboard
                            
                            
                            
                        Handle structs as scrutinee for match expressions
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (check_match_scrutinee): Handle structs
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.
You're right, adding a matching test would be great. Even more if you already have one at hand! Thanks!
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!
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 dg-output directive to make sure the printed output is correct :) but the best way is to create a main function which returns an i32, and to make it return 0 if the test works and something else if the test fails. check out gcc/testsuite/rust/execute/torture/matches_macro.rs for a good example
@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.