diff --git a/cli/src/main.rs b/cli/src/main.rs index d598e0f9..675ef2a2 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -39,7 +39,7 @@ use { /// Create a new server, bind it to an address, and serve responses until an error occurs. pub async fn serve(serve_args: ServeArgs) -> Result<(), Error> { // Load the wasm module into an execution context - let ctx = create_execution_context(&serve_args.shared(), true).await?; + let ctx = create_execution_context(serve_args.shared(), true).await?; let addr = serve_args.addr(); ViceroyService::new(ctx).serve(addr).await?; @@ -85,7 +85,7 @@ pub async fn main() -> ExitCode { /// Execute a Wasm program in the Viceroy environment. pub async fn run_wasm_main(run_args: RunArgs) -> Result<(), anyhow::Error> { // Load the wasm module into an execution context - let ctx = create_execution_context(&run_args.shared(), false).await?; + let ctx = create_execution_context(run_args.shared(), false).await?; let input = run_args.shared().input(); let program_name = match input.file_stem() { Some(stem) => stem.to_string_lossy(), diff --git a/cli/src/opts.rs b/cli/src/opts.rs index 458efa1f..5874c2e7 100644 --- a/cli/src/opts.rs +++ b/cli/src/opts.rs @@ -194,7 +194,7 @@ impl From<&ExperimentalModule> for ExperimentalModuleArg { /// [opts]: struct.Opts.html fn check_module(s: &str) -> Result { let path = PathBuf::from(s); - let contents = std::fs::read(&path)?; + let contents = std::fs::read(path)?; match wat::parse_bytes(&contents) { Ok(_) => Ok(s.to_string()), _ => Err(Error::FileFormat), diff --git a/lib/src/config/geolocation.rs b/lib/src/config/geolocation.rs index cb8ca275..7c1d3419 100644 --- a/lib/src/config/geolocation.rs +++ b/lib/src/config/geolocation.rs @@ -208,7 +208,7 @@ impl GeolocationMapping { pub fn read_json_contents( file: &Path, ) -> Result, GeolocationConfigError> { - let data = fs::read_to_string(&file).map_err(GeolocationConfigError::IoError)?; + let data = fs::read_to_string(file).map_err(GeolocationConfigError::IoError)?; // Deserialize the contents of the given JSON file. let json = match serde_json::from_str(&data) diff --git a/lib/src/config/secret_store.rs b/lib/src/config/secret_store.rs index 4ea40294..28c00b29 100644 --- a/lib/src/config/secret_store.rs +++ b/lib/src/config/secret_store.rs @@ -78,7 +78,7 @@ impl TryFrom for SecretStoreConfig { err: SecretStoreConfigError::FileNotAString(key.to_string()), } })?; - fs::read(&path) + fs::read(path) .map_err(|e| FastlyConfigError::InvalidSecretStoreDefinition { name: store_name.to_string(), err: SecretStoreConfigError::IoError(e), diff --git a/lib/src/execute.rs b/lib/src/execute.rs index 44ab83d2..e4125a72 100644 --- a/lib/src/execute.rs +++ b/lib/src/execute.rs @@ -353,7 +353,7 @@ impl ExecuteCtx { info!( "request completed using {} of WebAssembly heap", - bytesize::ByteSize::kib(heap_pages as u64 * 64) + bytesize::ByteSize::kib(heap_pages * 64) ); info!("request completed in {:.0?}", request_duration); diff --git a/lib/src/session.rs b/lib/src/session.rs index 36c3f792..a39ca26a 100644 --- a/lib/src/session.rs +++ b/lib/src/session.rs @@ -890,7 +890,7 @@ impl<'session> SelectedTargets<'session> { impl<'session> Drop for SelectedTargets<'session> { fn drop(&mut self) { - let targets = std::mem::replace(&mut self.targets, Vec::new()); + let targets = std::mem::take(&mut self.targets); self.session.reinsert_select_targets(targets); } } diff --git a/lib/src/streaming_body.rs b/lib/src/streaming_body.rs index fd6d882c..56aa358d 100644 --- a/lib/src/streaming_body.rs +++ b/lib/src/streaming_body.rs @@ -37,12 +37,6 @@ pub enum StreamingBodyItem { Finished, } -impl From for StreamingBodyItem { - fn from(chunk: Chunk) -> Self { - Self::Chunk(chunk) - } -} - impl StreamingBody { /// Create a new channel for streaming a body, returning write and read ends as a pair. pub fn new() -> (StreamingBody, mpsc::Receiver) { @@ -56,7 +50,7 @@ impl StreamingBody { /// sending, e.g. due to the receive end being closed. pub async fn send_chunk(&mut self, chunk: impl Into) -> Result<(), Error> { self.sender - .send(Chunk::from(chunk.into()).into()) + .send(StreamingBodyItem::Chunk(chunk.into())) .await .map_err(|_| Error::StreamingChunkSend) } @@ -78,9 +72,8 @@ impl StreamingBody { // If the channel is full, maybe the other end is just taking a while to receive all // the bytes. Spawn a task that will send a `finish` message as soon as there's room // in the channel. - let sender = self.sender.clone(); tokio::task::spawn(async move { - let _ = sender.send(StreamingBodyItem::Finished).await; + let _ = self.sender.send(StreamingBodyItem::Finished).await; }); Ok(()) } diff --git a/lib/src/wiggle_abi/req_impl.rs b/lib/src/wiggle_abi/req_impl.rs index 18ef2b74..19aa76cb 100644 --- a/lib/src/wiggle_abi/req_impl.rs +++ b/lib/src/wiggle_abi/req_impl.rs @@ -596,9 +596,7 @@ impl FastlyHttpReq for Session { &mut self, pending_req_handle: PendingRequestHandle, ) -> Result<(u32, ResponseHandle, BodyHandle), Error> { - let handle: PendingRequestHandle = pending_req_handle.into(); - - if self.async_item_mut(handle.into())?.is_ready() { + if self.async_item_mut(pending_req_handle.into())?.is_ready() { let resp = self .take_pending_request(pending_req_handle)? .recv() diff --git a/lib/src/wiggle_abi/secret_store_impl.rs b/lib/src/wiggle_abi/secret_store_impl.rs index 0ae40ee2..6486fa33 100644 --- a/lib/src/wiggle_abi/secret_store_impl.rs +++ b/lib/src/wiggle_abi/secret_store_impl.rs @@ -110,7 +110,7 @@ impl FastlySecretStore for Session { .as_array(plaintext_len) .as_slice_mut()? .ok_or(Error::SharedMemory)?; - plaintext_out.copy_from_slice(&plaintext); + plaintext_out.copy_from_slice(plaintext); nwritten_out.write(plaintext_len)?; Ok(())