diff options
| author | Ben Kimock <kimockb@gmail.com> | 2024-05-08 17:21:06 -0400 |
|---|---|---|
| committer | Ben Kimock <kimockb@gmail.com> | 2024-05-08 17:21:06 -0400 |
| commit | 0ca1a94b2bd58d19a1bd492300abd5bffe5263fb (patch) | |
| tree | 34e4c1632e73fab8c0675ec755fdeae86ea8dd53 /compiler/rustc_lint/src/reference_casting.rs | |
| parent | c3202afa2865ad26ef407544c3768070bfed7bfe (diff) | |
| download | rust-0ca1a94b2bd58d19a1bd492300abd5bffe5263fb.tar.gz rust-0ca1a94b2bd58d19a1bd492300abd5bffe5263fb.zip | |
Handle field projections like slice indexing in invalid_reference_casting
Diffstat (limited to 'compiler/rustc_lint/src/reference_casting.rs')
| -rw-r--r-- | compiler/rustc_lint/src/reference_casting.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index 63d55a73a98..b80e90c25a3 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -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; } |
