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