| 1 |
error: lifetime may not live long enough |
| 2 |
--> tests/ui/invariant.rs:7:5 |
| 3 |
| |
| 4 |
6 | fn require_covariant<'a>(phantom: InvariantPhantom<&'static str>) -> InvariantPhantom<&'a str> { |
| 5 |
| -- lifetime `'a` defined here |
| 6 |
7 | phantom |
| 7 |
| ^^^^^^^ returning this value requires that `'a` must outlive `'static` |
| 8 |
| |
| 9 |
= note: requirement occurs because of the type `InvariantPhantom<&str>`, which makes the generic argument `&str` invariant |
| 10 |
= note: the enum `InvariantPhantom<T>` is invariant over the parameter `T` |
| 11 |
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |
| 12 |
|
| 13 |
error: lifetime may not live long enough |
| 14 |
--> tests/ui/invariant.rs:11:5 |
| 15 |
| |
| 16 |
10 | fn require_contravariant<'a>(phantom: InvariantPhantom<&'a str>) -> InvariantPhantom<&'static str> { |
| 17 |
| -- lifetime `'a` defined here |
| 18 |
11 | phantom |
| 19 |
| ^^^^^^^ returning this value requires that `'a` must outlive `'static` |
| 20 |
| |
| 21 |
= note: requirement occurs because of the type `InvariantPhantom<&str>`, which makes the generic argument `&str` invariant |
| 22 |
= note: the enum `InvariantPhantom<T>` is invariant over the parameter `T` |
| 23 |
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance |