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 }
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
gaurikholkar-zz commentedon Sep 29, 2017
@nikomatsakis, maybe this needs mentoring?
Also for E0621, we don't handle Impl Items, should I open up an issue for that?
impl
item doesn't conform totrait
#65068Rollup merge of rust-lang#65068 - estebank:trait-impl-lt-mismatch, r=…
Rollup merge of rust-lang#65068 - estebank:trait-impl-lt-mismatch, r=…
Rollup merge of rust-lang#65068 - estebank:trait-impl-lt-mismatch, r=…
Auto merge of #65068 - estebank:trait-impl-lt-mismatch, r=nikomatsakis
steveklabnik commentedon Apr 29, 2021
Triage: here's the error today:
Dylan-DPC commentedon Jun 9, 2023
Current error:
Dylan-DPC commentedon Aug 30, 2024
Current output:
This already indicates that the lifetime should be added, so should be good enough to close this issue.