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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion cli/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl From<&ExperimentalModule> for ExperimentalModuleArg {
/// [opts]: struct.Opts.html
fn check_module(s: &str) -> Result<String, Error> {
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),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/config/geolocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl GeolocationMapping {
pub fn read_json_contents(
file: &Path,
) -> Result<HashMap<IpAddr, GeolocationData>, 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)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/config/secret_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl TryFrom<Table> 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),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
11 changes: 2 additions & 9 deletions lib/src/streaming_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ pub enum StreamingBodyItem {
Finished,
}

impl From<Chunk> 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<StreamingBodyItem>) {
Expand All @@ -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<Chunk>) -> Result<(), Error> {
self.sender
.send(Chunk::from(chunk.into()).into())
.send(StreamingBodyItem::Chunk(chunk.into()))
.await
.map_err(|_| Error::StreamingChunkSend)
}
Expand All @@ -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(())
}
Expand Down
4 changes: 1 addition & 3 deletions lib/src/wiggle_abi/req_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/wiggle_abi/secret_store_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down