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 @@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9
- refs/heads/incoming: 29a2a1ecd1fe33260a9390dd05899daf6a2ba69b
9
+ refs/heads/incoming: 3b299e8140326fbb3eee0e6274110c0b00019c26
10
10
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
11
11
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
12
12
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
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