Skip to content

Commit

Permalink
Auto merge of rust-lang#84053 - RalfJung:liballoc-miri, r=Manishearth
Browse files Browse the repository at this point in the history
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 rust-lang#80310 so r? `@Manishearth` `@kennytm`
  • Loading branch information
bors committed Apr 11, 2021
2 parents 25ea6be + 63b682b commit ef38b45
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ef38b45

Please sign in to comment.