Skip to content

Commit dc6803d

Browse files
committed
---
yaml --- r: 218355 b: refs/heads/master c: df5a1ca h: refs/heads/master i: 218353: 5599df0 218351: 5769f1a v: v3
1 parent 8aaf087 commit dc6803d

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f28f79b79615fc77e65ec42c4e2a3960659150c9
2+
refs/heads/master: df5a1ca8809d2d57e18cfe0c9d186a5699da6414
33
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
822822
struct_lit_data.ref_id,
823823
struct_lit_data.scope);
824824
let struct_def = struct_lit_data.ref_id;
825+
let scope = self.save_ctxt.enclosing_scope(ex.id);
825826

826827
for field in fields {
827828
if generated_code(field.ident.span) {
@@ -830,7 +831,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
830831

831832
let field_data = self.save_ctxt.get_field_ref_data(field,
832833
struct_def,
833-
self.cur_scope);
834+
scope);
834835
self.fmt.ref_str(recorder::VarRef,
835836
field.ident.span,
836837
Some(field_data.span),

trunk/src/librustc_trans/save/mod.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
194194
qualname: qualname,
195195
declaration: None,
196196
span: sub_span.unwrap(),
197-
scope: self.tcx.map.get_enclosing_scope(item.id).unwrap_or(0),
197+
scope: self.enclosing_scope(item.id),
198198
})
199199
}
200200
ast::ItemStatic(ref typ, mt, ref expr) => {
@@ -213,7 +213,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
213213
name: get_ident(item.ident).to_string(),
214214
qualname: qualname,
215215
span: sub_span.unwrap(),
216-
scope: self.tcx.map.get_enclosing_scope(item.id).unwrap_or(0),
216+
scope: self.enclosing_scope(item.id),
217217
value: value,
218218
type_value: ty_to_string(&typ),
219219
})
@@ -227,7 +227,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
227227
name: get_ident(item.ident).to_string(),
228228
qualname: qualname,
229229
span: sub_span.unwrap(),
230-
scope: self.tcx.map.get_enclosing_scope(item.id).unwrap_or(0),
230+
scope: selfenclosing_scope(item.id),
231231
value: self.span_utils.snippet(expr.span),
232232
type_value: ty_to_string(&typ),
233233
})
@@ -245,7 +245,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
245245
name: get_ident(item.ident).to_string(),
246246
qualname: qualname,
247247
span: sub_span.unwrap(),
248-
scope: self.tcx.map.get_enclosing_scope(item.id).unwrap_or(0),
248+
scope: self.enclosing_scope(item.id),
249249
filename: filename,
250250
})
251251
},
@@ -259,14 +259,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
259259
value: val,
260260
span: sub_span.unwrap(),
261261
qualname: enum_name,
262-
scope: self.tcx.map.get_enclosing_scope(item.id).unwrap_or(0),
262+
scope: self.enclosing_scope(item.id),
263263
})
264264
},
265265
ast::ItemImpl(_, _, _, ref trait_ref, ref typ, _) => {
266266
let mut type_data = None;
267267
let sub_span;
268268

269-
let parent = self.tcx.map.get_enclosing_scope(item.id).unwrap_or(0);
269+
let parent = self.enclosing_scope(item.id);
270270

271271
match typ.node {
272272
// Common case impl for a struct or something basic.
@@ -303,14 +303,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
303303
}
304304
}
305305

306-
// FIXME: we ought to be able to get the parent id ourselves, but we can't
307-
// for now.
308-
pub fn get_field_data(&self, field: &ast::StructField, parent: NodeId) -> Option<Data> {
306+
pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option<Data> {
309307
match field.node.kind {
310308
ast::NamedField(ident, _) => {
311309
let name = get_ident(ident);
312310
let qualname = format!("::{}::{}",
313-
self.tcx.map.path_to_string(parent),
311+
self.tcx.map.path_to_string(scope),
314312
name);
315313
let typ = self.tcx.node_types().get(&field.node.id).unwrap()
316314
.to_string();
@@ -320,7 +318,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
320318
name: get_ident(ident).to_string(),
321319
qualname: qualname,
322320
span: sub_span.unwrap(),
323-
scope: parent,
321+
scope: scope,
324322
value: "".to_owned(),
325323
type_value: typ,
326324
}))
@@ -329,8 +327,6 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
329327
}
330328
}
331329

