about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/reference_casting.rs
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2023-12-12 20:06:28 +0100
committerUrgau <urgau@numericable.fr>2023-12-14 17:27:14 +0100
commit4839cca9aaa7452c07c4ead76eeea8879e41b0cf (patch)
treee96cbfde93fa608ae8c429ce2bc1d897038598ee /compiler/rustc_lint/src/reference_casting.rs
parent97a26138e902aae4fac141d52cc1b8256805caec (diff)
downloadrust-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.rs7
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;
+            }
         };
     }