Skip to content

Commit

Permalink
Auto merge of rust-lang#133509 - Urgau:dangling_lint_perf, r=Noratrieb
Browse files Browse the repository at this point in the history
Recover some lost performence from rust-lang#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 rust-lang#132732 (comment)
cc `@Kobzol`
  • Loading branch information
bors committed Nov 27, 2024
2 parents 6b6a867 + b6c80a6 commit 66adeaf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/dangling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 66adeaf

Please sign in to comment.