332-
// FIXME: we ought to be able to get the parent id ourselves, but we can't
333-
// for now.
334330
pub fn get_trait_ref_data(&self,
335331
trait_ref: &ast::TraitRef,
336332
parent: NodeId)
@@ -359,7 +355,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
359355
return Some(Data::VariableRefData(VariableRefData {
360356
name: get_ident(ident.node).to_string(),
361357
span: sub_span.unwrap(),
362-
scope: self.tcx.map.get_enclosing_scope(expr.id).unwrap_or(0),
358+
scope: self.enclosing_scope(expr.id),
363359
ref_id: f.id,
364360
}));
365361
}
@@ -382,7 +378,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
382378
let sub_span = self.span_utils.span_for_last_ident(path.span);
383379
Some(Data::TypeRefData(TypeRefData {
384380
span: sub_span.unwrap(),
385-
scope: self.tcx.map.get_enclosing_scope(expr.id).unwrap_or(0),
381+
scope: self.enclosing_scope(expr.id),
386382
ref_id: def_id,
387383
}))
388384
}
@@ -402,7 +398,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
402398
ty::TraitContainer(_) => (None, Some(method_id))
403399
};
404400
let sub_span = self.span_utils.sub_span_for_meth_name(expr.span);
405-
let parent = self.tcx.map.get_enclosing_scope(expr.id).unwrap_or(0);
401+
let parent = self.enclosing_scope(expr.id);
406402
Some(Data::MethodCallData(MethodCallData {
407403
span: sub_span.unwrap(),
408404
scope: parent,
@@ -441,15 +437,15 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
441437
Data::VariableRefData(VariableRefData {
442438
name: self.span_utils.snippet(sub_span.unwrap()),
443439
span: sub_span.unwrap(),
444-
scope: self.tcx.map.get_enclosing_scope(id).unwrap_or(0),
440+
scope: self.enclosing_scope(id),
445441
ref_id: def.def_id(),
446442
})
447443
}
448444
def::DefStruct(def_id) | def::DefTy(def_id, _) => {
449445
Data::TypeRefData(TypeRefData {
450446
span: sub_span.unwrap(),
451447
ref_id: def_id,
452-
scope: self.tcx.map.get_enclosing_scope(id).unwrap_or(0),
448+
scope: self.enclosing_scope(id),
453449
})
454450
}
455451
def::DefMethod(decl_id, provenence) => {
@@ -484,7 +480,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
484480
};
485481
Data::MethodCallData(MethodCallData {
486482
span: sub_span.unwrap(),
487-
scope: self.tcx.map.get_enclosing_scope(id).unwrap_or(0),
483+
scope: self.enclosing_scope(id),
488484
ref_id: def_id,
489485
decl_id: Some(decl_id),
490486
})
@@ -493,7 +489,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
493489
Data::FunctionCallData(FunctionCallData {
494490
ref_id: def_id,
495491
span: sub_span.unwrap(),
496-
scope: self.tcx.map.get_enclosing_scope(id).unwrap_or(0),
492+
scope: self.enclosing_scope(id),
497493
})
498494
}
499495
_ => self.tcx.sess.span_bug(path.span,
@@ -545,6 +541,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
545541
}
546542
}
547543

544+
#[inline]
545+
fn enclosing_scope(&self, id: NodeId) -> NodeId {
546+
self.tcx.map.get_enclosing_scope(id).unwrap_or(0)
547+
}
548548
}
549549

550550
// An AST visitor for collecting paths from patterns.

0 commit comments

Comments
 (0)