@@ -107,6 +107,8 @@ pub enum Node {
107
107
108
108
/// NodeStructCtor represents a tuple struct.
109
109
NodeStructCtor ( @StructDef ) ,
110
+
111
+ NodeLifetime ( @Lifetime ) ,
110
112
}
111
113
112
114
// The odd layout is to bring down the total size.
@@ -127,6 +129,7 @@ enum MapEntry {
127
129
EntryLocal ( NodeId , @Pat ) ,
128
130
EntryBlock ( NodeId , P < Block > ) ,
129
131
EntryStructCtor ( NodeId , @StructDef ) ,
132
+ EntryLifetime ( NodeId , @Lifetime ) ,
130
133
131
134
// Roots for node trees.
132
135
RootCrate ,
@@ -153,6 +156,7 @@ impl MapEntry {
153
156
EntryLocal ( id, _) => id,
154
157
EntryBlock ( id, _) => id,
155
158
EntryStructCtor ( id, _) => id,
159
+ EntryLifetime ( id, _) => id,
156
160
_ => return None
157
161
} )
158
162
}
@@ -170,6 +174,7 @@ impl MapEntry {
170
174
EntryLocal ( _, p) => NodeLocal ( p) ,
171
175
EntryBlock ( _, p) => NodeBlock ( p) ,
172
176
EntryStructCtor ( _, p) => NodeStructCtor ( p) ,
177
+ EntryLifetime ( _, p) => NodeLifetime ( p) ,
173
178
_ => return None
174
179
} )
175
180
}
@@ -213,6 +218,8 @@ impl Map {
213
218
self . find_entry ( id) . and_then ( |x| x. to_node ( ) )
214
219
}
215
220
221
+ /// Retrieve the parent NodeId for `id`, or `id` itself if no
222
+ /// parent is registered in this map.
216
223
pub fn get_parent ( & self , id : NodeId ) -> NodeId {
217
224
self . find_entry ( id) . and_then ( |x| x. parent ( ) ) . unwrap_or ( id)
218
225
}
@@ -500,6 +507,15 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
500
507
SmallVector :: one ( stmt)
501
508
}
502
509
510
+ fn fold_type_method ( & mut self , m : & TypeMethod ) -> TypeMethod {
511
+ let parent = self . parent ;
512
+ self . parent = DUMMY_NODE_ID ;
513
+ let m = fold:: noop_fold_type_method ( m, self ) ;
514
+ assert_eq ! ( self . parent, m. id) ;
515
+ self . parent = parent;
516
+ m
517
+ }
518
+
503
519
fn fold_method ( & mut self , m : @Method ) -> @Method {
504
520
let parent = self . parent ;
505
521
self . parent = DUMMY_NODE_ID ;
@@ -522,6 +538,12 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
522
538
self . insert ( block. id , EntryBlock ( self . parent , block) ) ;
523
539
block
524
540
}
541
+
542
+ fn fold_lifetime ( & mut self , lifetime : & Lifetime ) -> Lifetime {
543
+ let lifetime = fold:: noop_fold_lifetime ( lifetime, self ) ;
544
+ self . insert ( lifetime. id , EntryLifetime ( self . parent , @lifetime) ) ;
545
+ lifetime
546
+ }
525
547
}
526
548
527
549
pub fn map_crate < F : FoldOps > ( krate : Crate , fold_ops : F ) -> ( Crate , Map ) {
@@ -658,6 +680,9 @@ fn node_id_to_str(map: &Map, id: NodeId) -> ~str {
658
680
Some ( NodeStructCtor ( _) ) => {
659
681
format ! ( "struct_ctor {} (id={})" , map. path_to_str( id) , id)
660
682
}
683
+ Some ( NodeLifetime ( ref l) ) => {
684
+ format ! ( "lifetime {} (id={})" , pprust:: lifetime_to_str( * l) , id)
685
+ }
661
686
None => {
662
687
format ! ( "unknown node (id={})" , id)
663
688
}
0 commit comments