@@ -117,7 +117,7 @@ pub unsafe trait AllocRef {
117117 /// [`handle_alloc_error`]: ../../alloc/alloc/fn.handle_alloc_error.html
118118 fn alloc ( & mut self , layout : Layout ) -> Result < MemoryBlock , AllocErr > ;
119119
120- /// Behaves like `alloc`, but also ensures that the contents are set to zero before being returned .
120+ /// Behaves like `alloc`, but also ensures that the returned memory is zero-initialized .
121121 ///
122122 /// # Errors
123123 ///
@@ -156,20 +156,19 @@ pub unsafe trait AllocRef {
156156 /// memory. The pointer is suitable for holding data described by a new layout with `layout`’s
157157 /// alignment and a size given by `new_size`. To accomplish this, the allocator may extend the
158158 /// allocation referenced by `ptr` to fit the new layout.
159- ///~
159+ ///
160160 /// If this method returns `Err`, then ownership of the memory block has not been transferred to
161161 /// this allocator, and the contents of the memory block are unaltered.
162162 ///
163163 /// # Safety
164164 ///
165165 /// * `ptr` must denote a block of memory [*currently allocated*] via this allocator,
166166 /// * `layout` must [*fit*] that block of memory (The `new_size` argument need not fit it.),
167- // We can't require that `new_size` is strictly greater than `memory.size` because of ZSTs.
168- // An alternative would be
169- // * `new_size must be strictly greater than `memory.size` or both are zero
170167 /// * `new_size` must be greater than or equal to `layout.size()`, and
171168 /// * `new_size`, when rounded up to the nearest multiple of `layout.align()`, must not overflow
172169 /// (i.e., the rounded value must be less than or equal to `usize::MAX`).
170+ // Note: We can't require that `new_size` is strictly greater than `layout.size()` because of ZSTs.
171+ // alternative: `new_size must be strictly greater than `layout.size()` or both are zero
173172 ///
174173 /// [*currently allocated*]: #currently-allocated-memory
175174 /// [*fit*]: #memory-fitting
@@ -283,7 +282,7 @@ pub unsafe trait AllocRef {
283282 // SAFETY: the caller must ensure that the `new_size` does not overflow.
284283 // `layout.align()` comes from a `Layout` and is thus guaranteed to be valid for a Layout.
285284 // The caller must ensure that `new_size` is greater than or equal to zero. If it's equal
286- // to zero, it's catched beforehand.
285+ // to zero, it's caught beforehand.
287286 unsafe { Layout :: from_size_align_unchecked ( new_size, layout. align ( ) ) } ;
288287 let new_memory = self . alloc_zeroed ( new_layout) ?;
289288
0 commit comments