@@ -28,7 +28,7 @@ For instance, a custom implementation of `Box` might write `Drop` like this:
28
28
``` rust
29
29
#![feature(ptr_internals, allocator_api, unique)]
30
30
31
- use std :: alloc :: {Global , GlobalAlloc , Layout , Opaque };
31
+ use std :: alloc :: {Global , GlobalAlloc , Layout };
32
32
use std :: mem;
33
33
use std :: ptr :: {drop_in_place, Unique };
34
34
@@ -38,7 +38,7 @@ impl<T> Drop for Box<T> {
38
38
fn drop (& mut self ) {
39
39
unsafe {
40
40
drop_in_place (self . ptr. as_ptr ());
41
- Global . dealloc (self . ptr. as_ptr () as * mut Opaque , Layout :: new :: <T >())
41
+ Global . dealloc (self . ptr. as_ptr () as * mut _ , Layout :: new :: <T >())
42
42
}
43
43
}
44
44
}
@@ -54,7 +54,7 @@ However this wouldn't work:
54
54
``` rust
55
55
#![feature(allocator_api, ptr_internals, unique)]
56
56
57
- use std :: alloc :: {Global , GlobalAlloc , Layout , Opaque };
57
+ use std :: alloc :: {Global , GlobalAlloc , Layout };
58
58
use std :: ptr :: {drop_in_place, Unique };
59
59
use std :: mem;
60
60
@@ -64,7 +64,7 @@ impl<T> Drop for Box<T> {
64
64
fn drop (& mut self ) {
65
65
unsafe {
66
66
drop_in_place (self . ptr. as_ptr ());
67
- Global . dealloc (self . ptr. as_ptr () as * mut Opaque , Layout :: new :: <T >());
67
+ Global . dealloc (self . ptr. as_ptr () as * mut _ , Layout :: new :: <T >());
68
68
}
69
69
}
70
70
}
@@ -76,7 +76,7 @@ impl<T> Drop for SuperBox<T> {
76
76
unsafe {
77
77
// Hyper-optimized: deallocate the box's contents for it
78
78
// without `drop`ing the contents
79
- Global . dealloc (self . my_box. ptr. as_ptr () as * mut Opaque , Layout :: new :: <T >());
79
+ Global . dealloc (self . my_box. ptr. as_ptr () as * mut _ , Layout :: new :: <T >());
80
80
}
81
81
}
82
82
}
@@ -125,7 +125,7 @@ of Self during `drop` is to use an Option:
125
125
``` rust
126
126
#![feature(allocator_api, ptr_internals, unique)]
127
127
128
- use std :: alloc :: {GlobalAlloc , Global , Layout , Opaque };
128
+ use std :: alloc :: {GlobalAlloc , Global , Layout };
129
129
use std :: ptr :: {drop_in_place, Unique };
130
130
use std :: mem;
131
131
@@ -135,7 +135,7 @@ impl<T> Drop for Box<T> {
135
135
fn drop (& mut self ) {
136
136
unsafe {
137
137
drop_in_place (self . ptr. as_ptr ());
138
- Global . dealloc (self . ptr. as_ptr () as * mut Opaque , Layout :: new :: <T >());
138
+ Global . dealloc (self . ptr. as_ptr () as * mut _ , Layout :: new :: <T >());
139
139
}
140
140
}
141
141
}
@@ -149,7 +149,7 @@ impl<T> Drop for SuperBox<T> {
149
149
// without `drop`ing the contents. Need to set the `box`
150
150
// field as `None` to prevent Rust from trying to Drop it.
151
151
let my_box = self . my_box. take (). unwrap ();
152
- Global . dealloc (my_box . ptr. as_ptr () as * mut Opaque , Layout :: new :: <T >());
152
+ Global . dealloc (my_box . ptr. as_ptr () as * mut _ , Layout :: new :: <T >());
153
153
mem :: forget (my_box );
154
154
}
155
155
}
0 commit comments