1 error: lifetime may not live long enough
2 --> $DIR/type-check-pointer-coercions.rs:2:5
4 LL | fn shared_to_const<'a, 'b>(x: &&'a i32) -> *const &'b i32 {
5 | -- -- lifetime `'b` defined here
7 | lifetime `'a` defined here
9 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
11 = help: consider adding the following bound: `'a: 'b`
13 error: lifetime may not live long enough
14 --> $DIR/type-check-pointer-coercions.rs:6:5
16 LL | fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 {
17 | -- -- lifetime `'b` defined here
19 | lifetime `'a` defined here
21 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
23 = help: consider adding the following bound: `'a: 'b`
25 error: lifetime may not live long enough
26 --> $DIR/type-check-pointer-coercions.rs:11:5
28 LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 {
29 | -- -- lifetime `'b` defined here
31 | lifetime `'a` defined here
32 LL | // Two errors because *mut is invariant
34 | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
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
41 error: lifetime may not live long enough
42 --> $DIR/type-check-pointer-coercions.rs:11:5
44 LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 {
45 | -- -- lifetime `'b` defined here
47 | lifetime `'a` defined here
48 LL | // Two errors because *mut is invariant
50 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
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
57 help: `'b` and `'a` must be the same: replace one with the other
59 error: lifetime may not live long enough
60 --> $DIR/type-check-pointer-coercions.rs:16:5
62 LL | fn mut_to_const<'a, 'b>(x: *mut &'a i32) -> *const &'b i32 {
63 | -- -- lifetime `'b` defined here
65 | lifetime `'a` defined here
67 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
69 = help: consider adding the following bound: `'a: 'b`
71 error: lifetime may not live long enough
72 --> $DIR/type-check-pointer-coercions.rs:22:5
74 LL | fn array_elem<'a, 'b>(x: &'a i32) -> *const &'b i32 {
75 | -- -- lifetime `'b` defined here
77 | lifetime `'a` defined here
80 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
82 = help: consider adding the following bound: `'a: 'b`
84 error: lifetime may not live long enough
85 --> $DIR/type-check-pointer-coercions.rs:28:5
87 LL | fn array_coerce<'a, 'b>(x: &'a i32) -> *const [&'b i32; 3] {
88 | -- -- lifetime `'b` defined here
90 | lifetime `'a` defined here
93 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
95 = help: consider adding the following bound: `'a: 'b`
97 error: lifetime may not live long enough
98 --> $DIR/type-check-pointer-coercions.rs:34:5
100 LL | fn nested_array<'a, 'b>(x: &'a i32) -> *const [&'b i32; 2] {
101 | -- -- lifetime `'b` defined here
103 | lifetime `'a` defined here
106 | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
108 = help: consider adding the following bound: `'a: 'b`
110 error: aborting due to 8 previous errors