-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #113137 - lukas-code:no-moving-references, r=compiler…
…-errors don't suggest `move` for borrows that aren't closures fixes #113087
- Loading branch information
Showing
3 changed files
with
41 additions
and
13 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fn some_fn<'a>(_: &'a i32, _: impl FnOnce(&'a i32)) {} | ||
|
||
fn main() { | ||
let some_closure = |_| {}; | ||
|
||
for a in [1] { | ||
some_fn(&a, |c| { //~ ERROR does not live long enough | ||
some_closure(c); | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0597]: `a` does not live long enough | ||
--> $DIR/issue-113087.rs:7:17 | ||
| | ||
LL | for a in [1] { | ||
| - binding `a` declared here | ||
LL | some_fn(&a, |c| { | ||
| ^^ borrowed value does not live long enough | ||
LL | some_closure(c); | ||
| ------------ borrow later captured here by closure | ||
LL | }); | ||
LL | } | ||
| - `a` dropped here while still borrowed | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |