Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4384465

Browse files
GnomedDevNoratrieb
andcommitted
Add additional safety documentation
Co-authored-by: Nilstrieb <[email protected]>
1 parent 08da79b commit 4384465

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/std/src/thread/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,10 @@ impl Inner {
13181318
fn parker(&self) -> Pin<&Parker> {
13191319
match self {
13201320
Self::Main => {
1321-
// Safety: MAIN_PARKER only ever has a mutable reference when Inner::Main is initialised.
1321+
// Safety: MAIN_PARKER is only ever read in this function, which requires access
1322+
// to an existing `&Inner` value, which can only be accessed via the main thread
1323+
// giving away such an instance from `current()`, implying that initialization,
1324+
// the only write to `MAIN_PARKER`, has been completed.
13221325
let static_ref: &'static MaybeUninit<Parker> = unsafe { &*MAIN_PARKER.get() };
13231326

13241327
// Safety: MAIN_PARKER is initialised when Inner::Main is initialised.

0 commit comments

Comments
 (0)