1
Fork 0

generalize adjust_from_tcx

This commit is contained in:
Strophox 2024-04-22 03:57:01 +02:00
parent 79734f1db8
commit 47e2cc2ea1

View file

@ -346,10 +346,10 @@ impl<Prov: Provenance, Bytes: AllocBytes> Allocation<Prov, (), Bytes> {
} }
} }
impl<Bytes: AllocBytes> Allocation<CtfeProvenance, (), Bytes> { impl Allocation {
/// Adjust allocation from the ones in `tcx` to a custom Machine instance /// Adjust allocation from the ones in `tcx` to a custom Machine instance
/// with a different `Provenance` and `Extra` type. /// with a different `Provenance`, `Extra` and `Byte` type.
pub fn adjust_from_tcx<Prov: Provenance, Extra, Err>( pub fn adjust_from_tcx<Prov: Provenance, Extra, Bytes: AllocBytes, Err>(
self, self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
extra: Extra, extra: Extra,
@ -371,7 +371,7 @@ impl<Bytes: AllocBytes> Allocation<CtfeProvenance, (), Bytes> {
} }
// Create allocation. // Create allocation.
Ok(Allocation { Ok(Allocation {
bytes, bytes: AllocBytes::from_bytes(Cow::from(&*bytes), self.align),
provenance: ProvenanceMap::from_presorted_ptrs(new_provenance), provenance: ProvenanceMap::from_presorted_ptrs(new_provenance),
init_mask: self.init_mask, init_mask: self.init_mask,
align: self.align, align: self.align,