@@ -67,18 +67,26 @@ fine: inlining that reference everywhere has the same behavior as computing a
6767new reference each time. In both cases, there exists exactly one instance of
6868the mutable memory that everything references.
6969
70- ### 3. ` Sync `
70+ ### 3. ` Send `
7171
72- Finally, the same constant reference is actually shared across threads. This is
73- very similar to multiple threads having a shared reference to the same ` static ` ,
74- which is why ` static ` must be ` Sync ` . So it seems like we should reject
75- non-` Sync ` types, conforming with the desugaring described above.
72+ Finally, the same constant value is actually shared across threads. This is
73+ very similar to sending the same value across threads, so it seems like we
74+ should reject non-` Send ` types. For shared references, this means the pointee
75+ type ought to be ` Sync ` . That is already required for ` static ` items, so this
76+ is consistent with the desugaring described above.
7677
7778However, this does not currently happen, and there are several crates across the
7879ecosystem that would break if we just started enforcing this now. See
7980[ this issue] ( https://github.com/rust-lang/rust/issues/49206 ) and the
8081[ PR attempting to fix this] ( https://github.com/rust-lang/rust/pull/54424/ ) .
8182
83+ Also, one could make the argument that the value does not have to be ` Send `
84+ because it is not actually sent to other threads; instead, conceptually, each
85+ thread re-does the same computation. But we know they will all come to the same
86+ result. This works, except when we consider address identity: with references
87+ in the ` const ` , all threads will get the same address, unlike in case of a
88+ per-thread recomputation which would lead to different addresses.
89+
8290* Dynamic check.* It is unclear how the Miri engine could dynamically check this.
8391
8492### 4. Drop
0 commit comments