-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] clippy new warnings in rustc 1.86.0 (05f9846f8 2025-03-31) #3710
base: main
Are you sure you want to change the base?
[RFC] clippy new warnings in rustc 1.86.0 (05f9846f8 2025-03-31) #3710
Conversation
I've assigned @valentinewallace as a reviewer! |
da14d57
to
3bbf7f0
Compare
``` 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 <[email protected]>
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 ``` Signed-off-by: Vincenzo Palazzo <[email protected]>
3bbf7f0
to
19f149e
Compare
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 <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3710 +/- ##
==========================================
- Coverage 89.04% 89.04% -0.01%
==========================================
Files 155 155
Lines 122019 122017 -2
Branches 122019 122017 -2
==========================================
- Hits 108652 108647 -5
- Misses 10701 10710 +9
+ Partials 2666 2660 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The changes seem minimal and the formatting is being properly corrected, because it's aligning further lines with the leading backtick, unlike before where those instance were aligned with the first letter. So this LGTM |
//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for | ||
//! more). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm these don't look right, though. does clippy complain if they have just one for leading space?
//! (see | ||
//! [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#the-channel_ready-message) | ||
//! for more info). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this as well. does it complain if you had only removed one leading space from each? it really should be 3 leading spaces, not 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me double-check this, I just applied what the error was saying without double checking for different spaces quantity! space suggestions are always weird IMHO :)
So you are suggesting another space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, since this looks odd:
//! - `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).
And this looks right:
//! - `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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird, but maybe you applied changes for this on main
after looking at an old CI run before #3704?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm a bit confused why we need to touch features.rs
once more, wasn't this solved in #3704 ?
Yeah, those changes are correct. I think this might have been applied to |
@@ -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` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
-A clippy::manual-repeat-n `# to be removed once we hit MSRV 1.86` | |
-A clippy::manual_repeat_n `# to be removed once we hit MSRV 1.86` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I believe we only need these changes:
diff --git a/lightning-types/src/features.rs b/lightning-types/src/features.rs
index 2aecdbc14..1b7f88031 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
🔔 1st Reminder Hey @valentinewallace! This PR has been waiting for your review. |
I was using an older version of the compiler, and Clippy did not report any issues. However, after updating to Rust 1.86.0, I was able to reproduce the warnings that we are having inside the CI. This patch proposes an opinionated solution that aligns with Clippy’s suggestions, but I am open to disabling some of the warnings if needed.
The commits include specific changes to highlight the errors, making the review process easier.
Probably @TheBlueMatt will have some opinion on this!