Skip to content

Commit 0fd399c

Browse files
committed
f fix spurious unused var warning
1 parent 76c787d commit 0fd399c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/util/ser_macros.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,14 @@ macro_rules! _decode_and_build {
929929
$crate::_init_and_read_len_prefixed_tlv_fields!($stream, {
930930
$(($type, $field, $fieldty)),*
931931
});
932+
// rustc is kinda dumb about unused variable warnings when we declare a variable via an
933+
// ident in a macro and then use it in an expr also defined in the same macro call. Thus,
934+
// it may generate unused variable warnings for variables that are, in fact, very much
935+
// used. Instead, we just blanket ignore unused variables here as it may be useful to write
936+
// field names without a _ prefix for legacy fields even if we don't care about the read
937+
// value.
932938
$(
939+
#[allow(unused_variables)]
933940
let $field = $crate::_init_tlv_based_struct_field!($field, $fieldty);
934941
)*
935942
::lightning_macros::drop_legacy_field_definition!($thing {

0 commit comments

Comments
 (0)