Skip to content

Mut patterns need more tests #10147

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

Closed
nikomatsakis opened this issue Oct 29, 2013 · 3 comments
Closed

Mut patterns need more tests #10147

nikomatsakis opened this issue Oct 29, 2013 · 3 comments
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@nikomatsakis
Copy link
Contributor

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

@steveklabnik steveklabnik added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 20, 2015
@steveklabnik
Copy link
Member

Triage: just adding a label for now.

@steveklabnik
Copy link
Member

Triage: I am not aware of any effort to create these kinds of tests. @nikomatsakis do you still think they'd be of value today? We have a lot of Rust code in the wild now, I feel confident about this feature :)

@nikomatsakis
Copy link
Contributor Author

Yah, close it.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 11, 2024
…_lint, r=Manishearth

Add new lint for byte char slices

This patch adds a new lint that checks for potentially harder to read byte char slices: `&[b'a', b'b']` and suggests to replace them with the easier to read `b"ab"` form.

Fixes rust-lang#10147

---

changelog: new lint: [`byte_char_slices`]
[rust-lang#10155](rust-lang/rust-clippy#10155)
<!-- changelog_checked -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

2 participants