]> git.lizzy.rs Git - rust.git/blob - src/test/ui/regions/regions-trait-object-subtyping.nll.stderr
Add variance-related information to lifetime error messages
[rust.git] / src / test / ui / regions / regions-trait-object-subtyping.nll.stderr
1 error: lifetime may not live long enough
2   --> $DIR/regions-trait-object-subtyping.rs:15:5
3    |
4 LL | fn foo3<'a,'b>(x: &'a mut dyn Dummy) -> &'b mut dyn Dummy {
5    |         -- -- lifetime `'b` defined here
6    |         |
7    |         lifetime `'a` defined here
8 LL |     // Without knowing 'a:'b, we can't coerce
9 LL |     x
10    |     ^ returning this value requires that `'a` must outlive `'b`
11    |
12    = help: consider adding the following bound: `'a: 'b`
13    = note: requirement occurs because of a mutable reference to dyn Dummy
14    = note: mutable references are invariant over their type parameter
15    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
16
17 error: lifetime may not live long enough
18   --> $DIR/regions-trait-object-subtyping.rs:22:5
19    |
20 LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut dyn Dummy>) -> Wrapper<&'b mut dyn Dummy> {
21    |         --    -- lifetime `'b` defined here
22    |         |
23    |         lifetime `'a` defined here
24 LL |     // We can't coerce because it is packed in `Wrapper`
25 LL |     x
26    |     ^ returning this value requires that `'b` must outlive `'a`
27    |
28    = help: consider adding the following bound: `'b: 'a`
29    = note: requirement occurs because of a mutable reference to dyn Dummy
30    = note: mutable references are invariant over their type parameter
31    = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
32
33 error: aborting due to 2 previous errors
34