diff options
| author | bors <bors@rust-lang.org> | 2020-03-03 10:18:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-03-03 10:18:57 +0000 |
| commit | a5de254862477924bcd8b9e1bff7eadd6ffb5e2a (patch) | |
| tree | 6d30e786044c654a5478545b69a9f8792e856655 /src/libstd/alloc.rs | |
| parent | 9381e8178b49636d4604e4ec0f1263960691c958 (diff) | |
| parent | e453a0cc49ad83fbb54fb22f9bba7545f5a92c68 (diff) | |
| download | rust-a5de254862477924bcd8b9e1bff7eadd6ffb5e2a.tar.gz rust-a5de254862477924bcd8b9e1bff7eadd6ffb5e2a.zip | |
Auto merge of #69666 - JohnTitor:rollup-6nt3op0, r=JohnTitor
Rollup of 9 pull requests Successful merges: - #69213 (Improve documentation on iterators length) - #69609 (Remove `usable_size` APIs) - #69619 (more cleanups) - #69620 (doc(librustc_error_codes): add long error explanation for E0719) - #69626 (Toolstate: don't duplicate nightly tool list.) - #69628 (Fix a leak in `DiagnosticBuilder::into_diagnostic`.) - #69633 (Update my mailmap entry) - #69634 (clean up E0378 explanation) - #69637 (Don't convert Results to Options just for matching.) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd/alloc.rs')
| -rw-r--r-- | src/libstd/alloc.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index 8965c6860c4..2da18e06d99 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -137,13 +137,15 @@ pub struct System; #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl AllocRef for System { #[inline] - unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> { - NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr) + unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> { + NonNull::new(GlobalAlloc::alloc(self, layout)).ok_or(AllocErr).map(|p| (p, layout.size())) } #[inline] - unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> { - NonNull::new(GlobalAlloc::alloc_zeroed(self, layout)).ok_or(AllocErr) + unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> { + NonNull::new(GlobalAlloc::alloc_zeroed(self, layout)) + .ok_or(AllocErr) + .map(|p| (p, layout.size())) } #[inline] @@ -157,8 +159,10 @@ unsafe impl AllocRef for System { ptr: NonNull<u8>, layout: Layout, new_size: usize, - ) -> Result<NonNull<u8>, AllocErr> { - NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)).ok_or(AllocErr) + ) -> Result<(NonNull<u8>, usize), AllocErr> { + NonNull::new(GlobalAlloc::realloc(self, ptr.as_ptr(), layout, new_size)) + .ok_or(AllocErr) + .map(|p| (p, new_size)) } } |
