mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 17:44:28 +00:00
document #[global_allocator] constraints `#[global_allocator]` is opsem magic. For instance, even if we do ```rust use std::alloc::System; #[global_allocator] static ALLOC: System = System; ``` it is still UB to allocate via `std::alloc::alloc()` and deallocate via `System.dealloc()`. This is because we add special magic LLVM attributes in the `#[global_allocator]` machinery that tell LLVM about our global allocation methods so it can optimize accordingly, and mixing allocators is against those rules. Cc @rust-lang/opsem @rust-lang/lang @nia-e @maxdexh @nikic is this enough to ensure that adding your intrinsics is sound?