diff options
| author | bors <bors@rust-lang.org> | 2024-05-08 17:28:17 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-08 17:28:17 +0000 | 
| commit | c3202afa2865ad26ef407544c3768070bfed7bfe (patch) | |
| tree | 7dff11dffacbd6390ed39ea78e1db661f370ca92 /compiler/rustc_lint/src/reference_casting.rs | |
| parent | e3029d220f6843f9b83d35927ff20a86137d7ed0 (diff) | |
| parent | 5347652fdf6fb02c8defa245ba487df05274ef6c (diff) | |
| download | rust-c3202afa2865ad26ef407544c3768070bfed7bfe.tar.gz rust-c3202afa2865ad26ef407544c3768070bfed7bfe.zip | |
Auto merge of #124890 - matthiaskrgr:rollup-25iq88h, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #124548 (Handle normalization failure in `struct_tail_erasing_lifetimes`) - #124761 (Fix insufficient logic when searching for the underlying allocation) - #124864 (rustdoc: use stability, instead of features, to decide what to show) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_lint/src/reference_casting.rs')
| -rw-r--r-- | compiler/rustc_lint/src/reference_casting.rs | 7 | 
1 files changed, 7 insertions, 0 deletions
| diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index 9fed91f7262..63d55a73a98 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -199,6 +199,13 @@ fn is_cast_to_bigger_memory_layout<'tcx>( let e_alloc = cx.expr_or_init(e); let e_alloc = if let ExprKind::AddrOf(_, _, inner_expr) = e_alloc.kind { inner_expr } else { e_alloc }; + + // 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 { + return None; + } + let alloc_ty = cx.typeck_results().node_type(e_alloc.hir_id); // if we do not find it we bail out, as this may not be UB | 
