From f4a3ed02439adb6b168e6979fcfef7dc2a9fc33a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 12 Aug 2024 15:37:28 +1000 Subject: [PATCH] Avoid a `FnPtr` deconstruct-and-recreate. --- compiler/rustc_middle/src/ty/layout.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 55511d0833ce..f16f4baf723e 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -986,10 +986,11 @@ fn ty_and_layout_pointee_info_at( safe: None, }) } - ty::FnPtr(sig_tys, hdr) if offset.bytes() == 0 => { - let fn_sig = sig_tys.with(hdr); - tcx.layout_of(param_env.and(Ty::new_fn_ptr(tcx, fn_sig))).ok().map(|layout| { - PointeeInfo { size: layout.size, align: layout.align.abi, safe: None } + ty::FnPtr(..) if offset.bytes() == 0 => { + tcx.layout_of(param_env.and(this.ty)).ok().map(|layout| PointeeInfo { + size: layout.size, + align: layout.align.abi, + safe: None, }) } ty::Ref(_, ty, mt) if offset.bytes() == 0 => {