File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
library/std/src/sys/thread_local Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,15 @@ mod lazy {
91
91
}
92
92
}
93
93
94
- /// The other methods hand out references while taking &self.
95
- /// As such, callers of this method must ensure no `&` and `&mut` are
96
- /// available and used at the same time.
94
+ /// Watch out: unsynchronized internal mutability!
95
+ ///
96
+ /// # Safety
97
+ /// Unsound if called while any `&'static T` is active.
97
98
#[ allow( unused) ]
98
- pub unsafe fn take ( & mut self ) -> Option < T > {
99
- // SAFETY: See doc comment for this method.
100
- unsafe { ( * self . inner . get ( ) ) . take ( ) }
99
+ pub ( crate ) unsafe fn take ( & self ) -> Option < T > {
100
+ let mutable: * mut _ = UnsafeCell :: get ( & self . inner ) ;
101
+ // SAFETY: That's the caller's problem.
102
+ unsafe { mutable. replace ( None ) }
101
103
}
102
104
}
103
105
}
You can’t perform that action at this time.
0 commit comments