-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace std::io::lazy::Lazy with a copy of lazy-static's similar, but Once-using, type. #53646
Comments
There was also some discussion on IRL to move lazy-static into libstd and claims that it is not necessary with |
yes |
// If we successfully register an at exit handler, then we cache the
// `Arc` allocation in our own internal box (it will get deallocated by
// the at exit handler). Otherwise we just return the freshly allocated
// `Arc`.
let registered = sys_common::at_exit(move || {
let ptr = {
let _guard = self.lock.lock();
self.ptr.replace(done())
};
drop(Box::from_raw(ptr))
}); Maybe that's why it can't just use |
We stabilized LazyLock and LazyCell. I think we're done here. |
This issue wasn't about stabilizing anything, it was entirely about std internals... turns out this was fixed 4 years ago on bab15f7. |
Yes, "we stabilized these" was, in this case, short for "we have refactored almost every single instance of Lazy-whatever in the standard library." |
It's not clear why
std::io::lazy
doesn't useOnce
, as that was available at the time when it was introduced.#53108 marked
Lazy::new
asunsafe
because of the lack of reentrance safety in the mutex being used, butOnce
specifically doesn't have reentrancy issues.lazy_static
version: https://github.com/rust-lang-nursery/lazy-static.rs/blob/13159c2b615903d93b4cd4f98d17fdfe70392a3a/src/inline_lazy.rsHowever, we need to change it per rust-lang-nursery/lazy-static.rs#117, otherwise it's unsound.
cc @RalfJung @alexcrichton
The text was updated successfully, but these errors were encountered: