Skip to content

improve case with method in trait, one named one anonymous lifetime parameter #42702

Closed
@gaurikholkar-zz

Description

@gaurikholkar-zz

In #42669 , we are currently not improving the error message for the methods in traits. For this example,

trait Foo {
  fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
              //    -  consider changing the type of `x` to `&'a i32`
        if x > y { x } else { y }
             //      ^ - lifetime `'a` required 
  }
} 
note: ...changing the signature in the trait may require changing the corresponding impls of the trait

cc @nikomatsakis

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions