Skip to content

Use Box::into_raw rather than the deprecated boxed::into_raw in tests and documentation. #26605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<T : ?Sized> Box<T> {
/// of `T` and releases memory. Since the way `Box` allocates and
/// releases memory is unspecified, the only valid pointer to pass
/// to this function is the one taken from another `Box` with
/// `boxed::into_raw` function.
/// `Box::into_raw` function.
///
/// Function is unsafe, because improper use of this function may
/// lead to memory problems like double-free, for example if the
Expand All @@ -140,10 +140,8 @@ impl<T : ?Sized> Box<T> {
/// # Examples
/// ```
/// # #![feature(box_raw)]
/// use std::boxed;
///
/// let seventeen = Box::new(17u32);
/// let raw = boxed::into_raw(seventeen);
/// let raw = Box::into_raw(seventeen);
/// let boxed_again = unsafe { Box::from_raw(raw) };
/// ```
#[unstable(feature = "box_raw", reason = "may be renamed")]
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/boxed_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ fn deref() {

#[test]
fn raw_sized() {
let x = Box::new(17);
let p = Box::into_raw(x);
unsafe {
let x = Box::new(17);
let p = boxed::into_raw(x);
assert_eq!(17, *p);
*p = 19;
let y = Box::from_raw(p);
Expand All @@ -105,9 +105,9 @@ fn raw_trait() {
}
}

let x: Box<Foo> = Box::new(Bar(17));
let p = Box::into_raw(x);
unsafe {
let x: Box<Foo> = Box::new(Bar(17));
let p = boxed::into_raw(x);
assert_eq!(17, (*p).get());
(*p).set(19);
let y: Box<Foo> = Box::from_raw(p);
Expand Down
10 changes: 4 additions & 6 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@
//!
//! ```
//! # #![feature(box_raw)]
//! use std::boxed;
//! let my_speed: Box<i32> = Box::new(88);
//! let my_speed: *mut i32 = Box::into_raw(my_speed);
//!
//! // By taking ownership of the original `Box<T>` though
//! // we are obligated to put it together later to be destroyed.
//! unsafe {
//! let my_speed: Box<i32> = Box::new(88);
//! let my_speed: *mut i32 = boxed::into_raw(my_speed);
//!
//! // By taking ownership of the original `Box<T>` though
//! // we are obligated to put it together later to be destroyed.
//! drop(Box::from_raw(my_speed));
//! }
//! ```
Expand Down