@@ -85,7 +85,9 @@ immutable [`static` items].
8585The [ ` Send ` ] , [ ` Sync ` ] , [ ` UnwindSafe ` ] and [ ` RefUnwindSafe ` ] traits are _ auto
8686traits_ . Auto traits have special properties.
8787
88- First, auto traits are automatically implemented using the following rules:
88+ If no explicit implementation or negative implementation is written out for an
89+ auto trait for a given type, then the compiler implements it automatically
90+ according to the following rules:
8991
9092* ` &T ` , ` &mut T ` , ` *const T ` , ` *mut T ` , ` [T; n] ` and ` [T] ` implement the trait
9193 if ` T ` does.
@@ -96,12 +98,23 @@ First, auto traits are automatically implemented using the following rules:
9698 closure that captures a ` T ` by shared reference and a ` U ` by value implements
9799 any auto traits that both ` &T ` and ` U ` do.
98100
101+ For generic types (counting the built-in types above as generic over ` T ` ), if an
102+ generic implementation is available, then the compiler does not automatically
103+ implement it for types that could use the implementation except that they do not
104+ meet the requisite trait bounds. For instance, the standard library implements
105+ ` Send ` for all ` &T ` where ` T ` is ` Sync ` ; this means that the compiler will not
106+ implement ` Send ` for ` &T ` if ` T ` is ` Send ` but not ` Sync ` .
107+
99108Auto traits can also have negative implementations, shown as `impl !AutoTrait
100109for T` in the standard library documentation, that override the automatic
101110implementations. For example ` *mut T ` has a negative implementation of ` Send ` ,
102- and so ` *mut T ` and ` (*mut T,) ` are not ` Send ` . Finally, auto traits may
103- be added as a bound to any [ trait object] \: ` Box<Debug + Send + UnwindSafe> ` is
104- a valid type.
111+ and so ` *mut T ` is not ` Send ` , even if ` T ` is. There is currently no stable way
112+ to specify additional negative implementations; they exist only in the standard
113+ library.
114+
115+ Auto traits may be added as an additional bound to any [ trait object] , even
116+ though normally only one trait is allowed. For instance, `Box<dyn Debug + Send +
117+ UnwindSafe>` is a valid type.
105118
106119## ` Sized `
107120
0 commit comments