Closed
Description
We need to improve the error message for the second case.
trait Foo {
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32;
}
// First is when impl implements same signature as trait:
impl Foo for () {
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
if x > y { x } else { y }
}
}
// Second is when impl implements different signature from trait.
// Here we *could* suggest adding lifetime to `x`.
trait Bar {
fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32;
}
impl Bar for () {
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
// this body `y` would be OK
if x > y { x } else { y }
}
}