@@ -346,17 +346,16 @@ impl<T:?Sized> MarkerTrait for T { }
346346#[ stable( feature = "rust1" , since = "1.0.0" ) ]
347347pub trait PhantomFn < A : ?Sized , R : ?Sized =( ) > { }
348348
349- /// `PhantomData` is a way to tell the compiler about fake fields.
350- /// Phantom data is required whenever type parameters are not used.
351- /// The idea is that if the compiler encounters a `PhantomData<T>`
352- /// instance, it will behave *as if* an instance of the type `T` were
353- /// present for the purpose of various automatic analyses.
349+ /// `PhantomData<T>` allows you to describe that a type acts as if it stores a value of type `T`,
350+ /// even though it does not. This allows you to inform the compiler about certain safety properties
351+ /// of your code.
352+ ///
353+ /// Though they both have scary names, `PhantomData<T>` and "phantom types" are unrelated. 👻👻👻
354354///
355355/// # Examples
356356///
357357/// When handling external resources over a foreign function interface, `PhantomData<T>` can
358- /// prevent mismatches by enforcing types in the method implementations, although the struct
359- /// doesn't actually contain values of the resource type.
358+ /// prevent mismatches by enforcing types in the method implementations:
360359///
361360/// ```
362361/// # trait ResType { fn foo(&self); };
@@ -397,11 +396,6 @@ pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
397396/// commonly necessary if the structure is using an unsafe pointer
398397/// like `*mut T` whose referent may be dropped when the type is
399398/// dropped, as a `*mut T` is otherwise not treated as owned.
400- ///
401- /// FIXME. Better documentation and examples of common patterns needed
402- /// here! For now, please see [RFC 738][738] for more information.
403- ///
404- /// [738]: https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md
405399#[ lang="phantom_data" ]
406400#[ stable( feature = "rust1" , since = "1.0.0" ) ]
407401pub struct PhantomData < T : ?Sized > ;
0 commit comments