mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Do not panic on tuple struct access out of bounds
This commit is contained in:
@@ -1665,13 +1665,16 @@ fn visit_expr(&mut self, ex: &'l ast::Expr) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user