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

Clippy errors #208

Merged
merged 5 commits into from
Mar 20, 2023
Merged

Clippy errors #208

merged 5 commits into from
Mar 20, 2023

Conversation

erikh
Copy link
Contributor

@erikh erikh commented Mar 6, 2023

This corrects numerous issues identified in style and general sanitation provided by cargo clippy. You will want to run this against the main branch (probably rebasing against #206 first, as this patch already is) to identify what changed.

Here's a quick high level overview of what changed:

  • many length comparisons to 0 length were replaced with is_empty()
  • numerous over-eager clones were plucked
  • a significant change to the init code regarding the start arguments for the supervise calls (this will need to be tested manually, most likely)
  • some issues regarding more modern usage of HashMaps to add default entries when they are missing

This change is much more ambitious and while confident, I am not certain that this patch will not add regressions. Please take the time to run the integration testing suite (email me if you need help setting it up) as well as manually test the supervision management code paths. I don't want you folks to release a broken change.

I do feel the code is overall better by this change, and is not superfluous. These are things I should have done a long time ago.

Thanks!

Signed-off-by: Erik Hollensbe <git@hollensbe.org>
Signed-off-by: Erik Hollensbe <git@hollensbe.org>
@laduke
Copy link
Contributor

laduke commented Mar 16, 2023

I'm all for it, but I'm seeing this when I run make test.
I will try again in the morning with a clearer head.
Pro clippy

 Compiling zeronsd v0.5.2 (/Users/travis/repos/github.com/zerotier/zeronsd)
error[E0507]: cannot move out of `self.launcher.network_id` which is behind a shared reference
   --> src/supervise.rs:350:13
    |
350 |             self.launcher.network_id.expect("network_id missing")
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ ---------------------------- `self.launcher.network_id` moved due to this method call
    |             |
    |             help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
    |             move occurs because `self.launcher.network_id` has type `std::option::Option<std::string::String>`, which does not implement the `Copy` trait
    |
note: this function takes ownership of the receiver `self`, which moves `self.launcher.network_id`
   --> /Users/travis/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:735:25
    |
735 |     pub const fn expect(self, msg: &str) -> T {
    |                         ^^^^

Signed-off-by: Erik Hollensbe <git@hollensbe.org>
@erikh
Copy link
Contributor Author

erikh commented Mar 17, 2023 via email

Signed-off-by: Erik Hollensbe <git@hollensbe.org>
@erikh
Copy link
Contributor Author

erikh commented Mar 20, 2023

Tests are fixed. Since I don't have an account to run the integration tests, you'll need to fix them if they need fixing.

@laduke
Copy link
Contributor

laduke commented Mar 20, 2023

awesome thanks. the tests still pass except for the little flakiness discussed elsewhere. I had to add one .as_ref() to get it to build still (see previous message).

i see more lints when i run clippy. i wonder if we're running different versions of something.

@laduke
Copy link
Contributor

laduke commented Mar 20, 2023

gonna merge unless you think that's a bad idea

@erikh
Copy link
Contributor Author

erikh commented Mar 20, 2023 via email

@laduke laduke merged commit 3c11cad into zerotier:main Mar 20, 2023
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.

None yet

2 participants