Disabled broken Clone impl for unsized buffers

This commit is contained in:
Wouter 2016-12-08 16:17:51 +01:00
parent dc27941fe4
commit 9cda522d13

View File

@ -175,14 +175,19 @@ fn write_struct(doc: &parse::Spirv, struct_id: u32, members: &[u32]) -> String {
}
}
format!("#[repr(C)]\n\
pub struct {name} {{\n{members}\n}} /* total_size: {t:?} */\n\n\
impl Clone for {name} {{\n fn clone(&self) -> Self {{\n \
{name} {{\n{copies}\n }}\n }}\n}}\n\n",
// We can only implement Clone if there's no unsized member in the struct.
let impl_text = if current_rust_offset.is_some() {
format!("\nimpl Clone for {name} {{\n fn clone(&self) -> Self {{\n \
{name} {{\n{copies}\n }}\n }}\n}}\n", name = name,
copies = rust_members.iter().map(Member::copy_text).collect::<Vec<_>>().join(",\n"))
} else {
"".to_owned()
};
format!("#[repr(C)]\npub struct {name} {{\n{members}\n}} /* total_size: {t:?} */\n{impl_text}",
name = name,
members = rust_members.iter().map(Member::declaration_text).collect::<Vec<_>>().join(",\n"),
t = spirv_req_total_size,
copies = rust_members.iter().map(Member::copy_text).collect::<Vec<_>>().join(",\n"))
t = spirv_req_total_size, impl_text=impl_text)
}
/// Returns true if a `BuiltIn` decorator is applied on a struct member.