about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-04-02 00:40:39 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-04-02 00:40:39 +0530
commit2159bbf6506c04e06b73f0e45dcf4e92f1ffa1ac (patch)
treec26ca986a67a16693b591b04966973f2ea87521a /src
parent6a3e8447eb9f592059161b6bbb74d1c14dbe445a (diff)
parentbfc2f5de85c86b7d60a26d16b9991d9763b4c07e (diff)
downloadrust-2159bbf6506c04e06b73f0e45dcf4e92f1ffa1ac.tar.gz
rust-2159bbf6506c04e06b73f0e45dcf4e92f1ffa1ac.zip
Rollup merge of #23925 - steveklabnik:gh22914, r=Gankro
Fixes #22914

Said issue was mostly fixed, as there wasn't any examples when it was initially posted. This is mostly just some re-wording of some things and some cleanup
Diffstat (limited to 'src')
-rw-r--r--src/libcore/marker.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
index 97bde9fc96e..d1d9c389942 100644
--- a/src/libcore/marker.rs
+++ b/src/libcore/marker.rs
@@ -347,17 +347,16 @@ impl<T:?Sized> MarkerTrait for T { }
 #[stable(feature = "rust1", since = "1.0.0")]
 pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
 
-/// `PhantomData` is a way to tell the compiler about fake fields.
-/// Phantom data is required whenever type parameters are not used.
-/// The idea is that if the compiler encounters a `PhantomData<T>`
-/// instance, it will behave *as if* an instance of the type `T` were
-/// present for the purpose of various automatic analyses.
+/// `PhantomData<T>` allows you to describe that a type acts as if it stores a value of type `T`,
+/// even though it does not. This allows you to inform the compiler about certain safety properties
+/// of your code.
+///
+/// Though they both have scary names, `PhantomData<T>` and "phantom types" are unrelated. 👻👻👻
 ///
 /// # Examples
 ///
 /// When handling external resources over a foreign function interface, `PhantomData<T>` can
-/// prevent mismatches by enforcing types in the method implementations, although the struct
-/// doesn't actually contain values of the resource type.
+/// prevent mismatches by enforcing types in the method implementations:
 ///
 /// ```
 /// # trait ResType { fn foo(&self); };
@@ -398,11 +397,6 @@ pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
 /// commonly necessary if the structure is using an unsafe pointer
 /// like `*mut T` whose referent may be dropped when the type is
 /// dropped, as a `*mut T` is otherwise not treated as owned.
-///
-/// FIXME. Better documentation and examples of common patterns needed
-/// here! For now, please see [RFC 738][738] for more information.
-///
-/// [738]: https://github.com/rust-lang/rfcs/blob/master/text/0738-variance.md
 #[lang="phantom_data"]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct PhantomData<T:?Sized>;