@@ -35,6 +35,7 @@ use hash::Hasher;
3535#[ stable( feature = "rust1" , since = "1.0.0" ) ]
3636#[ lang="send" ]
3737#[ rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely" ]
38+ #[ allow( deprecated) ]
3839pub unsafe trait Send : MarkerTrait {
3940 // empty.
4041}
@@ -50,6 +51,7 @@ impl !Send for Managed { }
5051#[ lang="sized" ]
5152#[ rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time" ]
5253#[ fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
54+ #[ allow( deprecated) ]
5355pub trait Sized : MarkerTrait {
5456 // Empty.
5557}
@@ -203,6 +205,7 @@ pub trait Copy : Clone {
203205#[ stable( feature = "rust1" , since = "1.0.0" ) ]
204206#[ lang="sync" ]
205207#[ rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely" ]
208+ #[ allow( deprecated) ]
206209pub unsafe trait Sync : MarkerTrait {
207210 // Empty
208211}
@@ -269,84 +272,41 @@ macro_rules! impls{
269272 )
270273}
271274
272- /// `MarkerTrait` is intended to be used as the supertrait for traits
273- /// that don't have any methods but instead serve just to designate
274- /// categories of types. An example would be the `Send` trait, which
275- /// indicates types that are sendable: `Send` does not itself offer
276- /// any methods, but instead is used to gate access to data.
277- ///
278- /// FIXME. Better documentation needed here!
279- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
275+ /// `MarkerTrait` is deprecated and no longer needed.
276+ #[ unstable( feature = "core" , reason = "deprecated" ) ]
277+ #[ deprecated( since = "1.0.0" , reason = "No longer needed" ) ]
278+ #[ allow( deprecated) ]
279+ #[ cfg( stage0) ]
280280pub trait MarkerTrait : PhantomFn < Self , Self > { }
281- // ~~~~~ <-- FIXME(#22806)?
282- //
283- // Marker trait has been made invariant so as to avoid inf recursion,
284- // but we should ideally solve the underlying problem. That's a bit
285- // complicated.
286281
282+ /// `MarkerTrait` is deprecated and no longer needed.
283+ #[ unstable( feature = "core" , reason = "deprecated" ) ]
284+ #[ deprecated( since = "1.0.0" , reason = "No longer needed" ) ]
285+ #[ allow( deprecated) ]
286+ #[ cfg( not( stage0) ) ]
287+ pub trait MarkerTrait { }
288+
289+ #[ allow( deprecated) ]
287290impl < T : ?Sized > MarkerTrait for T { }
288291
289- /// `PhantomFn` is a marker trait for use with traits that contain
290- /// type or lifetime parameters that do not appear in any of their
291- /// methods. In that case, you can either remove those parameters, or
292- /// add a `PhantomFn` supertrait that reflects the signature of
293- /// methods that compiler should "pretend" exists. This most commonly
294- /// occurs for traits with no methods: in that particular case, you
295- /// can extend `MarkerTrait`, which is equivalent to
296- /// `PhantomFn<Self>`.
297- ///
298- /// # Examples
299- ///
300- /// As an example, consider a trait with no methods like `Even`, meant
301- /// to represent types that are "even":
302- ///
303- /// ```rust,ignore
304- /// trait Even { }
305- /// ```
306- ///
307- /// In this case, because the implicit parameter `Self` is unused, the
308- /// compiler will issue an error. The only purpose of this trait is to
309- /// categorize types (and hence instances of those types) as "even" or
310- /// not, so if we *were* going to have a method, it might look like:
311- ///
312- /// ```rust,ignore
313- /// trait Even {
314- /// fn is_even(self) -> bool { true }
315- /// }
316- /// ```
317- ///
318- /// Therefore, we can model a method like this as follows:
319- ///
320- /// ```
321- /// use std::marker::PhantomFn;
322- /// trait Even : PhantomFn<Self> { }
323- /// ```
324- ///
325- /// Another equivalent, but clearer, option would be to use
326- /// `MarkerTrait`:
327- ///
328- /// ```
329- /// # #![feature(core)]
330- /// use std::marker::MarkerTrait;
331- /// trait Even : MarkerTrait { }
332- /// ```
333- ///
334- /// # Parameters
335- ///
336- /// - `A` represents the type of the method's argument. You can use a
337- /// tuple to represent "multiple" arguments. Any types appearing here
338- /// will be considered "contravariant".
339- /// - `R`, if supplied, represents the method's return type. This defaults
340- /// to `()` as it is rarely needed.
341- ///
342- /// # Additional reading
343- ///
344- /// More details and background can be found in [RFC 738][738].
345- ///
346- /// [738]: https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md
292+ /// `PhantomFn` is a deprecated marker trait that is no longer needed.
347293#[ lang="phantom_fn" ]
348- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
349- pub trait PhantomFn < A : ?Sized , R : ?Sized =( ) > { }
294+ #[ unstable( feature = "core" , reason = "deprecated" ) ]
295+ #[ deprecated( since = "1.0.0" , reason = "No longer needed" ) ]
296+ #[ cfg( stage0) ]
297+ pub trait PhantomFn < A : ?Sized , R : ?Sized =( ) > {
298+ }
299+
300+ /// `PhantomFn` is a deprecated marker trait that is no longer needed.
301+ #[ unstable( feature = "core" , reason = "deprecated" ) ]
302+ #[ deprecated( since = "1.0.0" , reason = "No longer needed" ) ]
303+ #[ cfg( not( stage0) ) ]
304+ pub trait PhantomFn < A : ?Sized , R : ?Sized =( ) > {
305+ }
306+
307+ #[ allow( deprecated) ]
308+ #[ cfg( not( stage0) ) ]
309+ impl < A : ?Sized , R : ?Sized , T : ?Sized > PhantomFn < A , R > for T { }
350310
351311/// `PhantomData<T>` allows you to describe that a type acts as if it stores a value of type `T`,
352312/// even though it does not. This allows you to inform the compiler about certain safety properties
@@ -444,6 +404,7 @@ mod impls {
444404/// [1]: http://en.wikipedia.org/wiki/Parametricity
445405#[ rustc_reflect_like]
446406#[ unstable( feature = "core" , reason = "requires RFC and more experience" ) ]
407+ #[ allow( deprecated) ]
447408pub trait Reflect : MarkerTrait {
448409}
449410
0 commit comments