Closed
Description
This example:
struct Ref<'a> { x: &'a u32 }
fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
x.push(y);
}
fn main() { }
currently prints an old-school and crappy error:
error[E0308]: mismatched types
--> src/main.rs:4:12
|
4 | x.push(y);
| ^ lifetime mismatch
|
= note: expected type `Ref<'a>`
found type `Ref<'b>`
note: the lifetime 'b as defined on the function body at 3:1...
--> src/main.rs:3:1
|
3 | / fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
4 | | x.push(y);
5 | | }
| |_^
note: ...does not necessarily outlive the lifetime 'a as defined on the function body at 3:1
--> src/main.rs:3:1
|
3 | / fn foo<'a, 'b>(mut x: Vec<Ref<'a>>, y: Ref<'b>) {
4 | | x.push(y);
5 | | }
| |_^
It should print something like:
error[E0623]: lifetime mismatch
--> src/main.rs:2:12
|
1 | fn foo<'a, 'b>(mut x: Vec<Ref<'a, u32>>, y: Ref<'b, u32>) {
| ------------ ------------ these two types are declared with different lifetimes...
2 | x.push(y);
| ^ ...but data from `y` flows into `x` here