@@ -94,27 +94,6 @@ pub unsafe trait AllocRef {
94
94
/// The returned block may have a larger size than specified by `layout.size()`, and may or may
95
95
/// not have its contents initialized.
96
96
///
97
- /// Note that you may not rely on this method actually getting called, even if there are calls
98
- /// to it in the source. The optimizer may detect unused allocations that it can either
99
- /// eliminate entirely or move to the stack and thus never invoke the allocator. The
100
- /// optimizer may further assume that allocation is infallible, so code that used to fail due
101
- /// to allocator failures may now suddenly work because the optimizer worked around the
102
- /// need for an allocation. More concretely, the following code example is unsound, irrespective
103
- /// of whether your custom allocator allows counting how many allocations have happened.
104
- ///
105
- /// ```rust,ignore (unsound and has placeholders)
106
- /// Global::dealloc(Global::alloc(some_layout));
107
- /// let number_of_heap_allocs = /* call private allocator API */;
108
- /// unsafe { std::intrinsics::assume(number_of_heap_allocs > 0); }
109
- /// ```
110
- ///
111
- /// Note that the optimizations mentioned above are not the only
112
- /// optimization that can be applied. You may generally not rely on heap allocations
113
- /// happening if they can be removed without changing program behavior.
114
- /// Whether allocations happen or not is not part of the program behavior, even if it
115
- /// could be detected via an allocator that tracks allocations by printing or otherwise
116
- /// having side effects.
117
- ///
118
97
/// # Errors
119
98
///
120
99
/// Returning `Err` indicates that either memory is exhausted or `layout` does not meet
0 commit comments