-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
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? |
Given the discussion above, this feels like it needs a t-libs decision? I'll nominate it @rustbot label +I-libs-nominated |
This was discussed in the @rust-lang/libs meeting but there were no strong feeling towards either keeping |
@bors r+ rollup |
Rollup of 9 pull requests Successful merges: - #142727 (wasm: rm static mut) - #143193 (Port `#[link]` to the new attribute parsing infrastructure ) - #144864 (No source fixes) - #145913 (Add spin_loop hint for LoongArch) - #145926 (compiletest: Remove several remnants of the old libtest-based executor) - #145928 (Rename `Location::file_with_nul` to `file_as_c_str`) - #145930 (`const`ify (the unstable) `str::as_str`) - #145941 (Disable `integer_to_ptr_transmutes` suggestion for unsized types) - #145953 (Update `icu_list` to 2.0) r? `@ghost` `@rustbot` modify labels: rollup
More #125035. I'm not sure this is correct, but it compiles.