Skip to content

Commit d878df0

Browse files
committed
auto merge of #13183 : erickt/rust/remove-list, r=alexcrichton
`collections::list::List` was decided in a [team meeting](https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-03-25) that it was unnecessary, so this PR removes it. Additionally, it removes an old and redundant purity test and fixes some warnings.
2 parents 3eb3a02 + 63b233c commit d878df0

File tree

11 files changed

+31
-296
lines changed

11 files changed

+31
-296
lines changed

src/libarena/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
extern crate collections;
2929

30-
use collections::list::{List, Cons, Nil};
31-
3230
use std::cast::{transmute, transmute_mut, transmute_mut_region};
3331
use std::cast;
3432
use std::cell::{Cell, RefCell};
@@ -87,7 +85,7 @@ pub struct Arena {
8785
// access the head.
8886
priv head: Chunk,
8987
priv copy_head: Chunk,
90-
priv chunks: RefCell<@List<Chunk>>,
88+
priv chunks: RefCell<Vec<Chunk>>,
9189
}
9290

9391
impl Arena {
@@ -99,7 +97,7 @@ impl Arena {
9997
Arena {
10098
head: chunk(initial_size, false),
10199
copy_head: chunk(initial_size, true),
102-
chunks: RefCell::new(@Nil),
100+
chunks: RefCell::new(Vec::new()),
103101
}
104102
}
105103
}
@@ -117,7 +115,7 @@ impl Drop for Arena {
117115
fn drop(&mut self) {
118116
unsafe {
119117
destroy_chunk(&self.head);
120-
for chunk in self.chunks.get().iter() {
118+
for chunk in self.chunks.borrow().iter() {
121119
if !chunk.is_copy.get() {
122120
destroy_chunk(chunk);
123121
}
@@ -179,7 +177,7 @@ impl Arena {
179177
fn alloc_copy_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
180178
// Allocate a new chunk.
181179
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
182-
self.chunks.set(@Cons(self.copy_head.clone(), self.chunks.get()));
180+
self.chunks.borrow_mut().push(self.copy_head.clone());
183181
self.copy_head =
184182
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);
185183

@@ -219,7 +217,7 @@ impl Arena {
219217
-> (*u8, *u8) {
220218
// Allocate a new chunk.
221219
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
222-
self.chunks.set(@Cons(self.head.clone(), self.chunks.get()));
220+
self.chunks.borrow_mut().push(self.head.clone());
223221
self.head =
224222
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);
225223

src/libcollections/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pub use deque::Deque;
3333
pub use dlist::DList;
3434
pub use enum_set::EnumSet;
3535
pub use hashmap::{HashMap, HashSet};
36-
pub use list::List;
3736
pub use lru_cache::LruCache;
3837
pub use priority_queue::PriorityQueue;
3938
pub use ringbuf::RingBuf;
@@ -47,7 +46,6 @@ pub mod deque;
4746
pub mod dlist;
4847
pub mod enum_set;
4948
pub mod hashmap;
50-
pub mod list;
5149
pub mod lru_cache;
5250
pub mod priority_queue;
5351
pub mod ringbuf;

src/libcollections/list.rs

Lines changed: 0 additions & 237 deletions
This file was deleted.

src/libgreen/sched.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,7 @@ mod test {
14731473
let mut handle = pool.spawn_sched();
14741474
handle.send(PinnedTask(pool.task(TaskOpts::new(), proc() {
14751475
unsafe {
1476-
let mut guard = LOCK.lock();
1476+
let guard = LOCK.lock();
14771477

14781478
start_tx.send(());
14791479
guard.wait(); // block the scheduler thread
@@ -1509,7 +1509,7 @@ mod test {
15091509
child_tx.send(20);
15101510
pingpong(&parent_rx, &child_tx);
15111511
unsafe {
1512-
let mut guard = LOCK.lock();
1512+
let guard = LOCK.lock();
15131513
guard.signal(); // wakeup waiting scheduler
15141514
guard.wait(); // wait for them to grab the lock
15151515
}

src/librustc/middle/typeck/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ use util::nodemap::{DefIdMap, FnvHashMap};
7272

7373
use std::cell::RefCell;
7474
use std::rc::Rc;
75-
use collections::List;
7675
use syntax::codemap::Span;
7776
use syntax::print::pprust::*;
7877
use syntax::{ast, ast_map, abi};
@@ -327,7 +326,7 @@ pub fn require_same_types(tcx: &ty::ctxt,
327326

328327
// a list of mapping from in-scope-region-names ("isr") to the
329328
// corresponding ty::Region
330-
pub type isr_alist = @List<(ty::BoundRegion, ty::Region)>;
329+
pub type isr_alist = @Vec<(ty::BoundRegion, ty::Region)>;
331330

332331
trait get_region<'a, T:'static> {
333332
fn get(&'a self, br: ty::BoundRegion) -> ty::Region;

src/libstd/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2335,7 +2335,7 @@ mod tests {
23352335

23362336
#[test]
23372337
fn test_counter_from_iter() {
2338-
let mut it = count(0, 5).take(10);
2338+
let it = count(0, 5).take(10);
23392339
let xs: ~[int] = FromIterator::from_iterator(it);
23402340
assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
23412341
}

src/libstd/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3218,7 +3218,7 @@ mod tests {
32183218
let data = ~"ประเทศไทย中";
32193219
let mut cpy = data.clone();
32203220
let other = "abc";
3221-
let mut it = other.chars();
3221+
let it = other.chars();
32223222
cpy.extend(it);
32233223
assert_eq!(cpy, data + other);
32243224
}

src/libstd/unstable/mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ mod test {
621621
#[test]
622622
fn destroy_immediately() {
623623
unsafe {
624-
let mut m = StaticNativeMutex::new();
624+
let m = StaticNativeMutex::new();
625625
m.destroy();
626626
}
627627
}

src/test/bench/task-perf-alloc-unwind.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
extern crate collections;
1414
extern crate time;
1515

16-
use collections::list::{List, Cons, Nil};
1716
use time::precise_time_s;
1817
use std::os;
1918
use std::task;
2019
use std::vec;
2120

21+
#[deriving(Clone)]
22+
enum List<T> {
23+
Nil, Cons(T, @List<T>)
24+
}
25+
2226
enum UniqueList {
2327
ULNil, ULCons(~UniqueList)
2428
}

0 commit comments

Comments
 (0)