MIR-borrowck: fix diagnostics for closures#45927
Merged
bors merged 2 commits intorust-lang:masterfrom Nov 13, 2017
Merged
Conversation
5788bd7 to
1872d84
Compare
e0eafb3 to
5961908
Compare
5961908 to
d3e9881
Compare
Member
|
r? @estebank |
estebank
reviewed
Nov 12, 2017
Contributor
estebank
left a comment
There was a problem hiding this comment.
r=me after updating the copyright year.
| @@ -0,0 +1,62 @@ | |||
| // Copyright 2014 The Rust Project Developers. See the COPYRIGHT | |||
|
|
||
| /// Finds the span of arguments of aclosure (within `maybe_closure_span`) and its usage of | ||
| /// the local assigned at `location`. | ||
| fn find_closure_span( |
Contributor
There was a problem hiding this comment.
It'd be nice to add some comments explaining what is being done in the code, but this method is short enough that it is not necessary.
Contributor
|
@bors r+ rollup |
Collaborator
|
📌 Commit f99142b has been approved by |
kennytm
added a commit
to kennytm/rust
that referenced
this pull request
Nov 13, 2017
…bank MIR-borrowck: fix diagnostics for closures Emit notes for captured variables in the same manner as AST borrowck. ``` error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast) --> $DIR/borrowck-closures-two-mut.rs:24:24 | 23 | let c1 = to_fn_mut(|| x = 4); | -- - previous borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here 24 | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once | ^^ - borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here 25 | } | - first borrow ends here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:24:24 | 23 | let c1 = to_fn_mut(|| x = 4); | -- - previous borrow occurs due to use of `x` in closure | | | first mutable borrow occurs here 24 | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once | ^^ - borrow occurs due to use of `x` in closure | | | second mutable borrow occurs here 25 | } | - first borrow ends here ``` Fixes rust-lang#45362.
bors
added a commit
that referenced
this pull request
Nov 13, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Emit notes for captured variables in the same manner as AST borrowck.
Fixes #45362.