Emit declarative LayoutMeta from the node macro into registry entries

This commit is contained in:
Dennis Kobert
2026-08-11 20:08:45 +00:00
parent 557f8020bb
commit b6f73b0691
5 changed files with 89 additions and 0 deletions

View File

@@ -1741,6 +1741,23 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
}
},
};
let layout_meta_fn = format_ident!("{}_layout_meta", fn_name);
let carrier_present = !shape.skips_carrier();
let element_spec = match &shape.element_write {
Some(ty) => quote!(#core_types::record::ElementSpec::Concrete(#core_types::record::element_write::<#ty>())),
None => quote!(#core_types::record::ElementSpec::Carried),
};
let layout_meta_def = quote! {
#vis fn #layout_meta_fn() -> #core_types::record::LayoutMeta {
#core_types::record::LayoutMeta {
carrier: #carrier_present,
element: #element_spec,
writes: ::std::vec![#(#write_descs),*],
removes: ::std::vec![#(#remove_pairs),*],
level_delta: 0,
}
}
};
let reading_secondaries = reading_secondary_indices(&regular_fields, shape);
let edge_args = regular_fields.iter().zip(&node_generics).map(|(field, generic)| {
let name = &field.pat_ident.ident;
@@ -1790,6 +1807,7 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
let write_names = (0..shape.write_markers.len()).map(|index| format_ident!("__write_{index}")).map(|slot| quote!(#slot,));
quote! {
#layout_def
#layout_meta_def
#[automatically_derived]
impl<#(#data_field_generic_idents,)* #(#node_generics,)*> #mod_name::#struct_name<#(#struct_type_params,)*> {