Skip to content

Commit bfb07fc

Browse files
committed
---
yaml --- r: 150877 b: refs/heads/try2 c: b25fe99 h: refs/heads/master i: 150875: 6283119 v: v3
1 parent d003055 commit bfb07fc

File tree

4 files changed

+87
-34
lines changed

4 files changed

+87
-34
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 0e30f07abc76587f676e91770b7630ac9727b2cb
8+
refs/heads/try2: b25fe99331a114b92131ecd4bd37abefb2508ff0
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/monomorphize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ pub fn monomorphic_fn(ccx: &CrateContext,
272272
}
273273

274274
// Ugh -- but this ensures any new variants won't be forgotten
275+
ast_map::NodeLifetime(..) |
275276
ast_map::NodeExpr(..) |
276277
ast_map::NodeStmt(..) |
277278
ast_map::NodeArg(..) |

branches/try2/src/libsyntax/ast_map.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ pub enum Node {
107107

108108
/// NodeStructCtor represents a tuple struct.
109109
NodeStructCtor(@StructDef),
110+
111+
NodeLifetime(@Lifetime),
110112
}
111113

112114
// The odd layout is to bring down the total size.
@@ -127,6 +129,7 @@ enum MapEntry {
127129
EntryLocal(NodeId, @Pat),
128130
EntryBlock(NodeId, P<Block>),
129131
EntryStructCtor(NodeId, @StructDef),
132+
EntryLifetime(NodeId, @Lifetime),
130133

131134
// Roots for node trees.
132135
RootCrate,
@@ -153,6 +156,7 @@ impl MapEntry {
153156
EntryLocal(id, _) => id,
154157
EntryBlock(id, _) => id,
155158
EntryStructCtor(id, _) => id,
159+
EntryLifetime(id, _) => id,
156160
_ => return None
157161
})
158162
}
@@ -170,6 +174,7 @@ impl MapEntry {
170174
EntryLocal(_, p) => NodeLocal(p),
171175
EntryBlock(_, p) => NodeBlock(p),
172176
EntryStructCtor(_, p) => NodeStructCtor(p),
177+
EntryLifetime(_, p) => NodeLifetime(p),
173178
_ => return None
174179
})
175180
}
@@ -213,6 +218,8 @@ impl Map {
213218
self.find_entry(id).and_then(|x| x.to_node())
214219
}
215220

221+
/// Retrieve the parent NodeId for `id`, or `id` itself if no
222+
/// parent is registered in this map.
216223
pub fn get_parent(&self, id: NodeId) -> NodeId {
217224
self.find_entry(id).and_then(|x| x.parent()).unwrap_or(id)
218225
}
@@ -500,6 +507,15 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
500507
SmallVector::one(stmt)
501508
}
502509

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+
503519
fn fold_method(&mut self, m: @Method) -> @Method {
504520
let parent = self.parent;
505521
self.parent = DUMMY_NODE_ID;
@@ -522,6 +538,12 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> {
522538
self.insert(block.id, EntryBlock(self.parent, block));
523539
block
524540
}
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+
}
525547
}
526548

527549
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 {
658680
Some(NodeStructCtor(_)) => {
659681
format!("struct_ctor {} (id={})", map.path_to_str(id), id)
660682
}
683+
Some(NodeLifetime(ref l)) => {
684+
format!("lifetime {} (id={})", pprust::lifetime_to_str(*l), id)
685+
}
661686
None => {
662687
format!("unknown node (id={})", id)
663688
}

0 commit comments

Comments
 (0)