1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// `#![no_std]`: these arrive with the standard prelude and name no path, so a `std::`
// search cannot see them - and a `#[derive]` can use them without the name appearing
// in this file at all, which is why they are not trimmed by inspection.
use ToOwned;
use Box;
use format;
use ;
use vec;
use Vec;
// `DynSend` and `DynSync` were `unsafe auto trait`s with a table of negative impls (raw
// pointers, `Rc`, cells) and hand-written positive impls (atomics, locks, arenas,
// collections). Upstream they gate what the parallel frontend may share between threads
// once `sync::is_dyn_thread_safe()` is true.
//
// Auto traits and negative impls are unstable, and this crate runs a compile on the
// caller's thread (no threads, no pool), so there is nothing for them to gate. They are
// now ordinary unsafe marker traits implemented for every type, which keeps every
// `T: DynSend` bound and `impl Fn() + DynSync` argument compiling unchanged. Two things
// could not be kept: an ordinary trait cannot be added to a trait object, so the former
// `dyn Trait + DynSend + DynSync` types are now `dyn Trait`; and the per-type impls
// elsewhere in the tree (`TyCtxt`, `Lock`, `RawList`, ...) were deleted, since they would
// conflict with the blanket impl. `FromDyn` in `sync.rs` no longer trusts these traits.
//
// If a thread pool ever comes back, this is the file to revisit: a universal `DynSend`
// states nothing, and the checks it used to perform would need a real mechanism again.
/// A type that could be sent across threads when `sync::is_dyn_thread_safe()` is true.
/// Implemented for every type; see the note at the top of this file.
pub unsafe
/// A type that could be shared across threads when `sync::is_dyn_thread_safe()` is true.
/// Implemented for every type; see the note at the top of this file.
pub unsafe
// SAFETY: no code in this crate moves or shares a value across threads, so these markers
// promise nothing that can be broken. See the note at the top of this file.
unsafe
unsafe
Sized + DynSync>
Sized + DynSend>
Sized + DynSend>
Sized + DynSync + DynSend>
// A wrapper to convert a struct that is already a `Send` or `Sync` into
// an instance of `DynSend` and `DynSync`, since the compiler cannot infer
// it automatically in some cases. (e.g. Box<dyn Send / Sync>)
// With the blanket impls above the wrapper adds nothing, but it is kept so its callers
// and its `Deref` stay unchanged.
;