Skip to content

"Implement missing members" helper doesn't parenthesise compound traits behind references #10326

Open
@Tamschi

Description

@Tamschi

Given

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

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

, using the "Implement missing members" command leads to the following code:

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

impl<'a, T: B> A<dyn 'a + B> for T {
    fn a(&self) -> &dyn 'a + B { // <-- Syntax Error: ambiguous `+` in a type
        todo!()
    }
}

This should be

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

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

instead, as after then applying the "use parentheses to disambiguate: …" helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assistsC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions