We have been using this code for a while, but it recently occurred to me that it may be unsound. We have a singleton self-referential struct T and an init function that returns &'static mut T which points to the newly created static variable. I understand that normally Pin is required for self-referential structs, but there will only ever be one instance of this struct at that location. I dont see how mem::replace or mem::swap could move T because both of those require another T to exist, which we guarantee that we don't have. Is there another way that T could be moved through &'static mut T when that is guaranteed to be the only instance of struct T, or is it certain that T will not be moved?
According to at least some team members (Ralf, and Niko I believe), moving out of a &'static mut _ is allowed (so long as you don't use the deinitialized place).
My understanding of the consensus is that moving out is not prohibited, so long as you reinitialize it by the time the borrow is over. That's the concept behind replace_with, which is generally held to be sound.