diff options
| author | Urgau <urgau@numericable.fr> | 2023-12-12 20:06:28 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2023-12-14 17:27:14 +0100 |
| commit | 4839cca9aaa7452c07c4ead76eeea8879e41b0cf (patch) | |
| tree | e96cbfde93fa608ae8c429ce2bc1d897038598ee /compiler/rustc_lint/src/reference_casting.rs | |
| parent | 97a26138e902aae4fac141d52cc1b8256805caec (diff) | |
| download | rust-4839cca9aaa7452c07c4ead76eeea8879e41b0cf.tar.gz rust-4839cca9aaa7452c07c4ead76eeea8879e41b0cf.zip | |
Recurse into let bindings if possible in ref casting lint
Diffstat (limited to 'compiler/rustc_lint/src/reference_casting.rs')
| -rw-r--r-- | compiler/rustc_lint/src/reference_casting.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_lint/src/reference_casting.rs b/compiler/rustc_lint/src/reference_casting.rs index cba47315548..96290288f07 100644 --- a/compiler/rustc_lint/src/reference_casting.rs +++ b/compiler/rustc_lint/src/reference_casting.rs @@ -182,7 +182,12 @@ fn peel_casts<'tcx>(cx: &LateContext<'tcx>, mut e: &'tcx Expr<'tcx>) -> (&'tcx E } arg } else { - break; + let init = cx.expr_or_init(e); + if init.hir_id != e.hir_id { + init + } else { + break; + } }; } |
