Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,14 @@ impl<'tcx> CValue<'tcx> {
let (field_ptr, field_layout) = codegen_field(fx, ptr, None, layout, field);
CValue::by_ref(field_ptr, field_layout)
}
CValueInner::ByRef(_, Some(_)) => todo!(),
CValueInner::ByRef(ptr, Some(extra)) => {
let (field_ptr, field_layout) = codegen_field(fx, ptr, Some(extra), layout, field);
if fx.tcx.type_has_metadata(field_layout.ty, ty::TypingEnv::fully_monomorphized()) {
CValue::by_ref_unsized(field_ptr, extra, field_layout)
} else {
CValue::by_ref(field_ptr, field_layout)
}
}
Comment thread
bjorn3 marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -655,7 +662,26 @@ impl<'tcx> CPlace<'tcx> {
flags,
);
}
CValueInner::ByRef(_, Some(_)) => todo!(),
CValueInner::ByRef(from_ptr, Some(_extra)) => {
// Unsized values shouldn't normally be written into sized places. However,
// if this happens, we can still copy the sized prefix using the destination layout's fixed size.
Comment thread
bjorn3 marked this conversation as resolved.
Outdated
let from_addr = from_ptr.get_addr(fx);
let to_addr = to_ptr.get_addr(fx);
let src_layout = from.1;
let size = dst_layout.size.bytes();
let src_align = src_layout.align.bytes().try_into().unwrap_or(128);
let dst_align = dst_layout.align.bytes().try_into().unwrap_or(128);
fx.bcx.emit_small_memory_copy(
fx.target_config,
to_addr,
from_addr,
size,
dst_align,
src_align,
true,
flags,
);
}
}
}
}
Expand Down
Loading