Description
I think we need more tests for the various edge cases introduced by PR #10026.
run-pass tests
I'd like to see run-pass tests that declare mutable values, mutate them, and check that the results are correct within all the possible places that patterns appear:
- Functions argument patterns
- Let patterns
- Match patterns
Ideally we would test for each of those possible sites at least one of each possible sort of pattern with a mut
binding.
Probably also a good idea to have a test that inherited mutability works out.
compile-fail tests
I think we need more tests checking the interaction with the borrow checker, at least. Some things we ought to check:
- declare mut binding
x
, freeze it with&x
, and then try to mutate it. Do this for various different kinds of patterns etc. - attempt to mutate bindings that are not declared mut but appear deep inside patterns (we may be able to adapt existing tests).
That seems like a good start. I'd probably just want to go examine the existing borrow checker tests that cover local variables and try and expand them to also test mutable bindings in the all 3 of the various locations and with various kinds of patterns.
I'll try to find some time to create some tests.
cc @luqmana