Chapter Send and synchronize in Description Rustonomicon what it means for Send or Sync . It mentions that:
- Raw pointers are neither sending nor syncing (because they do not have guards).
But that just asks a question; why *const T does not implement Sync ? Why are fuses important?
Just before that, he says:
Send and synchronize automatically derived features as well. This means that, unlike any other characteristic, if the type is completely composed of send or synchronization types, then it is Send or Sync. Almost all primitives are “Send and Sync”, and, as a result, almost all types you ever interact with are “Send and Sync”.
This is the main reason raw pointers are not Send and Sync . If you define a structure that encapsulates a raw pointer, but only expose it as &T or &mut T in the struct API, are you really sure that your structure respects the Send and Sync contracts? If the source pointers were Send , then Rc<T> also be Send by default, so it would have to explicitly refuse. (There is actually an explicit rejection of Rc<T> in the source code, but it is intended for documentation purposes only because it is actually redundant.)
[...] they are unsafe features . This means that they are unsafe to implement, and other unsafe code may suggest that they are correctly implemented.
OK, let's remember: they are unsafe for implementation, but they are automatically output. Isn't that a weird combination? In fact, this is not as bad as it seems. The most primitive types, such as u32 , are Send and Sync . Just reconciling primitive values in a structure or enumeration is not enough to disqualify a type for Send or Sync . Therefore, you need to create a structure or enumeration with no Send or no Sync before you need to write unsafe impl .
Send and Sync are marker features, which means they have no methods. Therefore, when a function or type places a Send or Sync binding in a type parameter, it relies on the type to comply with a specific contract throughout its API. Because of this:
An incorrect implementation of Send or Sync can cause Undefined behavior.