]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr
Miscellaneous inlining improvements
[rust.git] / src / test / ui / nll / closure-requirements / propagate-approximated-shorter-to-static-comparing-against-free.stderr
1 note: no external requirements
2   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:21:15
3    |
4 LL |       foo(cell, |cell_a, cell_x| {
5    |  _______________^
6 LL | |         cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
7 LL | |
8 LL | |     })
9    | |_____^
10    |
11    = note: defining type: case1::{closure#0} with closure substs [
12                i32,
13                for<'r> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('r) }) u32>)),
14                (),
15            ]
16
17 error[E0521]: borrowed data escapes outside of closure
18   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:22:9
19    |
20 LL |     foo(cell, |cell_a, cell_x| {
21    |                ------  ------ `cell_x` is a reference that is only valid in the closure body
22    |                |
23    |                `cell_a` declared here, outside of the closure body
24 LL |         cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure
25    |         ^^^^^^^^^^^^^^^^^^^^^^^^ `cell_x` escapes the closure body here
26
27 note: no external requirements
28   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:18:1
29    |
30 LL | / fn case1() {
31 LL | |     let a = 0;
32 LL | |     let cell = Cell::new(&a);
33 LL | |     foo(cell, |cell_a, cell_x| {
34 ...  |
35 LL | |     })
36 LL | | }
37    | |_^
38    |
39    = note: defining type: case1
40
41 note: external requirements
42   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:35:15
43    |
44 LL |       foo(cell, |cell_a, cell_x| {
45    |  _______________^
46 LL | |         cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
47 LL | |     })
48    | |_____^
49    |
50    = note: defining type: case2::{closure#0} with closure substs [
51                i32,
52                for<'r> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed('r) }) u32>)),
53                (),
54            ]
55    = note: number of external vids: 2
56    = note: where '_#1r: '_#0r
57
58 note: no external requirements
59   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:28:1
60    |
61 LL | / fn case2() {
62 LL | |     let a = 0;
63 LL | |     let cell = Cell::new(&a);
64 LL | |
65 ...  |
66 LL | |     })
67 LL | | }
68    | |_^
69    |
70    = note: defining type: case2
71
72 error[E0597]: `a` does not live long enough
73   --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:30:26
74    |
75 LL |       let cell = Cell::new(&a);
76    |                            ^^ borrowed value does not live long enough
77 ...
78 LL | /     foo(cell, |cell_a, cell_x| {
79 LL | |         cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static -> borrow error
80 LL | |     })
81    | |______- argument requires that `a` is borrowed for `'static`
82 LL |   }
83    |   - `a` dropped here while still borrowed
84
85 error: aborting due to 2 previous errors
86
87 Some errors have detailed explanations: E0521, E0597.
88 For more information about an error, try `rustc --explain E0521`.