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

Fix various warnings #271

Merged
merged 1 commit into from
Jun 9, 2023
Merged

Fix various warnings #271

merged 1 commit into from
Jun 9, 2023

Conversation

fgsch
Copy link
Member

@fgsch fgsch commented May 19, 2023

Fix various warnings spotted by clippy.

@fgsch fgsch force-pushed the fgsch/fix-warnings branch from 3593feb to b4accd5 Compare May 19, 2023 14:31
@fgsch fgsch marked this pull request as ready for review May 19, 2023 14:52
@fgsch fgsch force-pushed the fgsch/fix-warnings branch from b4accd5 to 5a993b8 Compare June 5, 2023 15:11
@fgsch
Copy link
Member Author

fgsch commented Jun 5, 2023

And the list of warnings this PR is trying to silence:

    Checking viceroy-lib v0.5.2 (/Users/fgsch/foss/Viceroy/lib)
warning: the borrowed expression implements the required traits
   --> lib/src/config/geolocation.rs:211:39
    |
211 |         let data = fs::read_to_string(&file).map_err(GeolocationConfigError::IoError)?;
    |                                       ^^^^^ help: change this to: `file`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

warning: the borrowed expression implements the required traits
  --> lib/src/config/secret_store.rs:81:34
   |
81 |                         fs::read(&path)
   |                                  ^^^^^ help: change this to: `path`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
   --> lib/src/session.rs:893:23
    |
893 |         let targets = std::mem::replace(&mut self.targets, Vec::new());
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut self.targets)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default
    = note: `#[warn(clippy::mem_replace_with_default)]` on by default

warning: casting to the same type is unnecessary (`u64` -> `u64`)
   --> lib/src/execute.rs:356:37
    |
356 |             bytesize::ByteSize::kib(heap_pages as u64 * 64)
    |                                     ^^^^^^^^^^^^^^^^^ help: try: `heap_pages`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `#[warn(clippy::unnecessary_cast)]` on by default

warning: useless conversion to the same type: `body::Chunk`
  --> lib/src/streaming_body.rs:59:19
   |
59 |             .send(Chunk::from(chunk.into()).into())
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `Chunk::from()`: `chunk.into()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
   = note: `#[warn(clippy::useless_conversion)]` on by default

warning: redundant clone
  --> lib/src/streaming_body.rs:81:41
   |
81 |                 let sender = self.sender.clone();
   |                                         ^^^^^^^^ help: remove this
   |
note: this value is dropped without further use
  --> lib/src/streaming_body.rs:81:30
   |
81 |                 let sender = self.sender.clone();
   |                              ^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
   = note: `#[warn(clippy::redundant_clone)]` on by default

warning: useless conversion to the same type: `wiggle_abi::types::PendingRequestHandle`
   --> lib/src/wiggle_abi/req_impl.rs:599:44
    |
599 |         let handle: PendingRequestHandle = pending_req_handle.into();
    |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `pending_req_handle`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> lib/src/wiggle_abi/secret_store_impl.rs:113:39
    |
113 |         plaintext_out.copy_from_slice(&plaintext);
    |                                       ^^^^^^^^^^ help: change this to: `plaintext`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: `viceroy-lib` (lib) generated 8 warnings (run `cargo clippy --fix --lib -p viceroy-lib` to apply 8 suggestions)
    Checking viceroy v0.5.2 (/Users/fgsch/foss/Viceroy/cli)
warning: the borrowed expression implements the required traits
   --> cli/src/opts.rs:197:34
    |
197 |     let contents = std::fs::read(&path)?;
    |                                  ^^^^^ help: change this to: `path`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default

warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> cli/src/main.rs:42:40
   |
42 |     let ctx = create_execution_context(&serve_args.shared(), true).await?;
   |                                        ^^^^^^^^^^^^^^^^^^^^ help: change this to: `serve_args.shared()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

warning: this expression creates a reference which is immediately dereferenced by the compiler
  --> cli/src/main.rs:88:40
   |
88 |     let ctx = create_execution_context(&run_args.shared(), false).await?;
   |                                        ^^^^^^^^^^^^^^^^^^ help: change this to: `run_args.shared()`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Copy link
Contributor

@aturon aturon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all LGTM, thank you!

@JakeChampion JakeChampion merged commit b193b28 into main Jun 9, 2023
@JakeChampion JakeChampion deleted the fgsch/fix-warnings branch June 9, 2023 09:53
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.

3 participants