-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
Lines 10 to 12 in e42cd8c
| pub struct CopyCell<T> { | |
| /// Internal value | |
| value: T, |
Lines 61 to 68 in e42cd8c
| pub fn set(&self, value: T) { | |
| use std::ptr::write_volatile; | |
| // Regular write produces abnormal behavior when running tests in | |
| // `--release` mode. Reordering writes when the compiler assumes | |
| // things are immutable is dangerous. | |
| unsafe { write_volatile(self.mut_ptr(), value) }; | |
| } |
This is writing through &T without std::cell::UnsafeCell being involved at all. Unfortunately UnsafeCell is currently not Copy, so as far as I understand CopyCell cannot be made sound until something like rust-lang/rust#55207 is implemented.