diff options
| author | Michael Goulet <michael@errs.io> | 2022-09-05 04:26:37 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-09-05 04:27:07 +0000 |
| commit | 41d4ea231410004f8f07bc097c51a5fe991b4ba5 (patch) | |
| tree | d51b416051d0842f0c179a07e338b2b13e9cd61f /src/test/ui/borrowck | |
| parent | a2cdcb3fea2baae5d20eabaa412e0d2f5b98c318 (diff) | |
| download | rust-41d4ea231410004f8f07bc097c51a5fe991b4ba5.tar.gz rust-41d4ea231410004f8f07bc097c51a5fe991b4ba5.zip | |
Don't suggest reborrow if usage is inside a closure
Diffstat (limited to 'src/test/ui/borrowck')
| -rw-r--r-- | src/test/ui/borrowck/issue-101119.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/borrowck/issue-101119.stderr | 15 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/issue-101119.rs b/src/test/ui/borrowck/issue-101119.rs new file mode 100644 index 00000000000..64e52eaac06 --- /dev/null +++ b/src/test/ui/borrowck/issue-101119.rs @@ -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() {} diff --git a/src/test/ui/borrowck/issue-101119.stderr b/src/test/ui/borrowck/issue-101119.stderr new file mode 100644 index 00000000000..a22afdc6764 --- /dev/null +++ b/src/test/ui/borrowck/issue-101119.stderr @@ -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`. |
