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