Fix unused_mut warning under --cfg=c_bindings
What changed, and why it matters
This commit is a minor code cleanup that removes a Rust compiler warning. It changes how a macro handles the `mut` keyword so that one version of the code no longer triggers an 'unused_mut' warning when compiled with a specific configuration flag. There is no functional change and no security impact.
No action required. This is a warning-suppression cleanup with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies the offer_explicit_metadata_builder_methods! macro in lightning/src/offers/offer.rs to accept an optional mut token. The macro invocation for OfferBuilder<ExplicitMetadata, ...> now passes mut, while the invocation for OfferBuilder<DerivedMetadata, ...> does not. This suppresses the unused_mut warning under --cfg=c_bindings without changing behavior.
Changed components
lightning/src/offers/offer.rsInspect captured patch +3 / −3
diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs
index cbea8e3..7ad3c28 100644
--- a/lightning/src/offers/offer.rs
+++ b/lightning/src/offers/offer.rs
@@ -220,7 +220,7 @@ impl MetadataStrategy for DerivedMetadata {}
macro_rules! offer_explicit_metadata_builder_methods {
(
- $self: ident, $self_type: ty, $return_type: ty, $return_value: expr
+ $self: ident, $self_type: ty, $return_type: ty, $return_value: expr $(, $mut: tt)?
) => {
/// Creates a new builder for an offer using the `signing_pubkey` for signing invoices. The
/// associated secret key must be remembered while the offer is valid.
@@ -259,7 +259,7 @@ macro_rules! offer_explicit_metadata_builder_methods {
///
/// Successive calls to this method will override the previous setting.
pub fn metadata(
- mut $self: $self_type, metadata: Vec<u8>,
+ $($mut)? $self: $self_type, metadata: Vec<u8>,
) -> Result<$return_type, Bolt12SemanticError> {
$self.offer.metadata = Some(Metadata::Bytes(metadata));
Ok($return_value)
@@ -523,7 +523,7 @@ impl<'a, M: MetadataStrategy, T: secp256k1::Signing> OfferBuilder<'a, M, T> {
}
impl<'a> OfferBuilder<'a, ExplicitMetadata, secp256k1::SignOnly> {
- offer_explicit_metadata_builder_methods!(self, Self, Self, self);
+ offer_explicit_metadata_builder_methods!(self, Self, Self, self, mut);
}
impl<'a, T: secp256k1::Signing> OfferBuilder<'a, DerivedMetadata, T> {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.