You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The error message for a trait with an unused parameter recommends the use of PhantomFn even though it's deprecated. It should presumably recommend PhantomData instead, and the documentation on PhantomData should be updated to include an example of how to use it with a trait.
<anon>:1:11: 1:12 error: parameter `T` is never used
<anon>:1 trait Foo<T> {
^
<anon>:1:12: 1:12 help: consider removing `T` or using a marker such as `core::marker::PhantomFn`
error: aborting due to previous error
You also get the same error today (suggesting PhantomFn) when using a "marker-like" trait with no functions, which is filed as #22598 (it needs a better error message).
The text was updated successfully, but these errors were encountered:
I admit to being slightly confused as to why PhantomFn and MarkerTrait are deprecated. This happened in #23938 (Remove variances from traits and deprecate PhantomFn/MarkerTrait). But MarkerTrait is still used as the super trait of the other markers (Send, Sized, and Reflect).
As near as I can tell, without using either of these two deprecated traits, the only way to declare a marker-like trait (e.g. one that doesn't use Self) is to use an associated type with PhantomData, e.g.
traitFoo{type_phantom = PhantomData<Self>;}
And it's not even clear if this is "correct". #23938 says that traits no longer have variance, so I guess it's ok? But I don't actually know.
Huh, you're right. I apparently had the beta on my system (it seems rustup.sh started installing that by default), and I'm not sure what version play.rust-lang.org is using right now (Edit: I'm told it's also on the beta).
Anyway, it seems PhantomFn stopped being recommended as of #23938.
The error message for a trait with an unused parameter recommends the use of
PhantomFn
even though it's deprecated. It should presumably recommendPhantomData
instead, and the documentation onPhantomData
should be updated to include an example of how to use it with a trait.Example (play):
yields
You also get the same error today (suggesting
PhantomFn
) when using a "marker-like" trait with no functions, which is filed as #22598 (it needs a better error message).The text was updated successfully, but these errors were encountered: