Skip to content

Commit 173892c

Browse files
committed
Note that there are other optimizations than the one showcased
1 parent a2f938a commit 173892c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

library/core/src/alloc/global.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ use crate::ptr;
6666
/// let number_of_heap_allocs = /* call private allocator API */;
6767
/// unsafe { std::intrinsics::assume(number_of_heap_allocs > 0); }
6868
/// ```
69+
///
70+
/// Note that allocation/deallocation pairs being moved to the stack is not the only
71+
/// optimization that can be applied. You may generally not rely on heap allocations
72+
/// happening, if they can be removed without changing program behaviour.
73+
/// Whether allocations happen or not is not part of the program behaviour, even if it
74+
/// could be detected via an allocator that tracks allocations.
6975
#[stable(feature = "global_alloc", since = "1.28.0")]
7076
pub unsafe trait GlobalAlloc {
7177
/// Allocate memory as described by the given `layout`.

0 commit comments

Comments
 (0)