-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Catch use of PhantomData that requires T: Sized #2308
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
Comments
The latter I agree with being a clear case where a I can't think of any counter examples for arbitrary bounds, we should probably just run it on a few big crates and see what happens. |
Oh but the "false positive" has a where-clause |
Perhaps this lint could be generalised to requiring |
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:
where there are no trait bounds on T. In this case you pretty much always want T: ?Sized right?
The text was updated successfully, but these errors were encountered: