]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/type-check-pointer-coercions.stderr
Rollup merge of #84262 - camelid:sized-ice, r=estebank
[rust.git] / src / test / ui / nll / type-check-pointer-coercions.stderr
1 error: lifetime may not live long enough
2   --> $DIR/type-check-pointer-coercions.rs:4:5
3    |
4 LL | fn shared_to_const<'a, 'b>(x: &&'a i32) -> *const &'b i32 {
5    |                    --  -- lifetime `'b` defined here
6    |                    |
7    |                    lifetime `'a` defined here
8 LL |     x
9    |     ^ returning this value requires that `'a` must outlive `'b`
10    |
11    = help: consider adding the following bound: `'a: 'b`
12
13 error: lifetime may not live long enough
14   --> $DIR/type-check-pointer-coercions.rs:8:5
15    |
16 LL | fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 {
17    |                    --  -- lifetime `'b` defined here
18    |                    |
19    |                    lifetime `'a` defined here
20 LL |     x
21    |     ^ returning this value requires that `'a` must outlive `'b`
22    |
23    = help: consider adding the following bound: `'a: 'b`
24
25 error: lifetime may not live long enough
26   --> $DIR/type-check-pointer-coercions.rs:13:5
27    |
28 LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 {
29    |                  --  -- lifetime `'b` defined here
30    |                  |
31    |                  lifetime `'a` defined here
32 LL |     // Two errors because *mut is invariant
33 LL |     x
34    |     ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
35    |
36    = help: consider adding the following bound: `'b: 'a`
37    = note: requirement occurs because of a mutable pointer to &i32
38    = note: mutable pointers are invariant over their type parameter
39    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
40
41 error: lifetime may not live long enough
42   --> $DIR/type-check-pointer-coercions.rs:13:5
43    |
44 LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 {
45    |                  --  -- lifetime `'b` defined here
46    |                  |
47    |                  lifetime `'a` defined here
48 LL |     // Two errors because *mut is invariant
49 LL |     x
50    |     ^ returning this value requires that `'a` must outlive `'b`
51    |
52    = help: consider adding the following bound: `'a: 'b`
53    = note: requirement occurs because of a mutable pointer to &i32
54    = note: mutable pointers are invariant over their type parameter
55    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
56
57 help: `'b` and `'a` must be the same: replace one with the other
58
59 error: lifetime may not live long enough
60   --> $DIR/type-check-pointer-coercions.rs:18:5
61    |
62 LL | fn mut_to_const<'a, 'b>(x: *mut &'a i32) -> *const &'b i32 {
63    |                 --  -- lifetime `'b` defined here
64    |                 |
65    |                 lifetime `'a` defined here
66 LL |     x
67    |     ^ returning this value requires that `'a` must outlive `'b`
68    |
69    = help: consider adding the following bound: `'a: 'b`
70
71 error: lifetime may not live long enough
72   --> $DIR/type-check-pointer-coercions.rs:24:5
73    |
74 LL | fn array_elem<'a, 'b>(x: &'a i32) -> *const &'b i32 {
75    |               --  -- lifetime `'b` defined here
76    |               |
77    |               lifetime `'a` defined here
78 ...
79 LL |     y
80    |     ^ returning this value requires that `'a` must outlive `'b`
81    |
82    = help: consider adding the following bound: `'a: 'b`
83
84 error: lifetime may not live long enough
85   --> $DIR/type-check-pointer-coercions.rs:30:5
86    |
87 LL | fn array_coerce<'a, 'b>(x: &'a i32) -> *const [&'b i32; 3] {
88    |                 --  -- lifetime `'b` defined here
89    |                 |
90    |                 lifetime `'a` defined here
91 ...
92 LL |     y
93    |     ^ returning this value requires that `'a` must outlive `'b`
94    |
95    = help: consider adding the following bound: `'a: 'b`
96
97 error: lifetime may not live long enough
98   --> $DIR/type-check-pointer-coercions.rs:36:5
99    |
100 LL | fn nested_array<'a, 'b>(x: &'a i32) -> *const [&'b i32; 2] {
101    |                 --  -- lifetime `'b` defined here
102    |                 |
103    |                 lifetime `'a` defined here
104 ...
105 LL |     y
106    |     ^ returning this value requires that `'a` must outlive `'b`
107    |
108    = help: consider adding the following bound: `'a: 'b`
109
110 error: aborting due to 8 previous errors
111