]> git.proxmox.com Git - rustc.git/blame - src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / closures / closure-bounds-static-cant-capture-borrowed.nll.stderr
CommitLineData
3c0e092e 1error[E0521]: borrowed data escapes outside of function
48663c56
XL
2 --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
3 |
3c0e092e
XL
4LL | fn foo(x: &()) {
5 | - - let's call the lifetime of this reference `'1`
6 | |
7 | `x` is a reference that is only valid in the function body
48663c56
XL
8LL | / bar(|| {
9LL | |
10LL | | let _ = x;
11LL | | })
3c0e092e
XL
12 | | ^
13 | | |
14 | |______`x` escapes the function body here
15 | argument requires that `'1` must outlive `'static`
48663c56
XL
16
17error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
18 --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
19 |
20LL | bar(|| {
21 | ^^ may outlive borrowed value `x`
22LL |
23LL | let _ = x;
24 | - `x` is borrowed here
25 |
26note: function requires argument type to outlive `'static`
27 --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
28 |
29LL | / bar(|| {
30LL | |
31LL | | let _ = x;
32LL | | })
33 | |______^
34help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword
35 |
36LL | bar(move || {
94222f64 37 | ++++
48663c56
XL
38
39error: aborting due to 2 previous errors
40
3c0e092e 41Some errors have detailed explanations: E0373, E0521.
48663c56 42For more information about an error, try `rustc --explain E0373`.