zerotier / zeronsd

A DNS server for ZeroTier users
https://zerotier.com
BSD 3-Clause "New" or "Revised" License
493 stars 56 forks source link

Clippy errors #208

Closed erikh closed 1 year ago

erikh commented 1 year ago

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:

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!

laduke commented 1 year ago

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 {
    |                         ^^^^
erikh commented 1 year ago

I'll look at it. I just submitted a patch tonight which fixes a few things with this branch too.

------- Original Message ------- On Thursday, March 16th, 2023 at 4:46 PM, Travis LaDuke @.***> wrote:

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 { | ^^^^

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

erikh commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

gonna merge unless you think that's a bad idea

erikh commented 1 year ago

it's a good idea; I'll step through it again next weekend with clippy and submit a second patch. It's just a linter, and there are always new things it catches.

------- Original Message ------- On Monday, March 20th, 2023 at 9:53 AM, Travis LaDuke @.***> wrote:

gonna merge unless you think that's a bad idea

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>