]> git.lizzy.rs Git - rust.git/blob - src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr
Auto merge of #85020 - lrh2000:named-upvars, r=tmandry
[rust.git] / src / test / ui / closures / closure-bounds-static-cant-capture-borrowed.nll.stderr
1 error[E0621]: explicit lifetime required in the type of `x`
2   --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
3    |
4 LL | /     bar(|| {
5 LL | |
6 LL | |         let _ = x;
7 LL | |     })
8    | |______^ lifetime `'static` required
9
10 error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
11   --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
12    |
13 LL |     bar(|| {
14    |         ^^ may outlive borrowed value `x`
15 LL |
16 LL |         let _ = x;
17    |                 - `x` is borrowed here
18    |
19 note: function requires argument type to outlive `'static`
20   --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
21    |
22 LL | /     bar(|| {
23 LL | |
24 LL | |         let _ = x;
25 LL | |     })
26    | |______^
27 help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword
28    |
29 LL |     bar(move || {
30    |         ++++
31
32 error: aborting due to 2 previous errors
33
34 Some errors have detailed explanations: E0373, E0621.
35 For more information about an error, try `rustc --explain E0373`.