Skip to content
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

Fixed of compilation on latest nightly locally, but still issue on playg… #71

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 8 additions & 8 deletions src/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For instance, a custom implementation of `Box` might write `Drop` like this:
```rust
#![feature(ptr_internals, allocator_api, unique)]

use std::alloc::{Global, GlobalAlloc, Layout};
use std::alloc::{System, GlobalAlloc, Layout};
use std::mem;
use std::ptr::{drop_in_place, Unique};

Expand All @@ -38,7 +38,7 @@ impl<T> Drop for Box<T> {
fn drop(&mut self) {
unsafe {
drop_in_place(self.ptr.as_ptr());
Global.dealloc(self.ptr.as_ptr() as *mut _, Layout::new::<T>())
System.dealloc(self.ptr.as_ptr() as *mut _, Layout::new::<T>())
}
}
}
Expand All @@ -54,7 +54,7 @@ However this wouldn't work:
```rust
#![feature(allocator_api, ptr_internals, unique)]

use std::alloc::{Global, GlobalAlloc, Layout};
use std::alloc::{System, GlobalAlloc, Layout};
use std::ptr::{drop_in_place, Unique};
use std::mem;

Expand All @@ -64,7 +64,7 @@ impl<T> Drop for Box<T> {
fn drop(&mut self) {
unsafe {
drop_in_place(self.ptr.as_ptr());
Global.dealloc(self.ptr.as_ptr() as *mut _, Layout::new::<T>());
System.dealloc(self.ptr.as_ptr() as *mut _, Layout::new::<T>());
}
}
}
Expand All @@ -76,7 +76,7 @@ impl<T> Drop for SuperBox<T> {
unsafe {
// Hyper-optimized: deallocate the box's contents for it
// without `drop`ing the contents
Global.dealloc(self.my_box.ptr.as_ptr() as *mut _, Layout::new::<T>());
System.dealloc(self.my_box.ptr.as_ptr() as *mut _, Layout::new::<T>());
}
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ of Self during `drop` is to use an Option:
```rust
#![feature(allocator_api, ptr_internals, unique)]

use std::alloc::{GlobalAlloc, Global, Layout};
use std::alloc::{GlobalAlloc, System, Layout};
use std::ptr::{drop_in_place, Unique};
use std::mem;

Expand All @@ -135,7 +135,7 @@ impl<T> Drop for Box<T> {
fn drop(&mut self) {
unsafe {
drop_in_place(self.ptr.as_ptr());
Global.dealloc(self.ptr.as_ptr() as *mut _, Layout::new::<T>());
System.dealloc(self.ptr.as_ptr() as *mut _, Layout::new::<T>());
}
}
}
Expand All @@ -149,7 +149,7 @@ impl<T> Drop for SuperBox<T> {
// without `drop`ing the contents. Need to set the `box`
// field as `None` to prevent Rust from trying to Drop it.
let my_box = self.my_box.take().unwrap();
Global.dealloc(my_box.ptr.as_ptr() as *mut _, Layout::new::<T>());
System.dealloc(my_box.ptr.as_ptr() as *mut _, Layout::new::<T>());
mem::forget(my_box);
}
}
Expand Down
Loading