|
| 1 | +error: lifetime may not live long enough |
| 2 | + --> $DIR/fn_def_coercion.rs:10:17 |
| 3 | + | |
| 4 | +LL | fn f<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 5 | + | -- -- lifetime `'b` defined here |
| 6 | + | | |
| 7 | + | lifetime `'a` defined here |
| 8 | +LL | let mut x = foo::<&'a ()>; |
| 9 | + | ^^^^^^^^^^^^^ assignment requires that `'a` must outlive `'b` |
| 10 | + | |
| 11 | + = help: consider adding the following bound: `'a: 'b` |
| 12 | + = note: requirement occurs because of a function pointer to `foo` |
| 13 | + = note: the function `foo` is invariant over the parameter `T` |
| 14 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 15 | + |
| 16 | +error: lifetime may not live long enough |
| 17 | + --> $DIR/fn_def_coercion.rs:11:5 |
| 18 | + | |
| 19 | +LL | fn f<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 20 | + | -- -- lifetime `'b` defined here |
| 21 | + | | |
| 22 | + | lifetime `'a` defined here |
| 23 | +LL | let mut x = foo::<&'a ()>; |
| 24 | +LL | x = foo::<&'b ()>; |
| 25 | + | ^^^^^^^^^^^^^^^^^ assignment requires that `'b` must outlive `'a` |
| 26 | + | |
| 27 | + = help: consider adding the following bound: `'b: 'a` |
| 28 | + = note: requirement occurs because of a function pointer to `foo` |
| 29 | + = note: the function `foo` is invariant over the parameter `T` |
| 30 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 31 | + |
| 32 | +help: `'a` and `'b` must be the same: replace one with the other |
| 33 | + |
| 34 | +error: lifetime may not live long enough |
| 35 | + --> $DIR/fn_def_coercion.rs:20:12 |
| 36 | + | |
| 37 | +LL | fn g<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 38 | + | -- -- lifetime `'c` defined here |
| 39 | + | | |
| 40 | + | lifetime `'a` defined here |
| 41 | +LL | let x = foo::<&'c ()>; |
| 42 | +LL | let _: &'c () = x(a); |
| 43 | + | ^^^^^^ type annotation requires that `'a` must outlive `'c` |
| 44 | + | |
| 45 | + = help: consider adding the following bound: `'a: 'c` |
| 46 | + |
| 47 | +error: lifetime may not live long enough |
| 48 | + --> $DIR/fn_def_coercion.rs:30:5 |
| 49 | + | |
| 50 | +LL | fn i<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 51 | + | -- -- lifetime `'b` defined here |
| 52 | + | | |
| 53 | + | lifetime `'a` defined here |
| 54 | +LL | let mut x = foo::<&'c ()>; |
| 55 | +LL | x = foo::<&'b ()>; |
| 56 | + | ^^^^^^^^^^^^^^^^^ assignment requires that `'b` must outlive `'a` |
| 57 | + | |
| 58 | + = help: consider adding the following bound: `'b: 'a` |
| 59 | + = note: requirement occurs because of a function pointer to `foo` |
| 60 | + = note: the function `foo` is invariant over the parameter `T` |
| 61 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 62 | + |
| 63 | +error: lifetime may not live long enough |
| 64 | + --> $DIR/fn_def_coercion.rs:31:5 |
| 65 | + | |
| 66 | +LL | fn i<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 67 | + | -- -- lifetime `'b` defined here |
| 68 | + | | |
| 69 | + | lifetime `'a` defined here |
| 70 | +... |
| 71 | +LL | x = foo::<&'a ()>; |
| 72 | + | ^^^^^^^^^^^^^^^^^ assignment requires that `'a` must outlive `'b` |
| 73 | + | |
| 74 | + = help: consider adding the following bound: `'a: 'b` |
| 75 | + = note: requirement occurs because of a function pointer to `foo` |
| 76 | + = note: the function `foo` is invariant over the parameter `T` |
| 77 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 78 | + |
| 79 | +help: `'a` and `'b` must be the same: replace one with the other |
| 80 | + | |
| 81 | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 82 | + |
| 83 | +error: lifetime may not live long enough |
| 84 | + --> $DIR/fn_def_coercion.rs:39:17 |
| 85 | + | |
| 86 | +LL | fn j<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 87 | + | -- -- lifetime `'b` defined here |
| 88 | + | | |
| 89 | + | lifetime `'a` defined here |
| 90 | +LL | let x = match true { |
| 91 | +LL | true => foo::<&'b ()>, |
| 92 | + | ^^^^^^^^^^^^^ assignment requires that `'b` must outlive `'a` |
| 93 | + | |
| 94 | + = help: consider adding the following bound: `'b: 'a` |
| 95 | + = note: requirement occurs because of a function pointer to `foo` |
| 96 | + = note: the function `foo` is invariant over the parameter `T` |
| 97 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 98 | + |
| 99 | +error: lifetime may not live long enough |
| 100 | + --> $DIR/fn_def_coercion.rs:40:18 |
| 101 | + | |
| 102 | +LL | fn j<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 103 | + | -- -- lifetime `'b` defined here |
| 104 | + | | |
| 105 | + | lifetime `'a` defined here |
| 106 | +... |
| 107 | +LL | false => foo::<&'a ()>, |
| 108 | + | ^^^^^^^^^^^^^ assignment requires that `'a` must outlive `'b` |
| 109 | + | |
| 110 | + = help: consider adding the following bound: `'a: 'b` |
| 111 | + = note: requirement occurs because of a function pointer to `foo` |
| 112 | + = note: the function `foo` is invariant over the parameter `T` |
| 113 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 114 | + |
| 115 | +help: `'a` and `'b` must be the same: replace one with the other |
| 116 | + | |
| 117 | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` |
| 118 | + |
| 119 | +error: lifetime may not live long enough |
| 120 | + --> $DIR/fn_def_coercion.rs:50:18 |
| 121 | + | |
| 122 | +LL | fn k<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 123 | + | -- -- lifetime `'c` defined here |
| 124 | + | | |
| 125 | + | lifetime `'a` defined here |
| 126 | +... |
| 127 | +LL | false => foo::<&'a ()>, |
| 128 | + | ^^^^^^^^^^^^^ assignment requires that `'a` must outlive `'c` |
| 129 | + | |
| 130 | + = help: consider adding the following bound: `'a: 'c` |
| 131 | + = note: requirement occurs because of a function pointer to `foo` |
| 132 | + = note: the function `foo` is invariant over the parameter `T` |
| 133 | + = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 134 | + |
| 135 | +error: lifetime may not live long enough |
| 136 | + --> $DIR/fn_def_coercion.rs:54:5 |
| 137 | + | |
| 138 | +LL | fn k<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { |
| 139 | + | -- -- lifetime `'b` defined here |
| 140 | + | | |
| 141 | + | lifetime `'a` defined here |
| 142 | +... |
| 143 | +LL | x(b); |
| 144 | + | ^^^^ argument requires that `'b` must outlive `'a` |
| 145 | + | |
| 146 | + = help: consider adding the following bound: `'b: 'a` |
| 147 | + |
| 148 | +help: the following changes may resolve your lifetime errors |
| 149 | + | |
| 150 | + = help: add bound `'a: 'c` |
| 151 | + = help: add bound `'b: 'a` |
| 152 | + |
| 153 | +error: aborting due to 9 previous errors |
| 154 | + |
0 commit comments