-
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.
Don't suggest reborrow if usage is inside a closure
- Loading branch information
1 parent
a2cdcb3
commit 41d4ea2
Showing
3 changed files
with
33 additions
and
1 deletion.
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,16 @@ | ||
struct State; | ||
|
||
fn once(_: impl FnOnce()) {} | ||
|
||
fn fill_memory_blocks_mt(state: &mut State) { | ||
loop { | ||
once(move || { | ||
//~^ ERROR use of moved value: `state` | ||
fill_segment(state); | ||
}); | ||
} | ||
} | ||
|
||
fn fill_segment(_: &mut State) {} | ||
|
||
fn main() {} |
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,15 @@ | ||
error[E0382]: use of moved value: `state` | ||
--> $DIR/issue-101119.rs:7:14 | ||
| | ||
LL | fn fill_memory_blocks_mt(state: &mut State) { | ||
| ----- move occurs because `state` has type `&mut State`, which does not implement the `Copy` trait | ||
LL | loop { | ||
LL | once(move || { | ||
| ^^^^^^^ value moved into closure here, in previous iteration of loop | ||
LL | | ||
LL | fill_segment(state); | ||
| ----- use occurs due to use in closure | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0382`. |