Skip to content

Commit 66adeaf

Browse files
committed
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 #132732 (comment) cc `@Kobzol`
2 parents 6b6a867 + b6c80a6 commit 66adeaf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/rustc_lint/src/dangling.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ impl DanglingPointerSearcher<'_, '_> {
130130

131131
fn lint_expr(cx: &LateContext<'_>, expr: &Expr<'_>) {
132132
if let ExprKind::MethodCall(method, receiver, _args, _span) = expr.kind
133-
&& let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
134-
&& cx.tcx.has_attr(fn_id, sym::rustc_as_ptr)
135133
&& is_temporary_rvalue(receiver)
136134
&& let ty = cx.typeck_results().expr_ty(receiver)
137135
&& owns_allocation(cx.tcx, ty)
136+
&& let Some(fn_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id)
137+
&& cx.tcx.has_attr(fn_id, sym::rustc_as_ptr)
138138
{
139139
// FIXME: use `emit_node_lint` when `#[primary_span]` is added.
140140
cx.tcx.emit_node_span_lint(

0 commit comments

Comments
 (0)