diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-08-12 15:37:28 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-08-12 15:37:28 +1000 |
| commit | f4a3ed02439adb6b168e6979fcfef7dc2a9fc33a (patch) | |
| tree | e344b1420ec74d902bc8ee9a29de75bf75efb96b | |
| parent | 9e95a2b9a5c434db5ad42fe3f8848cbbd161e642 (diff) | |
| download | rust-f4a3ed02439adb6b168e6979fcfef7dc2a9fc33a.tar.gz rust-f4a3ed02439adb6b168e6979fcfef7dc2a9fc33a.zip | |
Avoid a `FnPtr` deconstruct-and-recreate.
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 55511d0833c..f16f4baf723 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -986,10 +986,11 @@ where 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 => { |
