gccrs: feat: Made changes to ensure no wrong assignments are done.
gcc/rust/ChangeLog:
* backend/rust-compile-expr.cc (lvalue_p): Created a function that checks the lvalue. (CompileExpr::visit): Modified the function to check the lvalue using the above mentioned function and also checks the type of lvalue expression.
gcc/testsuite/ChangeLog:
* rust/compile/issue-3287.rs: New test for testing wrong assignments.
Fixes #3287
- [x] GCC development requires copyright assignment or the Developer's Certificate of Origin sign-off, see https://gcc.gnu.org/contribute.html or https://gcc.gnu.org/dco.html
- [x] Read contributing guidlines
- [x]
make check-rustpasses locally - [x] Run
clang-format - [x] Added any relevant test cases to
gcc/testsuite/rust/
There are changes required here i think we can get away wit this check but not totally convinced yet
Also it will need to be applied to the other assignments such as:
x +=1 etc
Can you give me more information about the case we are missing as x+= 1 is valid as long as x is mutable in rust.
There are changes required here i think we can get away wit this check but not totally convinced yet Also it will need to be applied to the other assignments such as: x +=1 etc
Can you give me more information about the case we are missing as x+= 1 is valid as long as x is mutable in rust.
You have to adjust the visitor for CompoundAssignmentExpr as well as the visitor for AssignmentExpr
Would probably be good to make lvalue_p operate on HIR nodes instead of trees
I guess they failing now because of newer tests. If this this merged with upstream there will not be as issue-3147.rs file is added after this changes.
You need to rebase you code and investigate why you have failing tests.