File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
14
14
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
15
15
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
16
16
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17
- refs/heads/auto: d74ac9ea03eb8faab72ce48b89dd47a14f45982a
17
+ refs/heads/auto: 8f2d71ac009e1f93c14266ecebb1c105a0a907e3
18
18
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
19
19
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
Original file line number Diff line number Diff line change @@ -150,11 +150,7 @@ wrapping `malloc` and `free`:
150
150
151
151
~~~~
152
152
use core::libc::{c_void, size_t, malloc, free};
153
-
154
- #[abi = "rust-intrinsic"]
155
- extern "rust-intrinsic" mod rusti {
156
- fn init<T>() -> T;
157
- }
153
+ use core::unstable::intrinsics;
158
154
159
155
// a wrapper around the handle returned by the foreign code
160
156
pub struct Unique<T> {
@@ -166,7 +162,8 @@ pub impl<'self, T: Owned> Unique<T> {
166
162
unsafe {
167
163
let ptr = malloc(core::sys::size_of::<T>() as size_t) as *mut T;
168
164
assert!(!ptr::is_null(ptr));
169
- *ptr = value;
165
+ // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
166
+ intrinsics::move_val_init(&mut *ptr, value);
170
167
Unique{ptr: ptr}
171
168
}
172
169
}
@@ -186,7 +183,7 @@ pub impl<'self, T: Owned> Unique<T> {
186
183
impl<T: Owned> Drop for Unique<T> {
187
184
fn finalize(&self) {
188
185
unsafe {
189
- let mut x = rusti ::init(); // dummy value to swap in
186
+ let mut x = intrinsics ::init(); // dummy value to swap in
190
187
x <-> *self.ptr; // moving the object out is needed to call the destructor
191
188
free(self.ptr as *c_void)
192
189
}
You can’t perform that action at this time.
0 commit comments