Files
rust/library/alloc
Jacob Pratt c604cd98b2 Rollup merge of #159720 - RalfJung:global-allocator-opsem-magic, r=aapoalas,nia-e,nikic
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?
2026-07-26 00:21:44 -04:00
..