thin-edge.io icon indicating copy to clipboard operation
thin-edge.io copied to clipboard

Clippy: Remove let unit

Open matthiasbeyer opened this issue 2 years ago • 10 comments

Proposed changes

It seems that clippy failures were merged at some point... I don't know.

This fixes a clippy lint over all crates in the repository, namingly the let-unit-value lint.

Nothing more was done in this patchset.

Types of changes

  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [x] Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • [ ] Documentation Update (if none of the other choices apply)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • [x] I have read the CONTRIBUTING doc
  • [x] I have signed the CLA (in all commits with git commit -s)
  • [x] I ran cargo fmt as mentioned in CODING_GUIDELINES
  • [x] I used cargo clippy as mentioned in CODING_GUIDELINES
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added necessary documentation (if appropriate)

matthiasbeyer avatar Jul 22 '22 06:07 matthiasbeyer

It seems that clippy failures were merged at some point... I don't know.

This more likely a new clippy check. We are using this idiom since quit a long time. The motivation is that the following highlight that we are not ignoring something:

let () = do_stuff();

Thanks to the #[must_use] attribute of Result this style is indeed not required.

For me both styles are valid.

didier-wenzek avatar Jul 22 '22 07:07 didier-wenzek

Why is our workflow is not catching these in the cargo clippy job?

That is indeed a good question :laughing:

~~As @didier-wenzek indicated, this might be a new check and maybe because we're running rust 1.56 in CI, which is kinda old (current is 1.62) the old clippy may not have the check yet.~~

Edit: Well, no, that clippy lint was added before 1.29.0 (it says so on the site of the lint)... so I honestly don't know...

If we update our CI to recent rust, we might experience some more failures even (although locally I didn't see any)!

matthiasbeyer avatar Jul 22 '22 07:07 matthiasbeyer

Edit: Well, no, that clippy lint was added before 1.29.0 (it says so on the site of the lint)... so I honestly don't know...

So I have both 1.62 and 1.58. On 1.62 if I run cargo clippy --all-features I too see this omit let warning. But on 1.58 I do not. However, if I run cargo clippy --all-features -- -W clippy::pedantic on 1.58 I start seeing the omit let warning.

cmosd avatar Jul 22 '22 08:07 cmosd

Interesting! Maybe it got promoted recently! :smile:

matthiasbeyer avatar Jul 22 '22 08:07 matthiasbeyer

We can merge it, however, the current cargo clippy in our workflow doesn't detect the warning, that means, in the future, someone can add let unit.

Which one should we go? Update our Rust version to 1.62.0 or keep 1.58.0 add -W clippy::pedantic option?

rina23q avatar Jul 25 '22 09:07 rina23q

IMO updating rust is the way to go, as clippy::pedantic is rather strict and also might have false positives. From its documentation:

lints which are rather strict or might have false positives

matthiasbeyer avatar Jul 25 '22 09:07 matthiasbeyer

@rina23q, @matthiasbeyer does it make sense to build for 1.58.1 (our MSRV) but check linting for 1.62.0?

cmosd avatar Jul 25 '22 10:07 cmosd

Yes I think that sounds like a good idea, IMO.

matthiasbeyer avatar Jul 25 '22 10:07 matthiasbeyer

After thinking again, I think that updating rust to 1.62.0 is the way to go. I mean for the whole project. Because there's no reason to keep it at an old version and having two different versions just introduces complexity in maintaining the CI ecosystem.

I'll file a PR to update it.

matthiasbeyer avatar Jul 26 '22 06:07 matthiasbeyer

:thinking: Are we gonna go forward with this?

matthiasbeyer avatar Aug 02 '22 18:08 matthiasbeyer

🤔 Are we gonna go forward with this?

Yes, I will approve even if I'm okay with the let () = ... syntax. This will let us move freely with new version of clippy.

didier-wenzek avatar Aug 18 '22 12:08 didier-wenzek

Rebased and resolved merge conflicts.

matthiasbeyer avatar Aug 18 '22 12:08 matthiasbeyer