diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index fc996b36779..1c400cbdfcb 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1149,7 +1149,7 @@ extern "rust-intrinsic" { /// Creating an invalid value: /// /// ```no_run - /// use std::{mem, ptr}; + /// use std::ptr; /// /// let mut v = Box::new(0i32); /// diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 3faadca3f39..eaff3093767 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -396,7 +396,7 @@ pub unsafe fn replace(dest: *mut T, mut src: T) -> T { /// ``` /// use std::ptr; /// -/// let mut s = String::new("foo"); +/// let mut s = String::from("foo"); /// unsafe { /// // `s2` now points to the same underlying memory as `s1`. /// let mut s2 = ptr::read(&s); @@ -410,10 +410,10 @@ pub unsafe fn replace(dest: *mut T, mut src: T) -> T { /// /// // Assigning to `s` would cause the old value to be dropped again, /// // resulting in undefined behavior. -/// // s = String::new("bar"); // ERROR +/// // s = String::from("bar"); // ERROR /// /// // `ptr::write` can be used to overwrite a value without dropping it. -/// ptr::write(&s, String::new("bar")); +/// ptr::write(&mut s, String::from("bar")); /// } /// /// assert_eq!(s, "bar");