From 8dd1b39baffe95e36e2bb6f555b848630ed6364e Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 5 Apr 2025 13:17:34 +0200 Subject: [PATCH 1/3] clippy: avoid manual implementation of `ok` ``` error: manual implementation of `ok` --> lightning/src/ln/channel.rs:8551:3 | 8551 | / match self.sign_channel_announcement(node_signer, announcement) { 8552 | | Ok(res) => Some(res), 8553 | | Err(_) => None, 8554 | | } | |_________^ help: replace with: `self.sign_channel_announcement(node_signer, announcement).ok()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_err = note: `-D clippy::manual-ok-err` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_ok_err)]` ``` Signed-off-by: Vincenzo Palazzo --- lightning/src/ln/channel.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 005ec566f0e..aafca1a6109 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -8548,10 +8548,7 @@ impl FundedChannel where Ok(res) => res, Err(_) => return None, }; - match self.sign_channel_announcement(node_signer, announcement) { - Ok(res) => Some(res), - Err(_) => None, - } + self.sign_channel_announcement(node_signer, announcement).ok() } /// May panic if called on a channel that wasn't immediately-previously From 7cd387c703cce76dca49b33659fc79ee59d35cec Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 5 Apr 2025 13:15:54 +0200 Subject: [PATCH 2/3] clippy: disable warning for repeat_n with recent rustc version we can use `repeat_n` instead of `repeat().take()` ``` error: this `repeat().take()` can be written more concisely --> lightning-invoice/src/ser.rs:256:12 | 256 | Box::new(core::iter::repeat(Fe32::Q).take(to_pad).chain(fes)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `repeat_n()` instead: `core::iter::repeat_n(Fe32::Q, to_pad)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_repeat_n = note: `-D clippy::manual-repeat-n` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_repeat_n)]` ``` but to keep compatibility with older rustc versions we need to disable the warning for the `repeat_n` lint. Signed-off-by: Vincenzo Palazzo --- ci/check-lint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/check-lint.sh b/ci/check-lint.sh index b66a856797a..1c6229e84f6 100755 --- a/ci/check-lint.sh +++ b/ci/check-lint.sh @@ -94,4 +94,5 @@ RUSTFLAGS='-D warnings' cargo clippy -- \ -A clippy::unnecessary_unwrap \ -A clippy::unused_unit \ -A clippy::useless_conversion \ - -A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` + -A clippy::unnecessary_map_or `# to be removed once we hit MSRV 1.70` \ + -A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` From 4892a57564772614aac444c7e2410002f9909aa7 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Mon, 7 Apr 2025 22:18:18 +0200 Subject: [PATCH 3/3] clippy: docs formatting This is the most opinonated suggestion in this sequence of patches. Probably IDK if would be an option disable this check, but for now this commit propose a formatting fix to make clippy happy. ``` error: doc list item overindented --> lightning-types/src/features.rs:62:5 | 62 | //! onion. | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items = note: `-D clippy::doc-overindented-list-items` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::doc_overindented_list_items)]` error: doc list item overindented --> lightning-types/src/features.rs:63:5 | 63 | //! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items error: doc list item overindented --> lightning-types/src/features.rs:64:5 | 64 | //! more). | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items error: doc list item overindented --> lightning-types/src/features.rs:66:5 | 66 | //! (see | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items error: doc list item overindented --> lightning-types/src/features.rs:67:5 | 67 | //! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items error: doc list item overindented --> lightning-types/src/features.rs:68:5 | 68 | //! for more info). | ^^^ help: try using ` ` (2 spaces) | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items error: could not compile `lightning-types` (lib) due to 6 previous errors ``` Suggested-by: @dunxen Signed-off-by: Vincenzo Palazzo --- lightning-types/src/features.rs | 12 ++++++------ lightning/src/ln/channel.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lightning-types/src/features.rs b/lightning-types/src/features.rs index 2aecdbc1415..1b7f880314f 100644 --- a/lightning-types/src/features.rs +++ b/lightning-types/src/features.rs @@ -59,13 +59,13 @@ //! - `SCIDPrivacy` - supply channel aliases for routing //! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information). //! - `PaymentMetadata` - include additional data in invoices which is passed to recipients in the -//! onion. -//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for -//! more). +//! onion. +//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for +//! more). //! - `ZeroConf` - supports accepting HTLCs and using channels prior to funding confirmation -//! (see -//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) -//! for more info). +//! (see +//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) +//! for more info). //! - `Keysend` - send funds to a node without an invoice //! (see the [`Keysend` feature assignment proposal](https://github.com/lightning/bolts/issues/605#issuecomment-606679798) for more information). //! - `Trampoline` - supports receiving and forwarding Trampoline payments diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index aafca1a6109..02a63ee2665 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -1153,7 +1153,7 @@ pub(crate) const MIN_AFFORDABLE_HTLC_COUNT: usize = 4; /// /// * The expected interval between ticks (1 minute). /// * The average convergence delay of updates across the network, i.e., ~300 seconds on average -/// for a node to see an update as seen on ``. +/// for a node to see an update as seen on ``. /// * `EXPIRE_PREV_CONFIG_TICKS` = convergence_delay / tick_interval pub(crate) const EXPIRE_PREV_CONFIG_TICKS: usize = 5;