mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Do not panic on tuple struct access out of bounds
This commit is contained in:
parent
c92630a04a
commit
f5a3efee88
@ -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(..) => {}
|
||||
|
@ -462,4 +462,7 @@ fn new(f: u32) -> Rls699 {
|
||||
|
||||
fn invalid_tuple_struct_access() {
|
||||
bar.0;
|
||||
|
||||
struct S;
|
||||
S.0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user