Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lightning-block-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 :(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug in clippy? Did we report it? In any case it might make sense to move the imports into the macros themselves.

Copy link
Contributor Author

@dunxen dunxen Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a bug honestly. I could only find an issue about a false positive related to this rule for rust-analyzer but this definitely is an issue with the rustc lint rule.

I'll dig some more and file an issue if there isn't one.

Edit: I also noticed the clippy --fix missed a bunch of instances of some rules it can actually fix. I'm not sure if it was the options/flags I used not cooperating but I'll treat it with some suspicion and possibly also file an issue.

use lightning::chain::Listen as _;

use std::future::Future;
use std::ops::Deref;
Expand Down Expand Up @@ -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<u32>)>;
fn get_best_block(&self) -> AsyncBlockSourceResult<'_, (BlockHash, Option<u32>)>;
}

/// Result type for `BlockSource` requests.
Expand Down
6 changes: 3 additions & 3 deletions lightning-invoice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Iter<RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>> {
) -> FilterMap<Iter<'_, RawTaggedField>, 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
Expand Down Expand Up @@ -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<Iter<RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>> {
) -> FilterMap<Iter<'_, RawTaggedField>, fn(&RawTaggedField) -> Option<&TaggedField>> {
self.signed_invoice.raw_invoice().known_tagged_fields()
}

Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion lightning-liquidity/src/events/event_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion lightning-liquidity/src/message_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
}
Expand Down
4 changes: 3 additions & 1 deletion lightning/src/chain/chainmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/blinded_payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions lightning/src/ln/chan_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 }
}

Expand All @@ -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<TrustedClosingTransaction, ()> {
pub fn verify(&self, funding_outpoint: OutPoint) -> Result<TrustedClosingTransaction<'_>, ()> {
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(),
Expand Down Expand Up @@ -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 }
}

Expand All @@ -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<T: secp256k1::Signing + secp256k1::Verification>(&self, channel_parameters: &DirectedChannelTransactionParameters, secp_ctx: &Secp256k1<T>) -> Result<TrustedCommitmentTransaction, ()> {
pub fn verify<T: secp256k1::Signing + secp256k1::Verification>(&self, channel_parameters: &DirectedChannelTransactionParameters, secp_ctx: &Secp256k1<T>) -> Result<TrustedCommitmentTransaction<'_>, ()> {
// 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);
Expand Down
5 changes: 3 additions & 2 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4534,7 +4534,7 @@ where
/// which peer generated this transaction and "to whom" this transaction flows.
#[inline]
#[rustfmt::skip]
fn build_commitment_transaction<L: Deref>(&self, funding: &FundingScope, commitment_number: u64, per_commitment_point: &PublicKey, local: bool, generated_by_local: bool, logger: &L) -> CommitmentData
fn build_commitment_transaction<L: Deref>(&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 };
Expand Down Expand Up @@ -11817,7 +11817,7 @@ where
}
}

pub fn remove_legacy_scids_before_block(&mut self, height: u32) -> alloc::vec::Drain<u64> {
pub fn remove_legacy_scids_before_block(&mut self, height: u32) -> alloc::vec::Drain<'_, u64> {
let end = self
.funding
.get_short_channel_id()
Expand Down Expand Up @@ -14192,6 +14192,7 @@ mod tests {
);
}

#[allow(dead_code)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this may actually be dead code, so we should probably remove it :)

