Skip to content
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

Only attempt to rustfmt files checked into git #3327

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

TheBlueMatt
Copy link
Collaborator

This avoids rustfmt failing on Rust files generated by dependent crates in target, eg

+ rustfmt --edition 2021 --check ./target/debug/build/thiserror-8230374e07b5c05a/out/probe.rs
Diff in /home/matt/rust-lightning-3/target/debug/build/thiserror-8230374e07b5c05a/out/probe.rs at line 1:

-    #![feature(provide_any)]
+#![feature(provide_any)]

-    use std::any::{Demand, Provider};
+use std::any::{Demand, Provider};

-    fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) {
-        p.provide(demand);
-    }
+fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) {
+	p.provide(demand);
+}

This avoids `rustfmt` failing on Rust files generated by dependent
crates in `target`, eg

```
+ rustfmt --edition 2021 --check ./target/debug/build/thiserror-8230374e07b5c05a/out/probe.rs
Diff in /home/matt/rust-lightning-3/target/debug/build/thiserror-8230374e07b5c05a/out/probe.rs at line 1:

-    #![feature(provide_any)]
+#![feature(provide_any)]

-    use std::any::{Demand, Provider};
+use std::any::{Demand, Provider};

-    fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) {
-        p.provide(demand);
-    }
+fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) {
+	p.provide(demand);
+}
```
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.64%. Comparing base (cdd1298) to head (930f5fb).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3327      +/-   ##
==========================================
- Coverage   89.64%   89.64%   -0.01%     
==========================================
  Files         126      126              
  Lines      102676   102676              
  Branches   102676   102676              
==========================================
- Hits        92043    92040       -3     
- Misses       7909     7912       +3     
  Partials     2724     2724              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vincenzopalazzo
Copy link
Contributor

Probably something is breaking

Checking lightning-invoice v0.32.0 (/home/runner/work/rust-lightning/rust-lightning/lightning-invoice)
    Checking lightning v0.0.124 (/home/runner/work/rust-lightning/rust-lightning/lightning)
error: this function depends on never type fallback being `()`
    --> lightning/src/ln/chan_utils.rs:1405:2
     |
1405 |     fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
     = note: for more information, see issue #1[237](https://github.com/lightningdevkit/rust-lightning/actions/runs/10927675314/job/30334397040?pr=3327#step:5:238)48 <https://github.com/rust-lang/rust/issues/123748>
     = help: specify the types explicitly
note: in edition 2024, the requirement `!: util::ser::Readable` will fail
    --> lightning/src/util/ser_macros.rs:373:17
     |
373  |           $field = Some($crate::util::ser::Readable::read(&mut $reader)?);
     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: lightning/src/ln/chan_utils.rs:1406:3
     |
1406 | /         _init_and_read_len_prefixed_tlv_fields!(reader, {
1407 | |             (0, commitment_number, required),
1408 | |             (1, to_broadcaster_delay, option),
1409 | |             (2, to_broadcaster_value_sat, required),
...    |
1416 | |             (15, channel_type_features, option),
1417 | |         });
     | |__________- in this macro invocation
     = note: `-D dependency-on-unit-never-type-fallback` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(dependency_on_unit_never_type_fallback)]`
     = note: this error originates in the macro `$crate::_decode_tlv` which comes from the expansion of the macro `_init_and_read_len_prefixed_tlv_fields` (in Nightly builds, run with -Z macro-backtrace for more info)

error: using `map_err` over `inspect_err`
    --> lightning/src/ln/channelmanager.rs:4116:5
     |
4116 |         ).map_err(|e| {
     |           ^^^^^^^
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
     = note: `-D clippy::manual-inspect` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::manual_inspect)]`
help: try
     |
4116 ~         ).inspect_err(|e| {
4117 |             let logger = WithContext::from(&self.logger, Some(path.hops.first().unwrap().pubkey), None, Some(*payment_hash));
4118 ~             log_error!(logger, "Failed to build an onion for path for payment hash {}", payment_hash);
     |

error: using `map_err` over `inspect_err`
   --> lightning/src/ln/outbound_payment.rs:773:5
    |
773 |             .map_err(|e| { self.remove_outbound_if_all_failed(payment_id, &e); e })
    |              ^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
help: try
    |
773 -             .map_err(|e| { self.remove_outbound_if_all_failed(payment_id, &e); e })
773 +             .inspect_err(|e| { self.remove_outbound_if_all_failed(payment_id, e); })
    |

error: could not compile `lightning` (lib) due to 3 previous errors

@TheBlueMatt
Copy link
Collaborator Author

Yes, linting will be broken until #3301 (due to rustc upgrade)

Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM, but also looking forward to be able to just drop all of this and start using cargo fmt soon :)

@tnull tnull merged commit 66fb520 into lightningdevkit:main Sep 19, 2024
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants