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

Commit 2e56bc2

Browse files
committed
Reword new_main safety comment
1 parent 2769dd6 commit 2e56bc2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/std/src/thread/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,8 +1371,10 @@ impl Thread {
13711371
///
13721372
/// This must only ever be called once, and must be called on the main thread.
13731373
pub(crate) unsafe fn new_main() -> Thread {
1374-
// Safety: Caller responsible for holding the mutable invariant and
1375-
// Parker::new_in_place does not read from the uninit value.
1374+
// Safety: As this is only called once and on the main thread, nothing else is accessing MAIN_PARKER
1375+
// as the only other read occurs after Inner::Main has been constructed, after this call finishes.
1376+
//
1377+
// Pre-main thread spawning cannot hit this either, as the caller holds that this is only called on the main thread.
13761378
unsafe { Parker::new_in_place(MAIN_PARKER.get().cast()) }
13771379

13781380
Self(Inner::Main)

0 commit comments

Comments
 (0)