Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad suggestion for field_reassign_with_default when generics are involved #6944

Closed
ThibsG opened this issue Mar 21, 2021 · 0 comments · Fixed by #6945
Closed

Bad suggestion for field_reassign_with_default when generics are involved #6944

ThibsG opened this issue Mar 21, 2021 · 0 comments · Fixed by #6945
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@ThibsG
Copy link
Contributor

ThibsG commented Mar 21, 2021

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
@ThibsG ThibsG added the C-bug Category: Clippy is not doing the correct thing label Mar 21, 2021
@bors bors closed this as completed in f3de78e Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant