Skip to content

Bad suggestion for field_reassign_with_default when generics are involved #6944

@ThibsG

Description

@ThibsG

I tried this code:

#[derive(Default)]
struct Wrapper<T> {
    i: T,
}

let mut a: Wrapper<bool> = Default::default();
a.i = true;

I expected to see this happen:

Generics are handled correctly like the following:

note: consider initializing the variable with `Wrapper::<bool> { i: true }` and removing relevant reassignments

Instead, this happened:

Suggestion is missing the use of :: just before generic types, leading to a compile-time error.

note: consider initializing the variable with `Wrapper<bool> { i: true }` and removing relevant reassignments

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions