Skip to content

Commit

Permalink
chore: upgrade rust toolchain to 1.74 (#3721)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Nov 21, 2023
1 parent 8c2cf2a commit 7b4eef0
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 43 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.73"
channel = "1.74.0"
components = ["clippy", "llvm-tools-preview", "rustfmt"]
3 changes: 1 addition & 2 deletions src/db/car/forest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ impl Encoder {
futures::stream::poll_fn(move |cx| {
let encoder = match encoder_store.as_mut() {
Err(e) => {
let dummy_error =
io::Error::new(io::ErrorKind::Other, "Error already consumed.");
let dummy_error = io::Error::other("Error already consumed.");
return Poll::Ready(Some(Err(anyhow::Error::from(std::mem::replace(
e,
dummy_error,
Expand Down
15 changes: 6 additions & 9 deletions src/libp2p/rpc/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,16 @@ where
let n = std::task::ready!(this.io.poll_read(cx, &mut buf))?;
// Terminated
if n == 0 {
let item = serde_ipld_dagcbor::de::from_reader(&self.bytes[..])
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()));
let item =
serde_ipld_dagcbor::de::from_reader(&self.bytes[..]).map_err(io::Error::other);
return Poll::Ready(item);
}
*this.bytes_read += n;
if *this.max_bytes_allowed > 0 && *this.bytes_read > *this.max_bytes_allowed {
let err = io::Error::new(
io::ErrorKind::Other,
format!(
"Buffer size exceeds the maximum allowed {}B",
*this.max_bytes_allowed,
),
);
let err = io::Error::other(format!(
"Buffer size exceeds the maximum allowed {}B",
*this.max_bytes_allowed,
));
warn!("{err}");
return Poll::Ready(Err(err));
}
Expand Down
8 changes: 3 additions & 5 deletions src/libp2p/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ where
{
let mut bytes = vec![];
io.read_to_end(&mut bytes).await?;
serde_ipld_dagcbor::de::from_reader(bytes.as_slice())
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))
serde_ipld_dagcbor::de::from_reader(bytes.as_slice()).map_err(io::Error::other)
}

async fn write_request<T>(
Expand Down Expand Up @@ -157,7 +156,7 @@ where
match tokio::time::timeout(TIMEOUT, DagCborDecodingReader::new(io, MAX_BYTES_ALLOWED)).await {
Ok(r) => r,
Err(_) => {
let err = io::Error::new(io::ErrorKind::Other, "read_and_decode timeout");
let err = io::Error::other("read_and_decode timeout");
tracing::warn!("{err}");
Err(err)
}
Expand All @@ -169,8 +168,7 @@ where
IO: AsyncWrite + Unpin,
T: serde::Serialize,
{
let bytes = fvm_ipld_encoding::to_vec(&data)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))?;
let bytes = fvm_ipld_encoding::to_vec(&data).map_err(io::Error::other)?;
io.write_all(&bytes).await?;
io.close().await?;
Ok(())
Expand Down
10 changes: 6 additions & 4 deletions src/libp2p_bitswap/internals/codec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2019-2023 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use std::io;

use async_trait::async_trait;
use asynchronous_codec::{FramedRead, FramedWrite};
use futures::{
Expand Down Expand Up @@ -40,7 +42,7 @@ impl request_response::Codec for BitswapRequestResponseCodec {

let mut parts = vec![];
for entry in pb_msg.wantlist.unwrap_or_default().entries {
let cid = Cid::try_from(entry.block).map_err(map_io_err)?;
let cid = Cid::try_from(entry.block).map_err(io::Error::other)?;
parts.push(BitswapMessage::Request(BitswapRequest {
ty: entry.wantType.into(),
cid,
Expand All @@ -50,16 +52,16 @@ impl request_response::Codec for BitswapRequestResponseCodec {
}

for payload in pb_msg.payload {
let prefix = Prefix::new(&payload.prefix).map_err(map_io_err)?;
let cid = prefix.to_cid(&payload.data).map_err(map_io_err)?;
let prefix = Prefix::new(&payload.prefix).map_err(io::Error::other)?;
let cid = prefix.to_cid(&payload.data).map_err(io::Error::other)?;
parts.push(BitswapMessage::Response(
cid,
BitswapResponse::Block(payload.data.to_vec()),
));
}

for presence in pb_msg.blockPresences {
let cid = Cid::try_from(presence.cid).map_err(map_io_err)?;
let cid = Cid::try_from(presence.cid).map_err(io::Error::other)?;
let have = presence.type_pb == BlockPresenceType::Have;
parts.push(BitswapMessage::Response(cid, BitswapResponse::Have(have)));
}
Expand Down
3 changes: 0 additions & 3 deletions src/libp2p_bitswap/internals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
pub(in crate::libp2p_bitswap) mod codec;
pub(in crate::libp2p_bitswap) mod event_handlers;
pub(in crate::libp2p_bitswap) mod prefix;

mod utils;
pub(in crate::libp2p_bitswap) use utils::*;
8 changes: 0 additions & 8 deletions src/libp2p_bitswap/internals/utils.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/shim/machine/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct BuiltinActorManifest {
static_assertions::assert_not_impl_all!(BuiltinActor: std::hash::Hash);

impl BuiltinActorManifest {
const MANDATORY_BUILTINS: &[BuiltinActor] = &[BuiltinActor::Init, BuiltinActor::System];
const MANDATORY_BUILTINS: &'static [BuiltinActor] = &[BuiltinActor::Init, BuiltinActor::System];
pub fn load_manifest(b: impl Blockstore, manifest_cid: &Cid) -> anyhow::Result<Self> {
let (manifest_version, actor_list_cid) = b
.get_cbor::<(u32, Cid)>(manifest_cid)?
Expand Down
2 changes: 1 addition & 1 deletion src/state_migration/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async fn test_state_migration(
)).timeout(timeout).send().await.unwrap();
let reader = response
.bytes_stream()
.map_err(|e| futures::io::Error::new(futures::io::ErrorKind::Other, e))
.map_err(std::io::Error::other)
.into_async_read();
let mut writer = futures::io::BufWriter::new(async_fs::File::create(&tmp).await.unwrap());
futures::io::copy(reader, &mut writer).await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/utils/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::utils::reqwest_resume;
use cid::Cid;
use futures::{AsyncWriteExt, TryStreamExt};
use reqwest::Response;
use std::{io::ErrorKind, path::Path};
use std::path::Path;
use tap::Pipe;
use tokio::io::AsyncBufRead;
use tokio_util::{
Expand Down Expand Up @@ -75,7 +75,7 @@ pub async fn reader(location: &str) -> anyhow::Result<impl AsyncBufRead> {
let content_length = resp.content_length().unwrap_or_default();
let stream = resume_resp
.bytes_stream()
.map_err(|reqwest_error| std::io::Error::new(ErrorKind::Other, reqwest_error))
.map_err(std::io::Error::other)
.pipe(tokio_util::io::StreamReader::new);

(Left(stream), content_length)
Expand Down
11 changes: 4 additions & 7 deletions src/utils/proofs_api/paramfetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,9 @@ async fn check_file(path: &Path, info: &ParameterData) -> Result<(), io::Error>
debug!("Parameter file {:?} is ok", path);
Ok(())
} else {
Err(io::Error::new(
ErrorKind::Other,
format!(
"Checksum mismatch in param file {:?}. ({} != {})",
path, str_sum, info.digest
),
))
Err(io::Error::other(format!(
"Checksum mismatch in param file {:?}. ({} != {})",
path, str_sum, info.digest
)))
}
}

0 comments on commit 7b4eef0

Please sign in to comment.