diff options
| author | oli <github35764891676564198441@oli-obk.de> | 2020-11-19 11:09:10 +0000 |
|---|---|---|
| committer | oli <github35764891676564198441@oli-obk.de> | 2020-11-19 11:09:10 +0000 |
| commit | 173892c7765365ca47f920771ee7f743e2c4dfaa (patch) | |
| tree | a2db6bfd75b21f2cd543e893c1c7ceea2c53794f | |
| parent | a2f938ac52d8d1b3ee1cf94f18705e95f28ca0b8 (diff) | |
| download | rust-173892c7765365ca47f920771ee7f743e2c4dfaa.tar.gz rust-173892c7765365ca47f920771ee7f743e2c4dfaa.zip | |
Note that there are other optimizations than the one showcased
| -rw-r--r-- | library/core/src/alloc/global.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/core/src/alloc/global.rs b/library/core/src/alloc/global.rs index 65406125a3d..e6fe1e89c10 100644 --- a/library/core/src/alloc/global.rs +++ b/library/core/src/alloc/global.rs @@ -66,6 +66,12 @@ use crate::ptr; /// let number_of_heap_allocs = /* call private allocator API */; /// unsafe { std::intrinsics::assume(number_of_heap_allocs > 0); } /// ``` +/// +/// Note that allocation/deallocation pairs being moved to the stack is not the only +/// optimization that can be applied. You may generally not rely on heap allocations +/// happening, if they can be removed without changing program behaviour. +/// Whether allocations happen or not is not part of the program behaviour, even if it +/// could be detected via an allocator that tracks allocations. #[stable(feature = "global_alloc", since = "1.28.0")] pub unsafe trait GlobalAlloc { /// Allocate memory as described by the given `layout`. |
