Do not panic on tuple struct access out of bounds

This commit is contained in:
Shotaro Yamada 2018-03-07 07:16:25 +09:00
parent c92630a04a
commit f5a3efee88
2 changed files with 13 additions and 7 deletions

View file

@ -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(..) => {}

View file

@ -462,4 +462,7 @@ fn new(f: u32) -> Rls699 {
fn invalid_tuple_struct_access() {
bar.0;
struct S;
S.0;
}