struct Keys {
signer: InMemorySigner,
}
Expand Down
8 changes: 5 additions & 3 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -11897,9 +11899,9 @@ where
L::Target: Logger,
{
#[cfg(not(c_bindings))]
create_offer_builder!(self, OfferBuilder<DerivedMetadata, secp256k1::All>);
create_offer_builder!(self, OfferBuilder<'_, DerivedMetadata, secp256k1::All>);
#[cfg(not(c_bindings))]
create_refund_builder!(self, RefundBuilder<secp256k1::All>);
create_refund_builder!(self, RefundBuilder<'_, secp256k1::All>);

#[cfg(c_bindings)]
create_offer_builder!(self, OfferWithDerivedMetadataBuilder);
Expand Down
6 changes: 3 additions & 3 deletions lightning/src/ln/functional_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ pub trait NodeHolder {
<Self::CM as AChannelManager>::MR,
<Self::CM as AChannelManager>::L,
>;
fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor>;
fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor<'_>>;
}
impl<H: NodeHolder> NodeHolder for &H {
type CM = H::CM;
Expand All @@ -737,7 +737,7 @@ impl<H: NodeHolder> NodeHolder for &H {
> {
(*self).node()
}
fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor> {
fn chain_monitor(&self) -> Option<&test_utils::TestChainMonitor<'_>> {
(*self).chain_monitor()
}
}
Expand All @@ -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)
}
}
Expand Down
9 changes: 6 additions & 3 deletions lightning/src/ln/payment_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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]);

Expand Down
14 changes: 7 additions & 7 deletions lightning/src/offers/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ where

fn create_offer_builder_intern<ES: Deref, PF, I>(
&self, entropy_source: ES, make_paths: PF,
) -> Result<(OfferBuilder<DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
where
ES::Target: EntropySource,
PF: FnOnce(
Expand Down Expand Up @@ -580,7 +580,7 @@ where
/// [`DefaultMessageRouter`]: crate::onion_message::messenger::DefaultMessageRouter
pub fn create_offer_builder<ES: Deref>(
&self, entropy_source: ES, peers: Vec<MessageForwardNode>,
) -> Result<OfferBuilder<DerivedMetadata, secp256k1::All>, Bolt12SemanticError>
) -> Result<OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Bolt12SemanticError>
where
ES::Target: EntropySource,
{
Expand All @@ -601,7 +601,7 @@ where
/// See [`Self::create_offer_builder`] for more details on usage.
pub fn create_offer_builder_using_router<ME: Deref, ES: Deref>(
&self, router: ME, entropy_source: ES, peers: Vec<MessageForwardNode>,
) -> Result<OfferBuilder<DerivedMetadata, secp256k1::All>, Bolt12SemanticError>
) -> Result<OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Bolt12SemanticError>
where
ME::Target: MessageRouter,
ES::Target: EntropySource,
Expand All @@ -627,7 +627,7 @@ where
#[cfg(async_payments)]
pub fn create_async_receive_offer_builder<ES: Deref>(
&self, entropy_source: ES, message_paths_to_always_online_node: Vec<BlindedMessagePath>,
) -> Result<(OfferBuilder<DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
) -> Result<(OfferBuilder<'_, DerivedMetadata, secp256k1::All>, Nonce), Bolt12SemanticError>
where
ES::Target: EntropySource,
{
Expand All @@ -639,7 +639,7 @@ where
fn create_refund_builder_intern<ES: Deref, PF, I>(
&self, entropy_source: ES, make_paths: PF, amount_msats: u64, absolute_expiry: Duration,
payment_id: PaymentId,
) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError>
) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError>
where
ES::Target: EntropySource,
PF: FnOnce(
Expand Down Expand Up @@ -712,7 +712,7 @@ where
pub fn create_refund_builder<ES: Deref>(
&self, entropy_source: ES, amount_msats: u64, absolute_expiry: Duration,
payment_id: PaymentId, peers: Vec<MessageForwardNode>,
) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError>
) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError>
where
ES::Target: EntropySource,
{
Expand Down Expand Up @@ -751,7 +751,7 @@ where
pub fn create_refund_builder_using_router<ES: Deref, ME: Deref>(
&self, router: ME, entropy_source: ES, amount_msats: u64, absolute_expiry: Duration,
payment_id: PaymentId, peers: Vec<MessageForwardNode>,
) -> Result<RefundBuilder<secp256k1::All>, Bolt12SemanticError>
) -> Result<RefundBuilder<'_, secp256k1::All>, Bolt12SemanticError>
where
ME::Target: MessageRouter,
ES::Target: EntropySource,
Expand Down
Loading
Loading