Skip to content

method has an incompatible type for trait due to lifetimes has too wide a span #33624

Open

Description

For

trait A<'a> {
    fn a<'b>(self) -> Box<A<'b>>;
}

struct C;

impl<'a> A<'a> for C {
    fn a<'b>(self) -> Box<A<'a>>{}
}

it would be much more useful if we spanned the offending lifetime rather than the whole method: i.e. like this

error: method `a` has an incompatible type for trait:
 expected bound lifetime parameter 'b,
    found concrete lifetime [--explain E0053]
 --> <anon>:8:5
8 |>     fn a<'b>(self) -> Box<A<'a>>{}
  |>                             ^^

instead of

error: method `a` has an incompatible type for trait:
 expected bound lifetime parameter 'b,
    found concrete lifetime [--explain E0053]
 --> <anon>:8:5
8 |>     fn a<'b>(self) -> Box<A<'a>>{}
  |>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regionsA-traitsArea: Trait systemD-confusingDiagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.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