-
Notifications
You must be signed in to change notification settings - Fork 13.5k
wasm: rm static mut #142727
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
base: master
Are you sure you want to change the base?
wasm: rm static mut #142727
Conversation
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use |
|
||
use crate::alloc::{GlobalAlloc, Layout, System}; | ||
|
||
static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new(); | ||
struct SyncDlmalloc(dlmalloc::Dlmalloc); | ||
unsafe impl Sync for SyncDlmalloc {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only safe if we're in WASM without threads, is this file already gated for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same file also contains a Lock impl for the case there are threads, which is used to guard the Allocator impl against unsynchronized accesses.
Is this motivated by the oldish issue to deprecate Fyi you should be able to sanity check the behavior with Cc @RalfJung since you could explain some of this much better than me. |
It's up to t-libs what they find more clear here. The alternative would be to leave the |
It's motivated by #125035, but I admit that I was under the impression that we should get rid of all uses of "static mut", but I see #53639 was closed as not planned. So should we just try and remove most uses of "static mut" that can easily be replaced by something other than SyncUnsafeCell, or something along those lines? |
More #125035. I'm not sure this is correct, but it compiles.