Handle field projections like slice indexing in invalid_reference_casting

This commit is contained in:
Ben Kimock 2024-05-08 17:21:06 -04:00
parent c3202afa28
commit 0ca1a94b2b
2 changed files with 8 additions and 1 deletions

View file

@ -202,7 +202,8 @@ fn is_cast_to_bigger_memory_layout<'tcx>(
// if the current expr looks like this `&mut expr[index]` then just looking
// at `expr[index]` won't give us the underlying allocation, so we just skip it
if let ExprKind::Index(..) = e_alloc.kind {
// the same logic applies field access like `&mut expr.field`
if let ExprKind::Index(..) | ExprKind::Field(..) = e_alloc.kind {
return None;
}