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