Avoid a FnPtr deconstruct-and-recreate.

This commit is contained in:
Nicholas Nethercote 2024-08-12 15:37:28 +10:00
parent 9e95a2b9a5
commit f4a3ed0243

View file

@ -986,10 +986,11 @@ where
safe: None, safe: None,
}) })
} }
ty::FnPtr(sig_tys, hdr) if offset.bytes() == 0 => { ty::FnPtr(..) if offset.bytes() == 0 => {
let fn_sig = sig_tys.with(hdr); tcx.layout_of(param_env.and(this.ty)).ok().map(|layout| PointeeInfo {
tcx.layout_of(param_env.and(Ty::new_fn_ptr(tcx, fn_sig))).ok().map(|layout| { size: layout.size,
PointeeInfo { size: layout.size, align: layout.align.abi, safe: None } align: layout.align.abi,
safe: None,
}) })
} }
ty::Ref(_, ty, mt) if offset.bytes() == 0 => { ty::Ref(_, ty, mt) if offset.bytes() == 0 => {