about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-11 00:27:23 +0000
committerbors <bors@rust-lang.org>2021-04-11 00:27:23 +0000
commitef38b45e8b5fe9258173376565e718b071c96cd7 (patch)
treeb2d13e49cc1132a56ee28a1bcf6512e36dfe6ccb
parent25ea6be13e308e72687916cb7af785cd1c09801c (diff)
parent63b682b3ec0a985c38461e05372e0d7eefbea8f7 (diff)
downloadrust-ef38b45e8b5fe9258173376565e718b071c96cd7.tar.gz
rust-ef38b45e8b5fe9258173376565e718b071c96cd7.zip
Auto merge of #84053 - RalfJung:liballoc-miri, r=Manishearth
fix incorrect Box::from_raw_in doctest

Now that Miri can run doctests, I ran it on liballoc, and found exactly one problem: this test creates a `Box<u8>` to deallocate a 4-byte allocation!

Introduced by https://github.com/rust-lang/rust/pull/80310 so r? `@Manishearth` `@kennytm`
-rw-r--r--library/alloc/src/boxed.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs
index 04033905728..ef37fef0455 100644
--- a/library/alloc/src/boxed.rs
+++ b/library/alloc/src/boxed.rs
@@ -793,7 +793,7 @@ impl<T: ?Sized, A: Allocator> Box<T, A> {
     /// use std::alloc::{Allocator, Layout, System};
     ///
     /// unsafe {
-    ///     let ptr = System.allocate(Layout::new::<i32>())?.as_mut_ptr();
+    ///     let ptr = System.allocate(Layout::new::<i32>())?.as_mut_ptr() as *mut i32;
     ///     // In general .write is required to avoid attempting to destruct
     ///     // the (uninitialized) previous contents of `ptr`, though for this
     ///     // simple example `*ptr = 5` would have worked as well.