Check if named type requires a lifetime and conform if does

This commit is contained in:
Jakub Konka
2020-07-21 20:35:14 +02:00
committed by Pat Hickey
parent e500be829b
commit 5d8271286a
2 changed files with 12 additions and 1 deletions

View File

@@ -19,7 +19,14 @@ pub(super) fn define_struct(
let member_decls = s.members.iter().map(|m| {
let name = names.struct_member(&m.name);
let type_ = match &m.tref {
witx::TypeRef::Name(nt) => names.type_(&nt.name),
witx::TypeRef::Name(nt) => {
let tt = names.type_(&nt.name);
if m.tref.needs_lifetime() {
quote!(#tt<'a>)
} else {
quote!(#tt)
}
},
witx::TypeRef::Value(ty) => match &**ty {
witx::Type::Builtin(builtin) => names.builtin_type(*builtin, quote!('a)),
witx::Type::Pointer(pointee) | witx::Type::ConstPointer(pointee) => {

View File

@@ -52,6 +52,10 @@ impl<'a> structs::Structs for WasiCtx<'a> {
second: *second,
})
}
fn sum_array<'b>(&self, an_arr: &types::StructOfArray<'b>) -> Result<u16, types::Errno> {
Ok(0)
}
}
#[derive(Debug)]