Skip to content
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

borrowck: clearer error message for mutability violation #33347

Closed
wants to merge 1 commit into from

Conversation

birkenfeld
Copy link
Contributor

Because the X in "cannot assign to X" can be quite involved, it is easy for the user to assume that
cannot assign to captured outer variable in anFnMutclosure
refers to a specialty of FnMut closures. This change should make it clearer that the "immutable" is the key point here.

Note: I haven't checked in what other cases this message is emitted. It didn't seem to be covered by any existing borrowck compile-fail checks. But since the variant is called MutabilityViolation it seemed safe to add the "immutable".

Fixes: #31871

Because the X in "cannot assign to X" can be quite involved, it
is easy for the user to assume that

    cannot assign to captured outer variable in an `FnMut` closure

refers to a specialty of FnMut closures.  This change should
make it clearer that the "immutable" is the key point here.

Fixes: rust-lang#31871
@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@birkenfeld
Copy link
Contributor Author

Ok, as seen in the test failures, this isn't as easy:

cannot assign to immutable immutable captured outer variable in an `FnOnce` closure `x`

@birkenfeld birkenfeld closed this May 2, 2016
@birkenfeld birkenfeld deleted the issue-31871 branch May 2, 2016 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants