Skip to content

Commit 10ce004

Browse files
committed
f misc fixes and better macro docs
1 parent 91e777e commit 10ce004

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lightning-macros/src/lib.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,33 @@ pub fn skip_legacy_fields(expr: TokenStream) -> TokenStream {
238238
res
239239
}
240240

241-
/// Scans an enum definition for fields initialized to `LDK_DROP_LEGACY_FIELD_DEFINITION` and drops
242-
/// that field.
241+
/// Scans an enum definition for fields initialized with `legacy` types and drops them.
242+
///
243+
/// This is used internally in LDK's TLV serialization logic and is not expected to be used by
244+
/// other crates.
245+
///
246+
/// Is expected to wrap a struct definition like
247+
/// ```ignore
248+
/// drop_legacy_field_definition!(Self {
249+
/// field1: _init_tlv_based_struct_field!(field1, option),
250+
/// field2: _init_tlv_based_struct_field!(field2, (legacy, u64, {}, {}))),
251+
/// })
252+
/// ```
253+
/// and will drop fields defined like `field2` with a type starting with `legacy`.
243254
#[proc_macro]
244255
pub fn drop_legacy_field_definition(expr: TokenStream) -> TokenStream {
245256
let mut st = if let Ok(parsed) = parse::<syn::Expr>(expr) {
246257
if let syn::Expr::Struct(st) = parsed {
247258
st
248259
} else {
249260
return (quote! {
250-
compile_error!("drop_legacy_field_definitions!() can only be used on struct expressions")
261+
compile_error!("drop_legacy_field_definition!() can only be used on struct expressions")
251262
})
252263
.into();
253264
}
254265
} else {
255266
return (quote! {
256-
compile_error!("drop_legacy_field_definitions!() can only be used on expressions")
267+
compile_error!("drop_legacy_field_definition!() can only be used on expressions")
257268
})
258269
.into();
259270
};

lightning/src/util/ser_macros.rs

-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ macro_rules! _run_legacy_tlv_read_logic {
475475
($field: ident, $fieldty: tt) => { }
476476
}
477477

478-
479478
/// Checks if `$val` matches `$type`.
480479
/// This is exported for use by other exported macros, do not use directly.
481480
#[doc(hidden)]

0 commit comments

Comments
 (0)