Skip to content

Commit 9258053

Browse files
committed
Undo dlist's destructor-involving type structure in light of #3039
1 parent 73ca560 commit 9258053

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/libcore/dlist.rs

+9-26
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,11 @@ enum dlist_node<T> = @{
1818
mut next: dlist_link<T>
1919
};
2020

21-
class dlist_root<T> {
22-
let mut size: uint;
23-
let mut hd: dlist_link<T>;
24-
let mut tl: dlist_link<T>;
25-
new() {
26-
self.size = 0; self.hd = none; self.tl = none;
27-
}
28-
drop {
29-
/* FIXME (#3039) This doesn't work during task failure - the box
30-
* annihilator might have killed some of our nodes already. This will
31-
* be safe to uncomment when the box annihilator is safer. As is,
32-
* this makes test_dlist_cyclic_link below crash the runtime.
33-
// Empty the list. Not doing this explicitly would leave cyclic links
34-
// around, not to be freed until cycle collection at task exit.
35-
while self.hd.is_some() {
36-
self.unlink(self.hd.get());
37-
}
38-
*/
39-
}
40-
}
41-
42-
type dlist<T> = @dlist_root<T>;
21+
enum dlist<T> = @{
22+
mut size: uint,
23+
mut hd: dlist_link<T>,
24+
mut tl: dlist_link<T>,
25+
};
4326

4427
impl private_methods<T> for dlist_node<T> {
4528
pure fn assert_links() {
@@ -107,7 +90,7 @@ pure fn new_dlist_node<T>(+data: T) -> dlist_node<T> {
10790

10891
/// Creates a new, empty dlist.
10992
pure fn new_dlist<T>() -> dlist<T> {
110-
@unchecked { dlist_root() }
93+
dlist(@{mut size: 0, mut hd: none, mut tl: none})
11194
}
11295

11396
/// Creates a new dlist with a single element
@@ -134,7 +117,7 @@ fn concat<T>(lists: dlist<dlist<T>>) -> dlist<T> {
134117
result
135118
}
136119

137-
impl private_methods<T> for dlist_root<T> {
120+
impl private_methods<T> for dlist<T> {
138121
pure fn new_link(-data: T) -> dlist_link<T> {
139122
some(dlist_node(@{data: data, mut linked: true,
140123
mut prev: none, mut next: none}))
@@ -336,7 +319,7 @@ impl extensions<T> for dlist<T> {
336319
* to the other list's head. O(1).
337320
*/
338321
fn append(them: dlist<T>) {
339-
if box::ptr_eq(self, them) {
322+
if box::ptr_eq(*self, *them) {
340323
fail ~"Cannot append a dlist to itself!"
341324
}
342325
if them.len() > 0 {
@@ -353,7 +336,7 @@ impl extensions<T> for dlist<T> {
353336
* list's tail to this list's head. O(1).
354337
*/
355338
fn prepend(them: dlist<T>) {
356-
if box::ptr_eq(self, them) {
339+
if box::ptr_eq(*self, *them) {
357340
fail ~"Cannot prepend a dlist to itself!"
358341
}
359342
if them.len() > 0 {

0 commit comments

Comments
 (0)