Skip to content

Commit ccb52fd

Browse files
committed
---
yaml --- r: 213089 b: refs/heads/auto c: 7182683 h: refs/heads/master i: 213087: 81c106c v: v3
1 parent bb3783d commit ccb52fd

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
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: 92d66764121a719d6755a7c33829598d32c9f4ba
13+
refs/heads/auto: 718268398e312b02775e946af31d77fe35fb5550
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: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -873,30 +873,31 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
873873

874874
self.write_sub_paths_truncated(path, false);
875875

876-
let struct_lit_data = self.save_ctxt.get_expr_data(ex);
877-
down_cast_data!(struct_lit_data, TypeRefData, self, ex.span);
878-
self.fmt.ref_str(recorder::TypeRef,
879-
ex.span,
880-
Some(struct_lit_data.span),
881-
struct_lit_data.ref_id,
882-
struct_lit_data.scope);
883-
let struct_def = struct_lit_data.ref_id;
884-
885-
for field in fields {
886-
if generated_code(field.ident.span) {
887-
continue;
888-
}
876+
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
877+
down_cast_data!(struct_lit_data, TypeRefData, self, ex.span);
878+
self.fmt.ref_str(recorder::TypeRef,
879+
ex.span,
880+
Some(struct_lit_data.span),
881+
struct_lit_data.ref_id,
882+
struct_lit_data.scope);
883+
let struct_def = struct_lit_data.ref_id;
884+
885+
for field in fields {
886+
if generated_code(field.ident.span) {
887+
continue;
888+
}
889889

890-
let field_data = self.save_ctxt.get_field_ref_data(field,
891-
struct_def,
892-
self.cur_scope);
893-
self.fmt.ref_str(recorder::VarRef,
894-
field.ident.span,
895-
Some(field_data.span),
896-
field_data.ref_id,
897-
field_data.scope);
890+
let field_data = self.save_ctxt.get_field_ref_data(field,
891+
struct_def,
892+
self.cur_scope);
893+
self.fmt.ref_str(recorder::VarRef,
894+
field.ident.span,
895+
Some(field_data.span),
896+
field_data.ref_id,
897+
field_data.scope);
898898

899-
self.visit_expr(&field.expr)
899+
self.visit_expr(&field.expr)
900+
}
900901
}
901902

902903
visit::walk_expr_opt(self, base)
@@ -1256,13 +1257,14 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
12561257

12571258
self.visit_expr(&sub_ex);
12581259

1259-
let field_data = self.save_ctxt.get_expr_data(ex);
1260-
down_cast_data!(field_data, VariableRefData, self, ex.span);
1261-
self.fmt.ref_str(recorder::VarRef,
1262-
ex.span,
1263-
Some(field_data.span),
1264-
field_data.ref_id,
1265-
field_data.scope);
1260+
if let Some(field_data) = self.save_ctxt.get_expr_data(ex) {
1261+
down_cast_data!(field_data, VariableRefData, self, ex.span);
1262+
self.fmt.ref_str(recorder::VarRef,
1263+
ex.span,
1264+
Some(field_data.span),
1265+
field_data.ref_id,
1266+
field_data.scope);
1267+
}
12661268
},
12671269
ast::ExprTupField(ref sub_ex, idx) => {
12681270
if generated_code(sub_ex.span) {

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
329329
})
330330
}
331331

332-
pub fn get_expr_data(&self, expr: &ast::Expr) -> Data {
332+
pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
333333
match expr.node {
334334
ast::ExprField(ref sub_ex, ident) => {
335335
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, &sub_ex).sty;
@@ -339,12 +339,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
339339
for f in &fields {
340340
if f.name == ident.node.name {
341341
let sub_span = self.span_utils.span_for_last_ident(expr.span);
342-
return Data::VariableRefData(VariableRefData {
342+
return Some(Data::VariableRefData(VariableRefData {
343343
name: get_ident(ident.node).to_string(),
344344
span: sub_span.unwrap(),
345345
scope: self.analysis.ty_cx.map.get_parent(expr.id),
346346
ref_id: f.id,
347-
});
347+
}));
348348
}
349349
}
350350

@@ -353,24 +353,28 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
353353
&get_ident(ident.node),
354354
ty))
355355
}
356-
_ => self.sess.span_bug(expr.span,
357-
&format!("Expected struct type, found {:?}", ty)),
356+
_ => {
357+
debug!("Expected struct type, found {:?}", ty);
358+
None
359+
}
358360
}
359361
}
360362
ast::ExprStruct(ref path, _, _) => {
361363
let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, expr).sty;
362364
match *ty {
363-
ty::ty_struct(def_id, _) => {
365+
ty::TyStruct(def_id, _) => {
364366
let sub_span = self.span_utils.span_for_last_ident(path.span);
365-
Data::TypeRefData(TypeRefData {
367+
Some(Data::TypeRefData(TypeRefData {
366368
span: sub_span.unwrap(),
367369
scope: self.analysis.ty_cx.map.get_parent(expr.id),
368370
ref_id: def_id,
369-
})
371+
}))
370372
}
371373
_ => {
372-
self.sess.span_bug(expr.span,
373-
&format!("expected ty_struct, found {:?}", ty));
374+
// FIXME ty could legitimately be a TyEnum, but then we will fail
375+
// later if we try to look up the fields.
376+
debug!("expected TyStruct, found {:?}", ty);
377+
None
374378
}
375379
}
376380
}

0 commit comments

Comments
 (0)