diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-06-29 05:48:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-29 05:48:40 +0200 |
| commit | 7e1869f9b4232655c4f975ba30322c3dfd2fa289 (patch) | |
| tree | 1530ee47660c4e77b5bfb1b64d41de8c36f48243 /tests | |
| parent | f35f213d2704665d9888e296809a51e4050ef08a (diff) | |
| parent | 5e83ddd27946a74f9ab3390977b99c32a365b7a0 (diff) | |
| download | rust-7e1869f9b4232655c4f975ba30322c3dfd2fa289.tar.gz rust-7e1869f9b4232655c4f975ba30322c3dfd2fa289.zip | |
Rollup merge of #113137 - lukas-code:no-moving-references, r=compiler-errors
don't suggest `move` for borrows that aren't closures fixes https://github.com/rust-lang/rust/issues/113087
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/closures/issue-113087.rs | 11 | ||||
| -rw-r--r-- | tests/ui/closures/issue-113087.stderr | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/closures/issue-113087.rs b/tests/ui/closures/issue-113087.rs new file mode 100644 index 00000000000..a4edc2f2f0b --- /dev/null +++ b/tests/ui/closures/issue-113087.rs @@ -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); + }); + } +} diff --git a/tests/ui/closures/issue-113087.stderr b/tests/ui/closures/issue-113087.stderr new file mode 100644 index 00000000000..8ccef4a54f5 --- /dev/null +++ b/tests/ui/closures/issue-113087.stderr @@ -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`. |
