-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
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 }
}
}
antonok-edm
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics