paritytech / parity-scale-codec

Lightweight, efficient, binary serialization and deserialization codec
Apache License 2.0
256 stars 94 forks source link

parity-scale-codec-derive 3.6.0 generates a lot of clippy warnings #454

Closed nazar-pc closed 1 year ago

nazar-pc commented 1 year ago

Upgraded from 3.1.4 to 3.6.0 and getting a lot of warnings like these in generated code:

warning: unneeded `return` statement
   --> crates/subspace-archiving/src/archiver.rs:170:5
    |
170 | /     /// Segment header of the parent
171 | |     #[codec(index = 4)]
172 | |     ParentSegmentHeader(SegmentHeader),
    | |______________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = help: remove `return`
warning: try not to call a closure in the expression where it is declared
  --> crates/subspace-networking/src/request_handlers/peer_info.rs:11:5
   |
11 | /     /// Special status for starting peer. Receiving it in the running mode means an error.
12 | |     Unknown,
   | |___________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure_call
   = note: `#[warn(clippy::redundant_closure_call)]` on by default
help: try doing something like
   |
11 ~     /// Special status for starting peer. Receiving it in the running mode means an error.
12 ~     Unknown,
   |

I think they need to be fixed or suppressed for generated code.

ggwpez commented 1 year ago

Yea… same is happening in Polkadot https://github.com/paritytech/polkadot/pull/7382

ggwpez commented 1 year ago

@koute the closure warning be this one maybe:
https://github.com/paritytech/parity-scale-codec/blob/0688c04994bdcf7ad817eddd26077625458102c4/derive/src/decode.rs#L78

koute commented 1 year ago

Ah, yep. I'll fix it.

SkymanOne commented 1 year ago

We had the same problem in ink!

koute commented 1 year ago

PR with a fix here: https://github.com/paritytech/parity-scale-codec/pull/455