about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUrgau <urgau@numericable.fr>2024-11-27 07:35:55 +0100
committerUrgau <urgau@numericable.fr>2024-11-27 07:35:55 +0100
commitb6c80a610fd075fe1f4c72972d19c8586a2a586e (patch)
tree7a3d5ef02e7d8126884768e7fb5e4332fd026ff0
parent9b040e92aa6d73c6c62ed1c12b59f40eed398aa4 (diff)
downloadrust-b6c80a610fd075fe1f4c72972d19c8586a2a586e.tar.gz
rust-b6c80a610fd075fe1f4c72972d19c8586a2a586e.zip
Avoid even more decoding if not absolutely necessary
-rw-r--r--compiler/rustc_lint/src/dangling.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/dangling.rs b/compiler/rustc_lint/src/dangling.rs
index 7b6e79f7137..7e298a9a63c 100644
--- a/compiler/rustc_lint/src/dangling.rs
+++ b/compiler/rustc_lint/src/dangling.rs
@@ -131,10 +131,10 @@ impl DanglingPointerSearcher<'_, '_> {
 fn lint_expr(cx: &LateContext<'_>, expr: &Expr<'_>) {
     if let ExprKind::MethodCall(method, receiver, _args, _span) = expr.kind
         && is_temporary_rvalue(receiver)
-        && let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
-        && cx.tcx.has_attr(fn_id, sym::rustc_as_ptr)
         && let ty = cx.typeck_results().expr_ty(receiver)
         && owns_allocation(cx.tcx, ty)
+        && let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
+        && cx.tcx.has_attr(fn_id, sym::rustc_as_ptr)
     {
         // FIXME: use `emit_node_lint` when `#[primary_span]` is added.
         cx.tcx.emit_node_span_lint(