diff options
| author | bors <bors@rust-lang.org> | 2024-11-27 21:19:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-27 21:19:54 +0000 |
| commit | 66adeaf46b7a646daeed29518ef76235fcdb9726 (patch) | |
| tree | aab55cde5a2a3e91e92ae055e72abb998ac56b88 | |
| parent | 6b6a867ae9eac4e78d041ac4ee84be1072a48cf7 (diff) | |
| parent | b6c80a610fd075fe1f4c72972d19c8586a2a586e (diff) | |
| download | rust-66adeaf46b7a646daeed29518ef76235fcdb9726.tar.gz rust-66adeaf46b7a646daeed29518ef76235fcdb9726.zip | |
Auto merge of #133509 - Urgau:dangling_lint_perf, r=Noratrieb
Recover some lost performence from #132732 This PR reorders some conditions in the `dangling_pointers_from_temporaries` lint to avoid some potentially expensive query call, in particular those who could involve some metadata decoding from disk. cc https://github.com/rust-lang/rust/pull/132732#issuecomment-2499990683 cc `@Kobzol`
| -rw-r--r-- | compiler/rustc_lint/src/dangling.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_lint/src/dangling.rs b/compiler/rustc_lint/src/dangling.rs index e3e51ba263d..7e298a9a63c 100644 --- a/compiler/rustc_lint/src/dangling.rs +++ b/compiler/rustc_lint/src/dangling.rs @@ -130,11 +130,11 @@ impl DanglingPointerSearcher<'_, '_> { fn lint_expr(cx: &LateContext<'_>, expr: &Expr<'_>) { if let ExprKind::MethodCall(method, receiver, _args, _span) = expr.kind - && let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) - && cx.tcx.has_attr(fn_id, sym::rustc_as_ptr) && is_temporary_rvalue(receiver) && 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( |
