diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index d11fc6efba46..ae75c04da72d 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -18,28 +18,11 @@ enum dlist_node = @{ mut next: dlist_link }; -class dlist_root { - let mut size: uint; - let mut hd: dlist_link; - let mut tl: dlist_link; - new() { - self.size = 0; self.hd = none; self.tl = none; - } - drop { - /* FIXME (#3039) This doesn't work during task failure - the box - * annihilator might have killed some of our nodes already. This will - * be safe to uncomment when the box annihilator is safer. As is, - * this makes test_dlist_cyclic_link below crash the runtime. - // Empty the list. Not doing this explicitly would leave cyclic links - // around, not to be freed until cycle collection at task exit. - while self.hd.is_some() { - self.unlink(self.hd.get()); - } - */ - } -} - -type dlist = @dlist_root; +enum dlist = @{ + mut size: uint, + mut hd: dlist_link, + mut tl: dlist_link, +}; impl private_methods for dlist_node { pure fn assert_links() { @@ -107,7 +90,7 @@ pure fn new_dlist_node(+data: T) -> dlist_node { /// Creates a new, empty dlist. pure fn new_dlist() -> dlist { - @unchecked { dlist_root() } + dlist(@{mut size: 0, mut hd: none, mut tl: none}) } /// Creates a new dlist with a single element @@ -134,7 +117,7 @@ fn concat(lists: dlist>) -> dlist { result } -impl private_methods for dlist_root { +impl private_methods for dlist { pure fn new_link(-data: T) -> dlist_link { some(dlist_node(@{data: data, mut linked: true, mut prev: none, mut next: none})) @@ -336,7 +319,7 @@ impl extensions for dlist { * to the other list's head. O(1). */ fn append(them: dlist) { - if box::ptr_eq(self, them) { + if box::ptr_eq(*self, *them) { fail ~"Cannot append a dlist to itself!" } if them.len() > 0 { @@ -353,7 +336,7 @@ impl extensions for dlist { * list's tail to this list's head. O(1). */ fn prepend(them: dlist) { - if box::ptr_eq(self, them) { + if box::ptr_eq(*self, *them) { fail ~"Cannot prepend a dlist to itself!" } if them.len() > 0 {