Skip to content

"implement the missing item: …" helper does not substitute type parameter #10327

Closed
@Tamschi

Description

@Tamschi

This seems distinct from #10326.

Given

trait A<T> {
    fn a(&self) -> &T;
}
struct B {}

impl<'a, T> A<B> for T {} // <-- not all trait items implemented, missing: `a` in implementation

, applying the "implement the missing item: …" helper leads to the following code (after formatting):

trait A<T> {
    fn a(&self) -> &T;
}
struct B {}

impl<'a, T> A<B> for T {
    fn a(&self) -> &T { // <-- method `a` has an incompatible type for trait\nexpected fn pointer `fn(&T) -> &B`\n found fn pointer `fn(&T) -> &T`
        todo!()
    }
}

This should instead be

trait A<T> {
    fn a(&self) -> &T;
}
struct B {}

impl<'a, T> A<B> for T {
    fn a(&self) -> &B { // <-- Ok
        todo!()
    }
}

as with the "Implement missing members" helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions