Skip to content

Commit 0c691df

Browse files
committed
auto merge of #13773 : brson/rust/boxxy, r=alexcrichton
`box` is the way you allocate in future-rust.
2 parents bca9647 + a5be12c commit 0c691df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+631
-624
lines changed

src/etc/emacs/rust-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
;; Font-locking definitions and helpers
170170
(defconst rust-mode-keywords
171171
'("as"
172-
"break"
172+
"box" "break"
173173
"continue" "crate"
174174
"do"
175175
"else" "enum" "extern"

src/libarena/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ mod tests {
517517
#[bench]
518518
pub fn bench_copy_nonarena(b: &mut Bencher) {
519519
b.iter(|| {
520-
~Point {
520+
box Point {
521521
x: 1,
522522
y: 2,
523523
z: 3,
@@ -569,7 +569,7 @@ mod tests {
569569
#[bench]
570570
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
571571
b.iter(|| {
572-
~Noncopy {
572+
box Noncopy {
573573
string: "hello world".to_owned(),
574574
array: vec!( 1, 2, 3, 4, 5 ),
575575
}

src/libcollections/btree.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ impl<K: Clone + TotalOrd, V: Clone> Leaf<K, V> {
377377
== Less);
378378
let branch_return = Node::new_branch(vec!(BranchElt::new(midpoint.key.clone(),
379379
midpoint.value.clone(),
380-
~Node::new_leaf(left_leaf))),
381-
~Node::new_leaf(right_leaf));
380+
box Node::new_leaf(left_leaf))),
381+
box Node::new_leaf(right_leaf));
382382
return (branch_return, true);
383383
}
384384
(Node::new_leaf(self.elts.clone()), true)
@@ -540,10 +540,10 @@ impl<K: Clone + TotalOrd, V: Clone> Branch<K, V> {
540540
//so we can return false.
541541
LeafNode(..) => {
542542
if index.unwrap() == self.elts.len() {
543-
self.rightmost_child = ~new_branch.clone();
543+
self.rightmost_child = box new_branch.clone();
544544
}
545545
else {
546-
self.elts.get_mut(index.unwrap()).left = ~new_branch.clone();
546+
self.elts.get_mut(index.unwrap()).left = box new_branch.clone();
547547
}
548548
return (Node::new_branch(self.clone().elts,
549549
self.clone().rightmost_child),
@@ -561,10 +561,10 @@ impl<K: Clone + TotalOrd, V: Clone> Branch<K, V> {
561561
//and return it, saying we have inserted a new element.
562562
LeafNode(..) => {
563563
if index.unwrap() == self.elts.len() {
564-
self.rightmost_child = ~new_branch;
564+
self.rightmost_child = box new_branch;
565565
}
566566
else {
567-
self.elts.get_mut(index.unwrap()).left = ~new_branch;
567+
self.elts.get_mut(index.unwrap()).left = box new_branch;
568568
}
569569
return (Node::new_branch(self.clone().elts,
570570
self.clone().rightmost_child),
@@ -604,9 +604,9 @@ impl<K: Clone + TotalOrd, V: Clone> Branch<K, V> {
604604
new_branch = Node::new_branch(
605605
vec!(BranchElt::new(midpoint.clone().key,
606606
midpoint.clone().value,
607-
~Node::new_branch(new_left,
607+
box Node::new_branch(new_left,
608608
midpoint.clone().left))),
609-
~Node::new_branch(new_right, self.clone().rightmost_child));
609+
box Node::new_branch(new_right, self.clone().rightmost_child));
610610
return (new_branch, true);
611611
}
612612
}

src/libcollections/dlist.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<T> Deque<T> for DList<T> {
238238
///
239239
/// O(1)
240240
fn push_front(&mut self, elt: T) {
241-
self.push_front_node(~Node::new(elt))
241+
self.push_front_node(box Node::new(elt))
242242
}
243243

244244
/// Remove the first element and return it, or None if the list is empty
@@ -252,7 +252,7 @@ impl<T> Deque<T> for DList<T> {
252252
///
253253
/// O(1)
254254
fn push_back(&mut self, elt: T) {
255-
self.push_back_node(~Node::new(elt))
255+
self.push_back_node(box Node::new(elt))
256256
}
257257

258258
/// Remove the last element and return it, or None if the list is empty
@@ -555,7 +555,7 @@ impl<'a, A> MutItems<'a, A> {
555555
impl<'a, A> ListInsertion<A> for MutItems<'a, A> {
556556
#[inline]
557557
fn insert_next(&mut self, elt: A) {
558-
self.insert_next_node(~Node::new(elt))
558+
self.insert_next_node(box Node::new(elt))
559559
}
560560

561561
#[inline]
@@ -675,19 +675,19 @@ mod tests {
675675
assert_eq!(m.pop_front(), None);
676676
assert_eq!(m.pop_back(), None);
677677
assert_eq!(m.pop_front(), None);
678-
m.push_front(~1);
678+
m.push_front(box 1);
679679
assert_eq!(m.pop_front(), Some(~1));
680-
m.push_back(~2);
681-
m.push_back(~3);
680+
m.push_back(box 2);
681+
m.push_back(box 3);
682682
assert_eq!(m.len(), 2);
683683
assert_eq!(m.pop_front(), Some(~2));
684684
assert_eq!(m.pop_front(), Some(~3));
685685
assert_eq!(m.len(), 0);
686686
assert_eq!(m.pop_front(), None);
687-
m.push_back(~1);
688-
m.push_back(~3);
689-
m.push_back(~5);
690-
m.push_back(~7);
687+
m.push_back(box 1);
688+
m.push_back(box 3);
689+
m.push_back(box 5);
690+
m.push_back(box 7);
691691
assert_eq!(m.pop_front(), Some(~1));
692692

693693
let mut n = DList::new();

src/libcollections/lru_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<K: Hash + TotalEq, V> LruCache<K, V> {
9393
let cache = LruCache {
9494
map: HashMap::new(),
9595
max_size: capacity,
96-
head: unsafe{ cast::transmute(~mem::uninit::<LruEntry<K, V>>()) },
96+
head: unsafe{ cast::transmute(box mem::uninit::<LruEntry<K, V>>()) },
9797
};
9898
unsafe {
9999
(*cache.head).next = cache.head;
@@ -111,7 +111,7 @@ impl<K: Hash + TotalEq, V> LruCache<K, V> {
111111
(node_ptr, None)
112112
}
113113
None => {
114-
let mut node = ~LruEntry::new(k, v);
114+
let mut node = box LruEntry::new(k, v);
115115
let node_ptr: *mut LruEntry<K, V> = &mut *node;
116116
(node_ptr, Some(node))
117117
}

src/libcollections/priority_queue.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,19 @@ mod tests {
273273
let mut heap = PriorityQueue::from_vec(vec!(~2, ~4, ~9));
274274
assert_eq!(heap.len(), 3);
275275
assert!(*heap.top() == ~9);
276-
heap.push(~11);
276+
heap.push(box 11);
277277
assert_eq!(heap.len(), 4);
278278
assert!(*heap.top() == ~11);
279-
heap.push(~5);
279+
heap.push(box 5);
280280
assert_eq!(heap.len(), 5);
281281
assert!(*heap.top() == ~11);
282-
heap.push(~27);
282+
heap.push(box 27);
283283
assert_eq!(heap.len(), 6);
284284
assert!(*heap.top() == ~27);
285-
heap.push(~3);
285+
heap.push(box 3);
286286
assert_eq!(heap.len(), 7);
287287
assert!(*heap.top() == ~27);
288-
heap.push(~103);
288+
heap.push(box 103);
289289
assert_eq!(heap.len(), 8);
290290
assert!(*heap.top() == ~103);
291291
}

src/libcollections/smallintmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ mod test_map {
459459
#[test]
460460
fn test_move_iter() {
461461
let mut m = SmallIntMap::new();
462-
m.insert(1, ~2);
462+
m.insert(1, box 2);
463463
let mut called = false;
464464
for (k, v) in m.move_iter() {
465465
assert!(!called);
@@ -468,7 +468,7 @@ mod test_map {
468468
assert_eq!(v, ~2);
469469
}
470470
assert!(called);
471-
m.insert(2, ~1);
471+
m.insert(2, box 1);
472472
}
473473
}
474474

src/libcollections/treemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ fn insert<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
834834
}
835835
}
836836
None => {
837-
*node = Some(~TreeNode::new(key, value));
837+
*node = Some(box TreeNode::new(key, value));
838838
None
839839
}
840840
}

src/libcollections/trie.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ fn insert<T>(count: &mut uint, child: &mut Child<T>, key: uint, value: T,
448448
// have to move out of `child`.
449449
match mem::replace(child, Nothing) {
450450
External(stored_key, stored_value) => {
451-
let mut new = ~TrieNode::new();
451+
let mut new = box TrieNode::new();
452452
insert(&mut new.count,
453453
&mut new.children[chunk(stored_key, idx)],
454454
stored_key, stored_value, idx + 1);

src/libgreen/basic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::unstable::sync::Exclusive;
2323

2424
/// This is the only exported function from this module.
2525
pub fn event_loop() -> ~EventLoop:Send {
26-
~BasicLoop::new() as ~EventLoop:Send
26+
box BasicLoop::new() as ~EventLoop:Send
2727
}
2828

2929
struct BasicLoop {
@@ -143,7 +143,7 @@ impl EventLoop for BasicLoop {
143143
fn pausable_idle_callback(&mut self, cb: ~Callback:Send)
144144
-> ~PausableIdleCallback:Send
145145
{
146-
let callback = ~BasicPausable::new(self, cb);
146+
let callback = box BasicPausable::new(self, cb);
147147
rtassert!(self.idle.is_none());
148148
unsafe {
149149
let cb_ptr: &*mut BasicPausable = cast::transmute(&callback);
@@ -156,7 +156,7 @@ impl EventLoop for BasicLoop {
156156
let id = self.next_remote;
157157
self.next_remote += 1;
158158
self.remotes.push((id, f));
159-
~BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback:Send
159+
box BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback:Send
160160
}
161161

162162
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory> { None }

0 commit comments

Comments
 (0)