Skip to content

Catch use of PhantomData that requires T: Sized #2308

Open
@dtolnay

Description

@dtolnay

In Serde the traits we implement for PhantomData should have worked for T: ?Sized, but as a bug they required T: Sized -- fixed in serde-rs/serde@4751627. Could Clippy have caught this? I struggle to think of any use of PhantomData<T> where T is an unconstrained type parameter where you would not want to allow ?Sized. As a starting point, maybe we could catch impls of the form:

impl<..., T, ...> Trait<...> for PhantomData<T> { /* ... */ }

where there are no trait bounds on T. In this case you pretty much always want T: ?Sized right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-middleType: Probably requires verifiying typesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions