Skip to content

Commit 81c106c

Browse files
committed
---
yaml --- r: 213087 b: refs/heads/auto c: 788fddd h: refs/heads/master i: 213085: a95d20d 213083: 1852181 213079: 5a28856 213071: 6bc743a 213055: aa5c558 v: v3
1 parent 5794539 commit 81c106c

File tree

3 files changed

+66
-34
lines changed

3 files changed

+66
-34
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 04b32cecace8565d04c8f3f9e02cca0680f0f7ed
13+
refs/heads/auto: 788fdddf3735f49c06b847578a090a863ed1c32d
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc_trans/save/dump_csv.rs

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
708708
&val);
709709

710710
// super-traits
711-
for super_bound in &trait_refs {
711+
for super_bound in trait_refs.iter() {
712712
let trait_ref = match *super_bound {
713713
ast::TraitTyParamBound(ref trait_ref, _) => {
714714
trait_ref
@@ -882,44 +882,35 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
882882

883883
self.write_sub_paths_truncated(path, false);
884884

885-
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, ex).sty;
886-
let struct_def = match *ty {
887-
ty::TyStruct(def_id, _) => {
888-
let sub_span = self.span.span_for_last_ident(path.span);
889-
self.fmt.ref_str(recorder::TypeRef,
890-
path.span,
891-
sub_span,
892-
def_id,
893-
self.cur_scope);
894-
Some(def_id)
895-
}
896-
_ => None
885+
let struct_lit_data = self.save_ctxt.get_expr_data(ex);
886+
let struct_def = if let super::Data::TypeRefData(struct_lit_data) = struct_lit_data {
887+
self.fmt.ref_str(recorder::TypeRef,
888+
ex.span,
889+
Some(struct_lit_data.span),
890+
struct_lit_data.ref_id,
891+
struct_lit_data.scope);
892+
struct_lit_data.ref_id
893+
} else {
894+
self.sess.span_bug(ex.span, "expected TypeRefData");
897895
};
898896

899897
for field in fields {
900-
match struct_def {
901-
Some(struct_def) => {
902-
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, struct_def);
903-
for f in &fields {
904-
if generated_code(field.ident.span) {
905-
continue;
906-
}
907-
if f.name == field.ident.node.name {
908-
// We don't really need a sub-span here, but no harm done
909-
let sub_span = self.span.span_for_last_ident(field.ident.span);
910-
self.fmt.ref_str(recorder::VarRef,
911-
field.ident.span,
912-
sub_span,
913-
f.id,
914-
self.cur_scope);
915-
}
916-
}
917-
}
918-
None => {}
898+
if generated_code(field.ident.span) {
899+
continue;
919900
}
920901

902+
let field_data = self.save_ctxt.get_field_ref_data(field,
903+
struct_def,
904+
self.cur_scope);
905+
self.fmt.ref_str(recorder::VarRef,
906+
field.ident.span,
907+
Some(field_data.span),
908+
field_data.ref_id,
909+
field_data.scope);
910+
921911
self.visit_expr(&field.expr)
922912
}
913+
923914
visit::walk_expr_opt(self, base)
924915
}
925916

branches/auto/src/librustc_trans/save/mod.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,54 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
349349
&format!("Expected struct type, found {:?}", ty)),
350350
}
351351
}
352+
ast::ExprStruct(ref path, _, _) => {
353+
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, expr).sty;
354+
match *ty {
355+
ty::ty_struct(def_id, _) => {
356+
let sub_span = self.span_utils.span_for_last_ident(path.span);
357+
Data::TypeRefData(TypeRefData {
358+
span: sub_span.unwrap(),
359+
scope: self.analysis.ty_cx.map.get_parent(expr.id),
360+
ref_id: def_id,
361+
})
362+
}
363+
_ => {
364+
self.sess.span_bug(expr.span,
365+
&format!("expected ty_struct, found {:?}", ty));
366+
}
367+
}
368+
}
352369
_ => {
353370
// FIXME
354371
unimplemented!();
355372
}
356373
}
357374
}
358375

376+
pub fn get_field_ref_data(&self,
377+
field_ref: &ast::Field,
378+
struct_id: DefId,
379+
parent: NodeId)
380+
-> VariableRefData {
381+
let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, struct_id);
382+
let field_name = get_ident(field_ref.ident.node).to_string();
383+
for f in &fields {
384+
if f.name == field_ref.ident.node.name {
385+
// We don't really need a sub-span here, but no harm done
386+
let sub_span = self.span_utils.span_for_last_ident(field_ref.ident.span);
387+
return VariableRefData {
388+
name: field_name,
389+
span: sub_span.unwrap(),
390+
scope: parent,
391+
ref_id: f.id,
392+
};
393+
}
394+
}
395+
396+
self.sess.span_bug(field_ref.span,
397+
&format!("Couldn't find field {}", field_name));
398+
}
399+
359400
pub fn get_data_for_id(&self, _id: &NodeId) -> Data {
360401
// FIXME
361402
unimplemented!();
@@ -400,7 +441,7 @@ impl<'v> Visitor<'v> for PathCollector {
400441
self.collected_paths.push((p.id,
401442
path.clone(),
402443
ast::MutMutable,
403-
recorder::StructRef));
444+
recorder::TypeRef));
404445
}
405446
ast::PatEnum(ref path, _) |
406447
ast::PatQPath(_, ref path) => {

0 commit comments

Comments
 (0)