@@ -57,7 +57,7 @@ For example, the following simple type for a singly-linked list...
57
57
```
58
58
struct List {
59
59
value: int,
60
- tail: Option<@ List>,
60
+ tail: Option<~ List>,
61
61
}
62
62
```
63
63
@@ -66,8 +66,8 @@ will generate the following callstack with a naive DFS algorithm:
66
66
```
67
67
describe(t = List)
68
68
describe(t = int)
69
- describe(t = Option<@ List>)
70
- describe(t = @ List)
69
+ describe(t = Option<~ List>)
70
+ describe(t = ~ List)
71
71
describe(t = List) // at the beginning again...
72
72
...
73
73
```
@@ -144,7 +144,7 @@ use util::ppaux;
144
144
145
145
use std:: c_str:: { CString , ToCStr } ;
146
146
use std:: cell:: { Cell , RefCell } ;
147
- use std:: rc:: Rc ;
147
+ use std:: rc:: { Rc , Weak } ;
148
148
use collections:: HashMap ;
149
149
use collections:: HashSet ;
150
150
use libc:: { c_uint, c_ulonglong, c_longlong} ;
@@ -181,7 +181,7 @@ pub struct CrateDebugContext {
181
181
created_files : RefCell < HashMap < ~str , DIFile > > ,
182
182
created_types : RefCell < HashMap < uint , DIType > > ,
183
183
created_enum_disr_types : RefCell < HashMap < ast:: DefId , DIType > > ,
184
- namespace_map : RefCell < HashMap < Vec < ast:: Name > , @ NamespaceTreeNode > > ,
184
+ namespace_map : RefCell < HashMap < Vec < ast:: Name > , Rc < NamespaceTreeNode > > > ,
185
185
// This collection is used to assert that composite types (structs, enums, ...) have their
186
186
// members only set once:
187
187
composite_types_completed : RefCell < HashSet < DIType > > ,
@@ -2831,14 +2831,14 @@ fn populate_scope_map(cx: &CrateContext,
2831
2831
struct NamespaceTreeNode {
2832
2832
name : ast:: Name ,
2833
2833
scope : DIScope ,
2834
- parent : Option < @ NamespaceTreeNode > ,
2834
+ parent : Option < Weak < NamespaceTreeNode > > ,
2835
2835
}
2836
2836
2837
2837
impl NamespaceTreeNode {
2838
2838
fn mangled_name_of_contained_item ( & self , item_name : & str ) -> ~str {
2839
2839
fn fill_nested ( node : & NamespaceTreeNode , output : & mut StrBuf ) {
2840
2840
match node. parent {
2841
- Some ( parent) => fill_nested ( parent, output) ,
2841
+ Some ( ref parent) => fill_nested ( & * parent. upgrade ( ) . unwrap ( ) , output) ,
2842
2842
None => { }
2843
2843
}
2844
2844
let string = token:: get_name ( node. name ) ;
@@ -2855,7 +2855,7 @@ impl NamespaceTreeNode {
2855
2855
}
2856
2856
}
2857
2857
2858
- fn namespace_for_item ( cx : & CrateContext , def_id : ast:: DefId ) -> @ NamespaceTreeNode {
2858
+ fn namespace_for_item ( cx : & CrateContext , def_id : ast:: DefId ) -> Rc < NamespaceTreeNode > {
2859
2859
ty:: with_path ( cx. tcx ( ) , def_id, |path| {
2860
2860
// prepend crate name if not already present
2861
2861
let krate = if def_id. krate == ast:: LOCAL_CRATE {
@@ -2867,7 +2867,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> @NamespaceTreeNo
2867
2867
let mut path = krate. move_iter ( ) . chain ( path) . peekable ( ) ;
2868
2868
2869
2869
let mut current_key = Vec :: new ( ) ;
2870
- let mut parent_node: Option < @ NamespaceTreeNode > = None ;
2870
+ let mut parent_node: Option < Rc < NamespaceTreeNode > > = None ;
2871
2871
2872
2872
// Create/Lookup namespace for each element of the path.
2873
2873
loop {
@@ -2891,7 +2891,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> @NamespaceTreeNo
2891
2891
None => {
2892
2892
// create and insert
2893
2893
let parent_scope = match parent_node {
2894
- Some ( node) => node. scope ,
2894
+ Some ( ref node) => node. scope ,
2895
2895
None => ptr:: null ( )
2896
2896
} ;
2897
2897
let namespace_name = token:: get_name ( name) ;
@@ -2908,14 +2908,14 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> @NamespaceTreeNo
2908
2908
}
2909
2909
} ) ;
2910
2910
2911
- let node = @ NamespaceTreeNode {
2911
+ let node = Rc :: new ( NamespaceTreeNode {
2912
2912
name : name,
2913
2913
scope : scope,
2914
- parent : parent_node,
2915
- } ;
2914
+ parent : parent_node. map ( |parent| parent . downgrade ( ) ) ,
2915
+ } ) ;
2916
2916
2917
2917
debug_context ( cx) . namespace_map . borrow_mut ( )
2918
- . insert ( current_key. clone ( ) , node) ;
2918
+ . insert ( current_key. clone ( ) , node. clone ( ) ) ;
2919
2919
2920
2920
node
2921
2921
}
0 commit comments