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

#[derive(TypedBuilder)] triggers clippy::used_underscore_binding for _ident: PhantomData<> #113

Closed
xFrednet opened this issue Sep 17, 2023 · 0 comments

Comments

@xFrednet
Copy link

The underscore binding is used for fields, which should not be used. In my project, I often use PhantomData to store a lifetime. This triggers the clippy::used_underscore_binding lint, when deriving TypedBuilder

Reproducer

#![warn(clippy::used_underscore_binding)]

use std::marker::PhantomData;

use typed_builder::TypedBuilder;

#[derive(TypedBuilder)]
pub struct Bar<'ast> {
    #[builder(default)]
    _lifetime: PhantomData<&'ast ()>,
}

And run cargo clippy

Suggestions

I'm not sure, if there is a simple way to fix this. Maybe #[allow(clippy::used_underscore_binding)] would fix it. Another option could be the addition of a new #[builder] attribute, that only sets the value and doesn't allow the user to override it.

These are just some suggestions, there are probably better solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant