Skip to content

Commit

Permalink
Do not panic on tuple struct access out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkuu committed Mar 6, 2018
1 parent c92630a commit f5a3efe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/librustc_save_analysis/dump_visitor.rs
Expand Up @@ -1665,13 +1665,16 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
if !self.span.filter_generated(sub_span, ex.span) {
let span =
self.span_from_span(sub_span.expect("No span found for var ref"));
let ref_id =
::id_from_def_id(def.non_enum_variant().fields[idx.node].did);
self.dumper.dump_ref(Ref {
kind: RefKind::Variable,
span,
ref_id,
});
if let Some(field) = def.non_enum_variant().fields.get(idx.node) {
let ref_id = ::id_from_def_id(field.did);
self.dumper.dump_ref(Ref {
kind: RefKind::Variable,
span,
ref_id,
});
} else {
return;
}
}
}
ty::TyTuple(..) => {}
Expand Down
3 changes: 3 additions & 0 deletions src/test/run-make/save-analysis-fail/foo.rs
Expand Up @@ -462,4 +462,7 @@ fn new(f: u32) -> Rls699 {

fn invalid_tuple_struct_access() {
bar.0;

struct S;
S.0;
}

0 comments on commit f5a3efe

Please sign in to comment.