Skip to content

Commit c89901e

Browse files
committed
f - fixed unused mut warnings in c_bindings
1 parent c000dfc commit c89901e

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

lightning/src/offers/invoice_request.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ macro_rules! invoice_request_derived_payer_id_builder_methods { (
224224
} }
225225

226226
macro_rules! invoice_request_builder_methods { (
227-
$self: ident, $self_type: ty, $return_type: ty, $return_value: expr, $secp_context: ty
227+
$self: ident, $self_type: ty, $return_type: ty, $return_value: expr, $secp_context: ty $(, $self_mut: tt)?
228228
) => {
229229
fn create_contents(offer: &Offer, metadata: Metadata) -> InvoiceRequestContentsWithoutPayerId {
230230
let offer = offer.contents.clone();
@@ -248,7 +248,7 @@ macro_rules! invoice_request_builder_methods { (
248248
/// offer.
249249
///
250250
/// Successive calls to this method will override the previous setting.
251-
pub(crate) fn chain_hash(mut $self: $self_type, chain: ChainHash) -> Result<$return_type, Bolt12SemanticError> {
251+
pub(crate) fn chain_hash($($self_mut)* $self: $self_type, chain: ChainHash) -> Result<$return_type, Bolt12SemanticError> {
252252
if !$self.offer.supports_chain(chain) {
253253
return Err(Bolt12SemanticError::UnsupportedChain);
254254
}
@@ -263,7 +263,7 @@ macro_rules! invoice_request_builder_methods { (
263263
/// Successive calls to this method will override the previous setting.
264264
///
265265
/// [`quantity`]: Self::quantity
266-
pub fn amount_msats(mut $self: $self_type, amount_msats: u64) -> Result<$return_type, Bolt12SemanticError> {
266+
pub fn amount_msats($($self_mut)* $self: $self_type, amount_msats: u64) -> Result<$return_type, Bolt12SemanticError> {
267267
$self.invoice_request.offer.check_amount_msats_for_quantity(
268268
Some(amount_msats), $self.invoice_request.quantity
269269
)?;
@@ -275,7 +275,7 @@ macro_rules! invoice_request_builder_methods { (
275275
/// does not conform to [`Offer::is_valid_quantity`].
276276
///
277277
/// Successive calls to this method will override the previous setting.
278-
pub fn quantity(mut $self: $self_type, quantity: u64) -> Result<$return_type, Bolt12SemanticError> {
278+
pub fn quantity($($self_mut)* $self: $self_type, quantity: u64) -> Result<$return_type, Bolt12SemanticError> {
279279
$self.invoice_request.offer.check_quantity(Some(quantity))?;
280280
$self.invoice_request.quantity = Some(quantity);
281281
Ok($return_value)
@@ -284,12 +284,12 @@ macro_rules! invoice_request_builder_methods { (
284284
/// Sets the [`InvoiceRequest::payer_note`].
285285
///
286286
/// Successive calls to this method will override the previous setting.
287-
pub fn payer_note(mut $self: $self_type, payer_note: String) -> $return_type {
287+
pub fn payer_note($($self_mut)* $self: $self_type, payer_note: String) -> $return_type {
288288
$self.invoice_request.payer_note = Some(payer_note);
289289
$return_value
290290
}
291291

292-
fn build_with_checks(mut $self: $self_type) -> Result<
292+
fn build_with_checks($($self_mut)* $self: $self_type) -> Result<
293293
(UnsignedInvoiceRequest, Option<KeyPair>, Option<&'b Secp256k1<$secp_context>>),
294294
Bolt12SemanticError
295295
> {
@@ -320,7 +320,7 @@ macro_rules! invoice_request_builder_methods { (
320320
Ok($self.build_without_checks())
321321
}
322322

323-
fn build_without_checks(mut $self: $self_type) ->
323+
fn build_without_checks($($self_mut)* $self: $self_type) ->
324324
(UnsignedInvoiceRequest, Option<KeyPair>, Option<&'b Secp256k1<$secp_context>>)
325325
{
326326
// Create the metadata for stateless verification of a Bolt12Invoice.
@@ -366,25 +366,25 @@ macro_rules! invoice_request_builder_methods { (
366366

367367
#[cfg(test)]
368368
macro_rules! invoice_request_builder_test_methods { (
369-
$self: ident, $self_type: ty, $return_type: ty, $return_value: expr
369+
$self: ident, $self_type: ty, $return_type: ty, $return_value: expr $(, $self_mut: tt)?
370370
) => {
371-
fn chain_unchecked(mut $self: $self_type, network: Network) -> $return_type {
371+
fn chain_unchecked($($self_mut)* $self: $self_type, network: Network) -> $return_type {
372372
let chain = ChainHash::using_genesis_block(network);
373373
$self.invoice_request.chain = Some(chain);
374374
$return_value
375375
}
376376

377-
fn amount_msats_unchecked(mut $self: $self_type, amount_msats: u64) -> $return_type {
377+
fn amount_msats_unchecked($($self_mut)* $self: $self_type, amount_msats: u64) -> $return_type {
378378
$self.invoice_request.amount_msats = Some(amount_msats);
379379
$return_value
380380
}
381381

382-
fn features_unchecked(mut $self: $self_type, features: InvoiceRequestFeatures) -> $return_type {
382+
fn features_unchecked($($self_mut)* $self: $self_type, features: InvoiceRequestFeatures) -> $return_type {
383383
$self.invoice_request.features = features;
384384
$return_value
385385
}
386386

387-
fn quantity_unchecked(mut $self: $self_type, quantity: u64) -> $return_type {
387+
fn quantity_unchecked($($self_mut)* $self: $self_type, quantity: u64) -> $return_type {
388388
$self.invoice_request.quantity = Some(quantity);
389389
$return_value
390390
}
@@ -403,10 +403,10 @@ impl<'a, 'b, T: secp256k1::Signing> InvoiceRequestBuilder<'a, 'b, DerivedPayerId
403403
}
404404

405405
impl<'a, 'b, P: PayerIdStrategy, T: secp256k1::Signing> InvoiceRequestBuilder<'a, 'b, P, T> {
406-
invoice_request_builder_methods!(self, Self, Self, self, T);
406+
invoice_request_builder_methods!(self, Self, Self, self, T, mut);
407407

408408
#[cfg(test)]
409-
invoice_request_builder_test_methods!(self, Self, Self, self);
409+
invoice_request_builder_test_methods!(self, Self, Self, self, mut);
410410
}
411411

412412
#[cfg(all(c_bindings, not(test)))]
@@ -498,13 +498,15 @@ impl UnsignedInvoiceRequest {
498498
}
499499
}
500500

501-
macro_rules! unsigned_invoice_request_sign_method { ($self: ident, $self_type: ty) => {
501+
macro_rules! unsigned_invoice_request_sign_method { (
502+
$self: ident, $self_type: ty $(, $self_mut: tt)?
503+
) => {
502504
/// Signs the [`TaggedHash`] of the invoice request using the given function.
503505
///
504506
/// Note: The hash computation may have included unknown, odd TLV records.
505507
///
506508
/// This is not exported to bindings users as functions are not yet mapped.
507-
pub fn sign<F, E>(mut $self: $self_type, sign: F) -> Result<InvoiceRequest, SignError<E>>
509+
pub fn sign<F, E>($($self_mut)* $self: $self_type, sign: F) -> Result<InvoiceRequest, SignError<E>>
508510
where
509511
F: FnOnce(&Self) -> Result<Signature, E>
510512
{
@@ -533,7 +535,7 @@ macro_rules! unsigned_invoice_request_sign_method { ($self: ident, $self_type: t
533535

534536
#[cfg(not(c_bindings))]
535537
impl UnsignedInvoiceRequest {
536-
unsigned_invoice_request_sign_method!(self, Self);
538+
unsigned_invoice_request_sign_method!(self, Self, mut);
537539
}
538540

539541
#[cfg(c_bindings)]

0 commit comments

Comments
 (0)