Skip to content

Mut patterns need more tests #10147

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions