Skip to content

chore: satisfy cargo clippy

Alexey Protsenko requested to merge clippy into master
warning: this expression borrows a reference (`&raft::prelude::HardState`) that is immediately dereferenced by the compiler
   --> picolib/traft/node.rs:136:37
    |
136 |         Storage::persist_hard_state(&hs);
    |                                     ^^^ help: change this to: `hs`
    |
    = note: `-W clippy::needless-borrow` implied by `-W clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
   --> picolib/traft/storage.rs:164:9
    |
164 |         Storage::term().map(|v| ret.term = v);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
    |         |
    |         help: try this: `if let Some(v) = Storage::term() { ... }`
    |
    = note: `-W clippy::option-map-unit-fn` implied by `-W clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn

warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
   --> picolib/traft/storage.rs:165:9
    |
165 |         Storage::vote().map(|v| ret.vote = v);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
    |         |
    |         help: try this: `if let Some(v) = Storage::vote() { ... }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn

warning: called `map(f)` on an `Option` value where `f` is a closure that returns the unit type `()`
   --> picolib/traft/storage.rs:166:9
    |
166 |         Storage::commit().map(|v| ret.commit = v);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
    |         |
    |         help: try this: `if let Some(v) = Storage::commit() { ... }`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unit_fn

warning: unneeded `return` statement
   --> picolib/traft/storage.rs:213:13
    |
213 |             return Ok(row.term);
    |             ^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `Ok(row.term)`
    |
    = note: `-W clippy::needless-return` implied by `-W clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

warning: unneeded `return` statement
   --> picolib/traft/storage.rs:216:13
    |
216 |             return Err(RaftError::Store(StorageError::Unavailable));
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove `return`: `Err(RaftError::Store(StorageError::Unavailable))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

warning: this public function might dereference a raw pointer but is not marked `unsafe`
  --> picolib/lib.rs:55:46
   |
55 |         let l = tlua::StaticLua::from_static(l);
   |                                              ^
   |
   = note: `-W clippy::not-unsafe-ptr-arg-deref` implied by `-W clippy::all`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#not_unsafe_ptr_arg_deref

warning: `picodata` (lib) generated 7 warnings
warning: single-character string constant used as pattern
  --> picodata/execve.rs:29:25
   |
29 |     for p in path.split(":") {
   |                         ^^^ help: try using a `char` instead: `':'`
   |
   = note: `-W clippy::single-char-pattern` implied by `-W clippy::all`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_pattern

warning: use of `or_insert` followed by a function call
  --> picodata/main.rs:70:10
   |
70 |         .or_insert("3301".to_owned());
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(|| "3301".to_owned())`
   |
   = note: `-W clippy::or-fun-call` implied by `-W clippy::all`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: use of `or_insert` followed by a function call
  --> picodata/main.rs:72:10
   |
72 |         .or_insert(".".to_owned());
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `or_insert_with(|| ".".to_owned())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call

warning: `picodata` (bin "picodata") generated 3 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s

Merge request reports