diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-04-03 00:32:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-03 00:32:03 +0200 |
| commit | e07f57c51ccc8b39dcde1ba9cd565be219e06580 (patch) | |
| tree | a66344d06d88b82d0f65544245895561d76c3f32 | |
| parent | 4cba69e5851d6b515afb970880f6fab0881b82f9 (diff) | |
| parent | 0b612399366e28b5314b5fd289f46c636d596a7b (diff) | |
| download | rust-e07f57c51ccc8b39dcde1ba9cd565be219e06580.tar.gz rust-e07f57c51ccc8b39dcde1ba9cd565be219e06580.zip | |
Rollup merge of #70691 - TimDiekmann:allocref-docs, r=RalfJung
Improve docs in `AllocRef` r? @RalfJung
| -rw-r--r-- | src/libcore/alloc/mod.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libcore/alloc/mod.rs b/src/libcore/alloc/mod.rs index e8c4b68c648..77ac93c7b79 100644 --- a/src/libcore/alloc/mod.rs +++ b/src/libcore/alloc/mod.rs @@ -33,9 +33,7 @@ impl fmt::Display for AllocErr { #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[unstable(feature = "allocator_api", issue = "32838")] pub enum AllocInit { - /// The contents of the new memory are undefined. - /// - /// Reading uninitialized memory is Undefined Behavior; it must be initialized before use. + /// The contents of the new memory are uninitialized. Uninitialized, /// The new memory is guaranteed to be zeroed. Zeroed, @@ -196,7 +194,11 @@ pub unsafe trait AllocRef { /// /// # Safety /// - /// `memory` must be a memory block returned by this allocator. + /// * `ptr` must be [*currently allocated*] via this allocator, and + /// * `layout` must [*fit*] the `ptr`. + /// + /// [*currently allocated*]: #currently-allocated-memory + /// [*fit*]: #memory-fitting unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout); /// Attempts to extend the memory block. @@ -237,7 +239,7 @@ pub unsafe trait AllocRef { // * `new_size must be strictly greater than `memory.size` or both are zero /// * `new_size` must be greater than or equal to `layout.size()` /// * `new_size`, when rounded up to the nearest multiple of `layout.align()`, must not overflow - /// (i.e., the rounded value must be less than `usize::MAX`). + /// (i.e., the rounded value must be less than or equal to `usize::MAX`). /// /// [*currently allocated*]: #currently-allocated-memory /// [*fit*]: #memory-fitting |
