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

Match binding is assignment #12508

Closed
wants to merge 1 commit into from
Closed

Conversation

edwardw
Copy link
Contributor

@edwardw edwardw commented Feb 23, 2014

In its first pass, namely gather_loans, the borrow checker tracks the
initialization sites among other things it does. It does so for let
bindings with initializers but not for bindings in match arms, which are
effectively also assignments. This patch does that for borrow checker.

Closes #12452.

@alexcrichton
Copy link
Member

Can you elaborate some more in the commit message about what the bug was and how this fixes it?

cc @nikomatsakis

@edwardw
Copy link
Contributor Author

edwardw commented Feb 24, 2014

Added more description in commit message. Also tweaked the fix a little bit to follow the convention of existing code more closely.

// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a small description to these tests about what they are supposed to do and the bug that they're testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@nikomatsakis
Copy link
Contributor

Also, what @flaper87 said. Something like "// Test that immutable pattern bindings cannot be reassigned."

@edwardw
Copy link
Contributor Author

edwardw commented Feb 24, 2014

r?

@flaper87
Copy link
Contributor

@edwardw Could you squash those commits? Also, I think those tests could live in the same file. Not sure what others think but I'd prefer having just 1 borrowck-match-binding-is-assign.rs test that verifies this behavior (and perhaps the number of the issue it fixed in the comments too).

@edwardw
Copy link
Contributor Author

edwardw commented Feb 24, 2014

@flaper87, can one compile-fail test have multiple failures?

@flaper87
Copy link
Contributor

In its first pass, namely gather_loans, the borrow checker tracks the
initialization sites among other things it does. It does so for let
bindings with initializers but not for bindings in match arms, which are
effectively also assignments. This patch does that for borrow checker.

Closes rust-lang#12452.
@edwardw
Copy link
Contributor Author

edwardw commented Feb 24, 2014

r?

@bors bors closed this in 4243cad Feb 25, 2014
@edwardw edwardw deleted the pat-assign branch February 25, 2014 07:33
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
fix: Don't respond to cancelled requests when retrying them

Fixes rust-lang/rust-analyzer#12482
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 4, 2024
Fix infinite loop in `cast_sign_loss` when peeling unwrap method calls

Fixes rust-lang#12506

The lint wants to peel method calls but didn't actually reassign the expression, leading to an infinite loop.

----

changelog: Fix infinite loop in [`cast_sign_loss`] when having two chained `.unwrap()` calls
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 25, 2024
Fix infinite loop in `cast_sign_loss` when peeling unwrap method calls

Fixes rust-lang#12506

The lint wants to peel method calls but didn't actually reassign the expression, leading to an infinite loop.

----

changelog: Fix infinite loop in [`cast_sign_loss`] when having two chained `.unwrap()` calls
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 25, 2024
Fix infinite loop in `cast_sign_loss` when peeling unwrap method calls

Fixes rust-lang#12506

The lint wants to peel method calls but didn't actually reassign the expression, leading to an infinite loop.

----

changelog: Fix infinite loop in [`cast_sign_loss`] when having two chained `.unwrap()` calls
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.

match binding is unexpectedly mutable
4 participants