Skip to content

TRPL: Document that Send and Sync are automatically derived #28581

Closed
@geofft

Description

@geofft

As far as I can tell, there is no documentation outside of the Rustonomicon that says that Send and Sync are automatically derived on datatypes that consist solely of Send and Sync members, and that all primitives other than raw pointers are Send + Sync.

So it is a natural worry for newcomers that the language is less thread-usable than it is (i.e., that libraries will forget to manually implement Send + Sync, and be pathologically safe by being unusable across threads), and it's hard to clarify that. (I only found this part of the 'nomicon through git grep; the obvious Google results for 'rust send and sync' didn't have a clear statement that they were automatically derived.)

This might be as easy as copying the two 'nomicon paragraphs starting with "Send and Sync are also automatically derived traits" into concurrency.md or so; there's no nontrivial discussion of unsafety in them. I could also send in a PR adding an example of using a Send + Sync struct, if that would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions