-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Detect closures assigned to binding in block #106509
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
26 changes: 15 additions & 11 deletions
26
src/test/ui/closures/2229_closure_analysis/diagnostics/borrowck/borrowck-3.stderr
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
error[E0597]: `p` does not live long enough | ||
--> $DIR/borrowck-3.rs:13:29 | ||
error[E0373]: closure may outlive the current block, but it borrows `p`, which is owned by the current block | ||
--> $DIR/borrowck-3.rs:11:9 | ||
| | ||
LL | let mut c = { | ||
| ----- borrow later stored here | ||
LL | let mut p = Point {x: "1".to_string(), y: "2".to_string() }; | ||
LL | || { | ||
| -- value captured here | ||
| ^^ may outlive borrowed value `p` | ||
LL | let x = &mut p.x; | ||
LL | println!("{:?}", p); | ||
| ^ borrowed value does not live long enough | ||
... | ||
LL | }; | ||
| - `p` dropped here while still borrowed | ||
| - `p` is borrowed here | ||
| | ||
note: block requires argument type to outlive `'1` | ||
--> $DIR/borrowck-3.rs:9:9 | ||
| | ||
LL | let mut c = { | ||
| ^^^^^ | ||
help: to force the closure to take ownership of `p` (and any other referenced variables), use the `move` keyword | ||
| | ||
LL | move || { | ||
| ++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. | ||
For more information about this error, try `rustc --explain E0373`. |
This file contains 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
25 changes: 15 additions & 10 deletions
25
src/test/ui/unboxed-closures/unboxed-closure-region.stderr
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
error[E0597]: `x` does not live long enough | ||
--> $DIR/unboxed-closure-region.rs:8:12 | ||
error[E0373]: closure may outlive the current block, but it borrows `x`, which is owned by the current block | ||
--> $DIR/unboxed-closure-region.rs:8:9 | ||
| | ||
LL | let _f = { | ||
| -- borrow later stored here | ||
LL | let x = 0; | ||
LL | || x | ||
| -- ^ borrowed value does not live long enough | ||
| ^^ - `x` is borrowed here | ||
| | | ||
| value captured here | ||
LL | }; | ||
| - `x` dropped here while still borrowed | ||
| may outlive borrowed value `x` | ||
| | ||
note: block requires argument type to outlive `'1` | ||
--> $DIR/unboxed-closure-region.rs:6:9 | ||
| | ||
LL | let _f = { | ||
| ^^ | ||
help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | ||
| | ||
LL | move || x | ||
| ++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. | ||
For more information about this error, try `rustc --explain E0373`. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ fn bindings() { | |
category, | ||
span, | ||
&format!("`{}`", name), | ||
"function", | ||
), | ||
( | ||
ref name, | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change necessary? I'm curious why a rustfmt test needed to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new argument in rustc. The rustfmt change is just to keep compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ytmimi - Technically I don't think it's necessary because we never need to compile these files, but I don't think the extra arg impacts the integrity of the rustfmt test in any way (I assumed it was simply changed based on a find+replace using the ident)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I blanket searched for all the function calls.