rust-lang/rust-clippy

Catch use of PhantomData that requires T: Sized

Open

#2,308 opened on 2017年12月27日

GitHub で見る
 (4 comments) (0 reactions) (0 assignees)Rust (10,406 stars) (1,391 forks)batch import
T-middlegood first issue

説明

In Serde the traits we implement for PhantomData should have worked for T: ?Sized, but as a bug they required T: Sized -- fixed in https://github.com/serde-rs/serde/commit/4751627f1cd14cacdf216188ccbb9ab0831e2b3f. 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?

コントリビューターガイド

Catch use of PhantomData that requires T: Sized · rust-lang/rust-clippy#2308 | Good First Issue