diff --git a/lightning-block-sync/src/lib.rs b/lightning-block-sync/src/lib.rs index 3f981cd8786..6cc8e2fcc36 100644 --- a/lightning-block-sync/src/lib.rs +++ b/lightning-block-sync/src/lib.rs @@ -49,7 +49,8 @@ use bitcoin::hash_types::BlockHash; use bitcoin::pow::Work; use lightning::chain; -use lightning::chain::Listen; +#[allow(unused_imports)] // This thinks trait imports are unused if they're use in macros :( +use lightning::chain::Listen as _; use std::future::Future; use std::ops::Deref; @@ -78,7 +79,7 @@ pub trait BlockSource: Sync + Send { /// to allow for a more efficient lookup. /// /// [`get_header`]: Self::get_header - fn get_best_block(&self) -> AsyncBlockSourceResult<(BlockHash, Option)>; + fn get_best_block(&self) -> AsyncBlockSourceResult<'_, (BlockHash, Option)>; } /// Result type for `BlockSource` requests. diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index b814210b390..9e330a97813 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -1146,7 +1146,7 @@ impl RawBolt11Invoice { /// This is not exported to bindings users as there is not yet a manual mapping for a FilterMap pub fn known_tagged_fields( &self, - ) -> FilterMap, fn(&RawTaggedField) -> Option<&TaggedField>> { + ) -> FilterMap, fn(&RawTaggedField) -> Option<&TaggedField>> { // For 1.14.0 compatibility: closures' types can't be written an fn()->() in the // function's type signature. // TODO: refactor once impl Trait is available @@ -1468,7 +1468,7 @@ impl Bolt11Invoice { /// This is not exported to bindings users as there is not yet a manual mapping for a FilterMap pub fn tagged_fields( &self, - ) -> FilterMap, fn(&RawTaggedField) -> Option<&TaggedField>> { + ) -> FilterMap, fn(&RawTaggedField) -> Option<&TaggedField>> { self.signed_invoice.raw_invoice().known_tagged_fields() } @@ -1480,7 +1480,7 @@ impl Bolt11Invoice { /// Return the description or a hash of it for longer ones /// /// This is not exported to bindings users because we don't yet export Bolt11InvoiceDescription - pub fn description(&self) -> Bolt11InvoiceDescriptionRef { + pub fn description(&self) -> Bolt11InvoiceDescriptionRef<'_> { if let Some(direct) = self.signed_invoice.description() { return Bolt11InvoiceDescriptionRef::Direct(direct); } else if let Some(hash) = self.signed_invoice.description_hash() { diff --git a/lightning-liquidity/src/events/event_queue.rs b/lightning-liquidity/src/events/event_queue.rs index a2589beb4e2..f59d34ed34a 100644 --- a/lightning-liquidity/src/events/event_queue.rs +++ b/lightning-liquidity/src/events/event_queue.rs @@ -67,7 +67,7 @@ impl EventQueue { } // Returns an [`EventQueueNotifierGuard`] that will notify about new event when dropped. - pub fn notifier(&self) -> EventQueueNotifierGuard { + pub fn notifier(&self) -> EventQueueNotifierGuard<'_> { EventQueueNotifierGuard(self) } } diff --git a/lightning-liquidity/src/message_queue.rs b/lightning-liquidity/src/message_queue.rs index 45b3c7f48af..2e99d545438 100644 --- a/lightning-liquidity/src/message_queue.rs +++ b/lightning-liquidity/src/message_queue.rs @@ -33,7 +33,7 @@ impl MessageQueue { self.pending_msgs_notifier.get_future() } - pub(crate) fn notifier(&self) -> MessageQueueNotifierGuard { + pub(crate) fn notifier(&self) -> MessageQueueNotifierGuard<'_> { MessageQueueNotifierGuard { msg_queue: self, buffer: VecDeque::new() } } } diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 0de372813b3..58770d64e2f 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -33,7 +33,9 @@ use crate::chain::channelmonitor::{ WithChannelMonitor, }; use crate::chain::transaction::{OutPoint, TransactionData}; -use crate::chain::{ChannelMonitorUpdateStatus, Filter, WatchedOutput}; +#[allow(unused_imports)] // This thinks trait imports are unused if they're use in macros :( +use crate::chain::Filter as _; +use crate::chain::{ChannelMonitorUpdateStatus, WatchedOutput}; use crate::events::{self, Event, EventHandler, ReplayEvent}; use crate::ln::channel_state::ChannelDetails; use crate::ln::msgs::{self, BaseMessageHandler, Init, MessageSendEvent, SendOnlyMessageHandler}; diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index c7011af43a9..7738fd218ee 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -42,7 +42,8 @@ use crate::chain::package::{ HolderHTLCOutput, PackageSolvingData, PackageTemplate, RevokedHTLCOutput, RevokedOutput, }; use crate::chain::transaction::{OutPoint, TransactionData}; -use crate::chain::Filter; +#[allow(unused_imports)] // This thinks trait imports are unused if they're use in macros :( +use crate::chain::Filter as _; use crate::chain::{BestBlock, WatchedOutput}; use crate::events::bump_transaction::{AnchorDescriptor, BumpTransactionEvent}; use crate::events::{ClosureReason, Event, EventHandler, ReplayEvent}; diff --git a/lightning/src/ln/blinded_payment_tests.rs b/lightning/src/ln/blinded_payment_tests.rs index d72c816cba9..0631db3d408 100644 --- a/lightning/src/ln/blinded_payment_tests.rs +++ b/lightning/src/ln/blinded_payment_tests.rs @@ -453,7 +453,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) { HTLCHandlingFailureType::Forward { node_id: Some(nodes[2].node.get_our_node_id()), channel_id: chan_1_2.2 }, }; expect_htlc_handling_failed_destinations!( - nodes[1].node.get_and_clear_pending_events(), &[failed_destination.clone()] + nodes[1].node.get_and_clear_pending_events(), core::slice::from_ref(&failed_destination) ); match check { ForwardCheckFail::ForwardPayloadEncodedAsReceive => { @@ -484,7 +484,7 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) { HTLCHandlingFailureType::Forward { node_id: Some(nodes[3].node.get_our_node_id()), channel_id: chan_2_3.2 }, }; expect_htlc_handling_failed_destinations!( - nodes[2].node.get_and_clear_pending_events(), &[failed_destination.clone()] + nodes[2].node.get_and_clear_pending_events(), core::slice::from_ref(&failed_destination) ); check_added_monitors!(nodes[2], 1); diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs index 557a988cc92..5518a75cb81 100644 --- a/lightning/src/ln/chan_utils.rs +++ b/lightning/src/ln/chan_utils.rs @@ -1035,7 +1035,7 @@ impl ChannelTransactionParameters { /// /// self.is_populated() must be true before calling this function. #[rustfmt::skip] - pub fn as_holder_broadcastable(&self) -> DirectedChannelTransactionParameters { + pub fn as_holder_broadcastable(&self) -> DirectedChannelTransactionParameters<'_> { assert!(self.is_populated(), "self.late_parameters must be set before using as_holder_broadcastable"); DirectedChannelTransactionParameters { inner: self, @@ -1048,7 +1048,7 @@ impl ChannelTransactionParameters { /// /// self.is_populated() must be true before calling this function. #[rustfmt::skip] - pub fn as_counterparty_broadcastable(&self) -> DirectedChannelTransactionParameters { + pub fn as_counterparty_broadcastable(&self) -> DirectedChannelTransactionParameters<'_> { assert!(self.is_populated(), "self.late_parameters must be set before using as_counterparty_broadcastable"); DirectedChannelTransactionParameters { inner: self, @@ -1435,7 +1435,7 @@ impl ClosingTransaction { /// /// This should only be used if you fully trust the builder of this object. It should not /// be used by an external signer - instead use the verify function. - pub fn trust(&self) -> TrustedClosingTransaction { + pub fn trust(&self) -> TrustedClosingTransaction<'_> { TrustedClosingTransaction { inner: self } } @@ -1446,7 +1446,7 @@ impl ClosingTransaction { /// An external validating signer must call this method before signing /// or using the built transaction. #[rustfmt::skip] - pub fn verify(&self, funding_outpoint: OutPoint) -> Result { + pub fn verify(&self, funding_outpoint: OutPoint) -> Result, ()> { let built = build_closing_transaction( self.to_holder_value_sat, self.to_counterparty_value_sat, self.to_holder_script.clone(), self.to_counterparty_script.clone(), @@ -1971,7 +1971,7 @@ impl CommitmentTransaction { /// /// This should only be used if you fully trust the builder of this object. It should not /// be used by an external signer - instead use the verify function. - pub fn trust(&self) -> TrustedCommitmentTransaction { + pub fn trust(&self) -> TrustedCommitmentTransaction<'_> { TrustedCommitmentTransaction { inner: self } } @@ -1982,7 +1982,7 @@ impl CommitmentTransaction { /// An external validating signer must call this method before signing /// or using the built transaction. #[rustfmt::skip] - pub fn verify(&self, channel_parameters: &DirectedChannelTransactionParameters, secp_ctx: &Secp256k1) -> Result { + pub fn verify(&self, channel_parameters: &DirectedChannelTransactionParameters, secp_ctx: &Secp256k1) -> Result, ()> { // This is the only field of the key cache that we trust let per_commitment_point = &self.keys.per_commitment_point; let keys = TxCreationKeys::from_channel_static_keys(per_commitment_point, channel_parameters.broadcaster_pubkeys(), channel_parameters.countersignatory_pubkeys(), secp_ctx); diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index b5cf6f3ea9c..bd4cdcd4a18 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -4534,7 +4534,7 @@ where /// which peer generated this transaction and "to whom" this transaction flows. #[inline] #[rustfmt::skip] - fn build_commitment_transaction(&self, funding: &FundingScope, commitment_number: u64, per_commitment_point: &PublicKey, local: bool, generated_by_local: bool, logger: &L) -> CommitmentData + fn build_commitment_transaction(&self, funding: &FundingScope, commitment_number: u64, per_commitment_point: &PublicKey, local: bool, generated_by_local: bool, logger: &L) -> CommitmentData<'_> where L::Target: Logger { let broadcaster_dust_limit_sat = if local { self.holder_dust_limit_satoshis } else { self.counterparty_dust_limit_satoshis }; @@ -11817,7 +11817,7 @@ where } } - pub fn remove_legacy_scids_before_block(&mut self, height: u32) -> alloc::vec::Drain { + pub fn remove_legacy_scids_before_block(&mut self, height: u32) -> alloc::vec::Drain<'_, u64> { let end = self .funding .get_short_channel_id() @@ -14192,6 +14192,7 @@ mod tests { ); } + #[allow(dead_code)] struct Keys { signer: InMemorySigner, } diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 1fd99f89451..455f3e9e6d9 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -50,7 +50,9 @@ use crate::chain::channelmonitor::{ LATENCY_GRACE_PERIOD_BLOCKS, MAX_BLOCKS_FOR_CONF, }; use crate::chain::transaction::{OutPoint, TransactionData}; -use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Watch}; +#[allow(unused_imports)] // This thinks trait imports are unused if they're use in macros :( +use crate::chain::Watch as _; +use crate::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm}; use crate::events::{ self, ClosureReason, Event, EventHandler, EventsProvider, HTLCHandlingFailureType, InboundChannelFunds, PaymentFailureReason, ReplayEvent, @@ -11897,9 +11899,9 @@ where L::Target: Logger, { #[cfg(not(c_bindings))] - create_offer_builder!(self, OfferBuilder); + create_offer_builder!(self, OfferBuilder<'_, DerivedMetadata, secp256k1::All>); #[cfg(not(c_bindings))] - create_refund_builder!(self, RefundBuilder); + create_refund_builder!(self, RefundBuilder<'_, secp256k1::All>); #[cfg(c_bindings)] create_offer_builder!(self, OfferWithDerivedMetadataBuilder); diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 00e883e8561..b14b2287f9b 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -718,7 +718,7 @@ pub trait NodeHolder { ::MR, ::L, >; - fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor>; + fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor<'_>>; } impl NodeHolder for &H { type CM = H::CM; @@ -737,7 +737,7 @@ impl NodeHolder for &H { > { (*self).node() } - fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor> { + fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor<'_>> { (*self).chain_monitor() } } @@ -746,7 +746,7 @@ impl<'a, 'b: 'a, 'c: 'b> NodeHolder for Node<'a, 'b, 'c> { fn node(&self) -> &TestChannelManager<'b, 'c> { &self.node } - fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor> { + fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor<'_>> { Some(self.chain_monitor) } } diff --git a/lightning/src/ln/payment_tests.rs b/lightning/src/ln/payment_tests.rs index b11294f1158..4c63bfa4f8e 100644 --- a/lightning/src/ln/payment_tests.rs +++ b/lightning/src/ln/payment_tests.rs @@ -3581,7 +3581,7 @@ fn no_extra_retries_on_back_to_back_fail() { expect_and_process_pending_htlcs(&nodes[1], false); expect_htlc_handling_failed_destinations!( nodes[1].node.get_and_clear_pending_events(), - &[next_hop_failure.clone()] + core::slice::from_ref(&next_hop_failure) ); check_added_monitors(&nodes[1], 1); @@ -3755,7 +3755,7 @@ fn test_simple_partial_retry() { HTLCHandlingFailureType::Forward { node_id: Some(node_c_id), channel_id: chan_2.2 }; expect_htlc_handling_failed_destinations!( nodes[1].node.get_and_clear_pending_events(), - &[next_hop_failure.clone()] + core::slice::from_ref(&next_hop_failure) ); check_added_monitors(&nodes[1], 2); @@ -4247,7 +4247,10 @@ fn do_claim_from_closed_chan(fail_payment: bool) { // We fail the HTLC on the A->B->D path first as it expires 4 blocks earlier. We go ahead // and expire both immediately, though, by connecting another 4 blocks. let reason = HTLCHandlingFailureType::Receive { payment_hash: hash }; - expect_and_process_pending_htlcs_and_htlc_handling_failed(&nodes[3], &[reason.clone()]); + expect_and_process_pending_htlcs_and_htlc_handling_failed( + &nodes[3], + core::slice::from_ref(&reason), + ); connect_blocks(&nodes[3], 4); expect_and_process_pending_htlcs_and_htlc_handling_failed(&nodes[3], &[reason]); diff --git a/lightning/src/offers/flow.rs b/lightning/src/offers/flow.rs index cd3f95e0841..81c1c33a991 100644 --- a/lightning/src/offers/flow.rs +++ b/lightning/src/offers/flow.rs @@ -525,7 +525,7 @@ where fn create_offer_builder_intern( &self, entropy_source: ES, make_paths: PF, - ) -> Result<(OfferBuilder, Nonce), Bolt12SemanticError> + ) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError> where ES::Target: EntropySource, PF: FnOnce( @@ -580,7 +580,7 @@ where /// [`DefaultMessageRouter`]: crate::onion_message::messenger::DefaultMessageRouter pub fn create_offer_builder( &self, entropy_source: ES, peers: Vec, - ) -> Result, Bolt12SemanticError> + ) -> Result, Bolt12SemanticError> where ES::Target: EntropySource, { @@ -601,7 +601,7 @@ where /// See [`Self::create_offer_builder`] for more details on usage. pub fn create_offer_builder_using_router( &self, router: ME, entropy_source: ES, peers: Vec, - ) -> Result, Bolt12SemanticError> + ) -> Result, Bolt12SemanticError> where ME::Target: MessageRouter, ES::Target: EntropySource, @@ -627,7 +627,7 @@ where #[cfg(async_payments)] pub fn create_async_receive_offer_builder( &self, entropy_source: ES, message_paths_to_always_online_node: Vec, - ) -> Result<(OfferBuilder, Nonce), Bolt12SemanticError> + ) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError> where ES::Target: EntropySource, { @@ -639,7 +639,7 @@ where fn create_refund_builder_intern( &self, entropy_source: ES, make_paths: PF, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId, - ) -> Result, Bolt12SemanticError> + ) -> Result, Bolt12SemanticError> where ES::Target: EntropySource, PF: FnOnce( @@ -712,7 +712,7 @@ where pub fn create_refund_builder( &self, entropy_source: ES, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId, peers: Vec, - ) -> Result, Bolt12SemanticError> + ) -> Result, Bolt12SemanticError> where ES::Target: EntropySource, { @@ -751,7 +751,7 @@ where pub fn create_refund_builder_using_router( &self, router: ME, entropy_source: ES, amount_msats: u64, absolute_expiry: Duration, payment_id: PaymentId, peers: Vec, - ) -> Result, Bolt12SemanticError> + ) -> Result, Bolt12SemanticError> where ME::Target: MessageRouter, ES::Target: EntropySource, diff --git a/lightning/src/offers/invoice.rs b/lightning/src/offers/invoice.rs index 198e544fefc..9751f52b046 100644 --- a/lightning/src/offers/invoice.rs +++ b/lightning/src/offers/invoice.rs @@ -836,7 +836,7 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// From [`Offer::description`] or [`Refund::description`]. /// /// [`Offer::description`]: crate::offers::offer::Offer::description - pub fn description(&$self) -> Option { + pub fn description(&$self) -> Option> { $contents.description() } @@ -854,7 +854,7 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// From [`Offer::issuer`] or [`Refund::issuer`]. /// /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer - pub fn issuer(&$self) -> Option { + pub fn issuer(&$self) -> Option> { $contents.issuer() } @@ -919,7 +919,7 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// A payer-provided note reflected back in the invoice. /// /// From [`InvoiceRequest::payer_note`] or [`Refund::payer_note`]. - pub fn payer_note(&$self) -> Option { + pub fn payer_note(&$self) -> Option> { $contents.payer_note() } @@ -1019,7 +1019,7 @@ impl Bolt12Invoice { ) } - pub(crate) fn as_tlv_stream(&self) -> FullInvoiceTlvStreamRef { + pub(crate) fn as_tlv_stream(&self) -> FullInvoiceTlvStreamRef<'_> { let ( payer_tlv_stream, offer_tlv_stream, @@ -1127,7 +1127,7 @@ impl InvoiceContents { } } - fn description(&self) -> Option { + fn description(&self) -> Option> { match self { InvoiceContents::ForOffer { invoice_request, .. } => { invoice_request.inner.offer.description() @@ -1154,7 +1154,7 @@ impl InvoiceContents { } } - fn issuer(&self) -> Option { + fn issuer(&self) -> Option> { match self { InvoiceContents::ForOffer { invoice_request, .. } => { invoice_request.inner.offer.issuer() @@ -1220,7 +1220,7 @@ impl InvoiceContents { } } - fn payer_note(&self) -> Option { + fn payer_note(&self) -> Option> { match self { InvoiceContents::ForOffer { invoice_request, .. } => invoice_request.payer_note(), InvoiceContents::ForRefund { refund, .. } => refund.payer_note(), @@ -1315,7 +1315,7 @@ impl InvoiceContents { ) } - fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef { + fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef<'_> { let (payer, offer, invoice_request, experimental_offer, experimental_invoice_request) = match self { InvoiceContents::ForOffer { invoice_request, .. } => { @@ -1379,7 +1379,7 @@ pub(super) fn filter_fallbacks(chain: ChainHash, fallbacks: &Vec (InvoiceTlvStreamRef, ExperimentalInvoiceTlvStreamRef) { + fn as_tlv_stream(&self) -> (InvoiceTlvStreamRef<'_>, ExperimentalInvoiceTlvStreamRef) { let features = { if self.features == Bolt12InvoiceFeatures::empty() { None diff --git a/lightning/src/offers/invoice_request.rs b/lightning/src/offers/invoice_request.rs index dedbb27c674..27f32bcc1d2 100644 --- a/lightning/src/offers/invoice_request.rs +++ b/lightning/src/offers/invoice_request.rs @@ -688,7 +688,7 @@ macro_rules! invoice_request_accessors { ($self: ident, $contents: expr) => { /// A payer-provided note which will be seen by the recipient and reflected back in the invoice /// response. - pub fn payer_note(&$self) -> Option { + pub fn payer_note(&$self) -> Option> { $contents.payer_note() } @@ -854,7 +854,7 @@ impl InvoiceRequest { invoice_request_respond_with_explicit_signing_pubkey_methods!( self, self, - InvoiceBuilder + InvoiceBuilder<'_, ExplicitSigningPubkey> ); invoice_request_verify_method!(self, Self); @@ -889,7 +889,7 @@ impl InvoiceRequest { self.signature } - pub(crate) fn as_tlv_stream(&self) -> FullInvoiceRequestTlvStreamRef { + pub(crate) fn as_tlv_stream(&self) -> FullInvoiceRequestTlvStreamRef<'_> { let ( payer_tlv_stream, offer_tlv_stream, @@ -968,7 +968,7 @@ impl VerifiedInvoiceRequest { invoice_request_respond_with_explicit_signing_pubkey_methods!( self, self.inner, - InvoiceBuilder + InvoiceBuilder<'_, ExplicitSigningPubkey> ); #[cfg(c_bindings)] invoice_request_respond_with_explicit_signing_pubkey_methods!( @@ -980,7 +980,7 @@ impl VerifiedInvoiceRequest { invoice_request_respond_with_derived_signing_pubkey_methods!( self, self.inner, - InvoiceBuilder + InvoiceBuilder<'_, DerivedSigningPubkey> ); #[cfg(c_bindings)] invoice_request_respond_with_derived_signing_pubkey_methods!( @@ -1074,7 +1074,7 @@ impl InvoiceRequestContents { self.payer_signing_pubkey } - pub(super) fn payer_note(&self) -> Option { + pub(super) fn payer_note(&self) -> Option> { self.inner.payer_note.as_ref().map(|payer_note| PrintableString(payer_note.as_str())) } @@ -1082,7 +1082,7 @@ impl InvoiceRequestContents { &self.inner.offer_from_hrn } - pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef { + pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef<'_> { let (payer, offer, mut invoice_request, experimental_offer, experimental_invoice_request) = self.inner.as_tlv_stream(); invoice_request.payer_id = Some(&self.payer_signing_pubkey); @@ -1103,7 +1103,7 @@ impl InvoiceRequestContentsWithoutPayerSigningPubkey { self.amount_msats } - pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef { + pub(super) fn as_tlv_stream(&self) -> PartialInvoiceRequestTlvStreamRef<'_> { let payer = PayerTlvStreamRef { metadata: self.payer.0.as_bytes() }; let (offer, experimental_offer) = self.offer.as_tlv_stream(); diff --git a/lightning/src/offers/offer.rs b/lightning/src/offers/offer.rs index bdc9e7c8b87..5b613091c6b 100644 --- a/lightning/src/offers/offer.rs +++ b/lightning/src/offers/offer.rs @@ -646,7 +646,7 @@ macro_rules! offer_accessors { ($self: ident, $contents: expr) => { /// A complete description of the purpose of the payment. Intended to be displayed to the user /// but with the caveat that it has not been verified in any way. - pub fn description(&$self) -> Option<$crate::types::string::PrintableString> { + pub fn description(&$self) -> Option<$crate::types::string::PrintableString<'_>> { $contents.description() } @@ -664,7 +664,7 @@ macro_rules! offer_accessors { ($self: ident, $contents: expr) => { /// The issuer of the offer, possibly beginning with `user@domain` or `domain`. Intended to be /// displayed to the user but with the caveat that it has not been verified in any way. - pub fn issuer(&$self) -> Option<$crate::types::string::PrintableString> { + pub fn issuer(&$self) -> Option<$crate::types::string::PrintableString<'_>> { $contents.issuer() } @@ -802,7 +802,7 @@ impl Offer { #[cfg(test)] impl Offer { - pub(super) fn as_tlv_stream(&self) -> FullOfferTlvStreamRef { + pub(super) fn as_tlv_stream(&self) -> FullOfferTlvStreamRef<'_> { self.contents.as_tlv_stream() } } @@ -848,7 +848,7 @@ impl OfferContents { self.amount } - pub fn description(&self) -> Option { + pub fn description(&self) -> Option> { self.description.as_ref().map(|description| PrintableString(description)) } @@ -874,7 +874,7 @@ impl OfferContents { .unwrap_or(false) } - pub fn issuer(&self) -> Option { + pub fn issuer(&self) -> Option> { self.issuer.as_ref().map(|issuer| PrintableString(issuer.as_str())) } @@ -995,7 +995,7 @@ impl OfferContents { } } - pub(super) fn as_tlv_stream(&self) -> FullOfferTlvStreamRef { + pub(super) fn as_tlv_stream(&self) -> FullOfferTlvStreamRef<'_> { let (currency, amount) = match &self.amount { None => (None, None), Some(Amount::Bitcoin { amount_msats }) => (None, Some(*amount_msats)), diff --git a/lightning/src/offers/refund.rs b/lightning/src/offers/refund.rs index 68f80177e1e..87d7a845b53 100644 --- a/lightning/src/offers/refund.rs +++ b/lightning/src/offers/refund.rs @@ -480,7 +480,7 @@ pub(super) struct RefundContents { impl Refund { /// A complete description of the purpose of the refund. Intended to be displayed to the user /// but with the caveat that it has not been verified in any way. - pub fn description(&self) -> PrintableString { + pub fn description(&self) -> PrintableString<'_> { self.contents.description() } @@ -504,7 +504,7 @@ impl Refund { /// The issuer of the refund, possibly beginning with `user@domain` or `domain`. Intended to be /// displayed to the user but with the caveat that it has not been verified in any way. - pub fn issuer(&self) -> Option { + pub fn issuer(&self) -> Option> { self.contents.issuer() } @@ -553,7 +553,7 @@ impl Refund { } /// Payer provided note to include in the invoice. - pub fn payer_note(&self) -> Option { + pub fn payer_note(&self) -> Option> { self.contents.payer_note() } } @@ -667,8 +667,8 @@ macro_rules! respond_with_derived_signing_pubkey_methods { ($self: ident, $build #[cfg(not(c_bindings))] impl Refund { - respond_with_explicit_signing_pubkey_methods!(self, InvoiceBuilder); - respond_with_derived_signing_pubkey_methods!(self, InvoiceBuilder); + respond_with_explicit_signing_pubkey_methods!(self, InvoiceBuilder<'_, ExplicitSigningPubkey>); + respond_with_derived_signing_pubkey_methods!(self, InvoiceBuilder<'_, DerivedSigningPubkey>); } #[cfg(c_bindings)] @@ -679,7 +679,7 @@ impl Refund { #[cfg(test)] impl Refund { - fn as_tlv_stream(&self) -> RefundTlvStreamRef { + fn as_tlv_stream(&self) -> RefundTlvStreamRef<'_> { self.contents.as_tlv_stream() } } @@ -705,7 +705,7 @@ impl Hash for Refund { } impl RefundContents { - pub fn description(&self) -> PrintableString { + pub fn description(&self) -> PrintableString<'_> { PrintableString(&self.description) } @@ -727,7 +727,7 @@ impl RefundContents { .unwrap_or(false) } - pub fn issuer(&self) -> Option { + pub fn issuer(&self) -> Option> { self.issuer.as_ref().map(|issuer| PrintableString(issuer.as_str())) } @@ -770,11 +770,11 @@ impl RefundContents { } /// Payer provided note to include in the invoice. - pub fn payer_note(&self) -> Option { + pub fn payer_note(&self) -> Option> { self.payer_note.as_ref().map(|payer_note| PrintableString(payer_note.as_str())) } - pub(super) fn as_tlv_stream(&self) -> RefundTlvStreamRef { + pub(super) fn as_tlv_stream(&self) -> RefundTlvStreamRef<'_> { let payer = PayerTlvStreamRef { metadata: self.payer.0.as_bytes() }; let offer = OfferTlvStreamRef { diff --git a/lightning/src/offers/static_invoice.rs b/lightning/src/offers/static_invoice.rs index 805a2ffe9f8..77f486a6a06 100644 --- a/lightning/src/offers/static_invoice.rs +++ b/lightning/src/offers/static_invoice.rs @@ -235,7 +235,7 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// A complete description of the purpose of the originating offer, from [`Offer::description`]. /// /// [`Offer::description`]: crate::offers::offer::Offer::description - pub fn description(&$self) -> Option { + pub fn description(&$self) -> Option> { $contents.description() } @@ -250,7 +250,7 @@ macro_rules! invoice_accessors { ($self: ident, $contents: expr) => { /// The issuer of the offer, from [`Offer::issuer`]. /// /// [`Offer::issuer`]: crate::offers::offer::Offer::issuer - pub fn issuer(&$self) -> Option { + pub fn issuer(&$self) -> Option> { $contents.issuer() } @@ -454,7 +454,7 @@ impl InvoiceContents { } } - fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef { + fn as_tlv_stream(&self) -> PartialInvoiceTlvStreamRef<'_> { let features = { if self.features == Bolt12InvoiceFeatures::empty() { None @@ -503,7 +503,7 @@ impl InvoiceContents { self.offer.features() } - fn description(&self) -> Option { + fn description(&self) -> Option> { self.offer.description() } @@ -511,7 +511,7 @@ impl InvoiceContents { self.offer.absolute_expiry() } - fn issuer(&self) -> Option { + fn issuer(&self) -> Option> { self.offer.issuer() } @@ -763,7 +763,7 @@ mod tests { ); impl StaticInvoice { - fn as_tlv_stream(&self) -> FullInvoiceTlvStreamRef { + fn as_tlv_stream(&self) -> FullInvoiceTlvStreamRef<'_> { let ( offer_tlv_stream, invoice_tlv_stream, diff --git a/lightning/src/routing/gossip.rs b/lightning/src/routing/gossip.rs index a9f45f13d4b..5be09d7932b 100644 --- a/lightning/src/routing/gossip.rs +++ b/lightning/src/routing/gossip.rs @@ -1054,7 +1054,7 @@ impl PartialEq for ChannelInfo { impl ChannelInfo { /// Returns a [`DirectedChannelInfo`] for the channel directed to the given `target` from a /// returned `source`, or `None` if `target` is not one of the channel's counterparties. - pub fn as_directed_to(&self, target: &NodeId) -> Option<(DirectedChannelInfo, &NodeId)> { + pub fn as_directed_to(&self, target: &NodeId) -> Option<(DirectedChannelInfo<'_>, &NodeId)> { if self.one_to_two.is_none() || self.two_to_one.is_none() { return None; } @@ -1073,7 +1073,7 @@ impl ChannelInfo { /// Returns a [`DirectedChannelInfo`] for the channel directed from the given `source` to a /// returned `target`, or `None` if `source` is not one of the channel's counterparties. - pub fn as_directed_from(&self, source: &NodeId) -> Option<(DirectedChannelInfo, &NodeId)> { + pub fn as_directed_from(&self, source: &NodeId) -> Option<(DirectedChannelInfo<'_>, &NodeId)> { if self.one_to_two.is_none() || self.two_to_one.is_none() { return None; } diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index d56d5747e09..9d3093c5a90 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1284,7 +1284,7 @@ impl Payee { Self::Blinded { features, .. } => features.as_ref().map_or(false, |f| f.supports_basic_mpp()), } } - fn features(&self) -> Option { + fn features(&self) -> Option> { match self { Self::Clear { features, .. } => features.as_ref().map(|f| FeaturesRef::Bolt11(f)), Self::Blinded { features, .. } => features.as_ref().map(|f| FeaturesRef::Bolt12(f)), diff --git a/lightning/src/routing/scoring.rs b/lightning/src/routing/scoring.rs index 02efb88dbb9..6c111ab475b 100644 --- a/lightning/src/routing/scoring.rs +++ b/lightning/src/routing/scoring.rs @@ -544,7 +544,7 @@ impl ChannelLiquidities { self.0.iter() } - fn entry(&mut self, short_channel_id: u64) -> Entry { + fn entry(&mut self, short_channel_id: u64) -> Entry<'_, u64, ChannelLiquidity, RandomState> { self.0.entry(short_channel_id) } diff --git a/lightning/src/sync/fairrwlock.rs b/lightning/src/sync/fairrwlock.rs index d97370090cd..6ebb196810d 100644 --- a/lightning/src/sync/fairrwlock.rs +++ b/lightning/src/sync/fairrwlock.rs @@ -26,14 +26,14 @@ impl FairRwLock { // Note that all atomic accesses are relaxed, as we do not rely on the atomics here for any // ordering at all, instead relying on the underlying RwLock to provide ordering of unrelated // memory. - pub fn write(&self) -> LockResult> { + pub fn write(&self) -> LockResult> { self.waiting_writers.fetch_add(1, Ordering::Relaxed); let res = self.lock.write(); self.waiting_writers.fetch_sub(1, Ordering::Relaxed); res } - pub fn read(&self) -> LockResult> { + pub fn read(&self) -> LockResult> { if self.waiting_writers.load(Ordering::Relaxed) != 0 { let _write_queue_lock = self.lock.write(); } diff --git a/lightning/src/util/indexed_map.rs b/lightning/src/util/indexed_map.rs index 34860e3d68a..3f8b3578086 100644 --- a/lightning/src/util/indexed_map.rs +++ b/lightning/src/util/indexed_map.rs @@ -111,7 +111,7 @@ impl IndexedMap { } /// Returns an iterator which iterates over the `key`/`value` pairs in a given range. - pub fn range>(&mut self, range: R) -> Range { + pub fn range>(&mut self, range: R) -> Range<'_, K, V> { self.keys.sort_unstable(); let start = match range.start_bound() { Bound::Unbounded => 0, diff --git a/lightning/src/util/ser_macros.rs b/lightning/src/util/ser_macros.rs index c3cf2044deb..ea7a3e8a2a2 100644 --- a/lightning/src/util/ser_macros.rs +++ b/lightning/src/util/ser_macros.rs @@ -1677,9 +1677,9 @@ mod tests { } // TLVs from the BOLT test cases which should not decode as either n1 or n2 - do_test!(concat!("fd01"), ShortRead); + do_test!("fd01", ShortRead); do_test!(concat!("fd0001", "00"), InvalidValue); - do_test!(concat!("fd0101"), ShortRead); + do_test!("fd0101", ShortRead); do_test!(concat!("0f", "fd"), ShortRead); do_test!(concat!("0f", "fd26"), ShortRead); do_test!(concat!("0f", "fd2602"), ShortRead); @@ -1763,7 +1763,7 @@ mod tests { }; } - do_test!(concat!(""), None, None, None, None); + do_test!("", None, None, None, None); do_test!(concat!("21", "00"), None, None, None, None); do_test!(concat!("fd0201", "00"), None, None, None, None); do_test!(concat!("fd00fd", "00"), None, None, None, None); diff --git a/lightning/src/util/test_channel_signer.rs b/lightning/src/util/test_channel_signer.rs index e619069af50..04b24825bd4 100644 --- a/lightning/src/util/test_channel_signer.rs +++ b/lightning/src/util/test_channel_signer.rs @@ -145,7 +145,7 @@ impl TestChannelSigner { } #[cfg(any(test, feature = "_test_utils"))] - pub fn get_enforcement_state(&self) -> MutexGuard { + pub fn get_enforcement_state(&self) -> MutexGuard<'_, EnforcementState> { self.state.lock().unwrap() }