Skip to content

Commit

Permalink
chore: upgrade rust toolchain to 1.78.0 (#2006)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored May 8, 2024
1 parent 2949ff7 commit 863f6ef
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 42 deletions.
4 changes: 2 additions & 2 deletions ipld/encoding/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ pub mod strict_bytes {
S: Serializer;
}

impl<T: ?Sized> Serialize for T
impl<T> Serialize for T
where
T: AsRef<[u8]>,
T: AsRef<[u8]> + ?Sized,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand Down
16 changes: 6 additions & 10 deletions ipld/encoding/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ impl serde::ser::Serializer for Serializer {
Err(Error::KindNotSupported)
}

fn serialize_some<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
where
T: serde::Serialize,
T: serde::Serialize + ?Sized,
{
Err(Error::KindNotSupported)
}
Expand All @@ -95,26 +95,22 @@ impl serde::ser::Serializer for Serializer {
Err(Error::KindNotSupported)
}

fn serialize_newtype_struct<T: ?Sized>(
self,
_: &'static str,
_: &T,
) -> Result<Self::Ok, Self::Error>
fn serialize_newtype_struct<T>(self, _: &'static str, _: &T) -> Result<Self::Ok, Self::Error>
where
T: serde::Serialize,
T: serde::Serialize + ?Sized,
{
Err(Error::KindNotSupported)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T>(
self,
_: &'static str,
_: u32,
_: &'static str,
_: &T,
) -> Result<Self::Ok, Self::Error>
where
T: serde::Serialize,
T: serde::Serialize + ?Sized,
{
Err(Error::KindNotSupported)
}
Expand Down
20 changes: 10 additions & 10 deletions ipld/hamt/src/hamt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ where
/// assert_eq!(map.get(&2).unwrap(), None);
/// ```
#[inline]
pub fn get<Q: ?Sized>(&self, k: &Q) -> Result<Option<&V>, Error>
pub fn get<Q>(&self, k: &Q) -> Result<Option<&V>, Error>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
V: DeserializeOwned,
{
match self.root.get(k, self.store.borrow(), &self.conf)? {
Expand Down Expand Up @@ -278,10 +278,10 @@ where
/// assert_eq!(map.contains_key(&2).unwrap(), false);
/// ```
#[inline]
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> Result<bool, Error>
pub fn contains_key<Q>(&self, k: &Q) -> Result<bool, Error>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
Ok(self.root.get(k, self.store.borrow(), &self.conf)?.is_some())
}
Expand All @@ -306,10 +306,10 @@ where
/// assert_eq!(map.delete(&1).unwrap(), Some((1, "a".to_string())));
/// assert_eq!(map.delete(&1).unwrap(), None);
/// ```
pub fn delete<Q: ?Sized>(&mut self, k: &Q) -> Result<Option<(K, V)>, Error>
pub fn delete<Q>(&mut self, k: &Q) -> Result<Option<(K, V)>, Error>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
let deleted = self.root.remove_entry(k, self.store.borrow(), &self.conf)?;

Expand Down Expand Up @@ -410,15 +410,15 @@ where
/// assert_eq!(next_key.unwrap(), numbers[2]);
/// ```
#[inline]
pub fn for_each_ranged<Q: ?Sized, F>(
pub fn for_each_ranged<Q, F>(
&self,
starting_key: Option<&Q>,
max: Option<usize>,
mut f: F,
) -> Result<(usize, Option<K>), Error>
where
K: Borrow<Q> + Clone,
Q: Eq + Hash,
Q: Eq + Hash + ?Sized,
V: DeserializeOwned,
F: FnMut(&K, &V) -> anyhow::Result<()>,
{
Expand Down Expand Up @@ -510,11 +510,11 @@ where
///
/// # anyhow::Ok(())
/// ```
pub fn iter_from<Q: ?Sized>(&self, key: &Q) -> Result<IterImpl<BS, V, K, H, Ver>, Error>
pub fn iter_from<Q>(&self, key: &Q) -> Result<IterImpl<BS, V, K, H, Ver>, Error>
where
H: HashAlgorithm,
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
IterImpl::new_from(&self.store, &self.root, key, &self.conf)
}
Expand Down
8 changes: 4 additions & 4 deletions ipld/hamt/src/hash_algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::{Hash, HashedKey};

/// Algorithm used as the hasher for the Hamt.
pub trait HashAlgorithm {
fn hash<X: ?Sized>(key: &X) -> HashedKey
fn hash<X>(key: &X) -> HashedKey
where
X: Hash;
X: Hash + ?Sized;
}

/// Type is needed because the Sha256 hasher does not implement `std::hash::Hasher`
Expand All @@ -35,9 +35,9 @@ impl Hasher for Sha2HasherWrapper {
pub enum Sha256 {}

impl HashAlgorithm for Sha256 {
fn hash<X: ?Sized>(key: &X) -> HashedKey
fn hash<X>(key: &X) -> HashedKey
where
X: Hash,
X: Hash + ?Sized,
{
let mut hasher = Sha2HasherWrapper::default();
key.hash(&mut hasher);
Expand Down
4 changes: 2 additions & 2 deletions ipld/hamt/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
}
}

pub(crate) fn new_from<Q: ?Sized>(
pub(crate) fn new_from<Q>(
store: &'a BS,
root: &'a Node<K, V, H, Ver>,
key: &Q,
Expand All @@ -52,7 +52,7 @@ where
where
H: HashAlgorithm,
K: Borrow<Q> + PartialOrd,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
let hashed_key = H::hash(key);
let mut hash = HashBits::new(&hashed_key);
Expand Down
20 changes: 10 additions & 10 deletions ipld/hamt/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,29 @@ where
}

#[inline]
pub fn get<Q: ?Sized, S: Blockstore>(
pub fn get<Q, S: Blockstore>(
&self,
k: &Q,
store: &S,
conf: &Config,
) -> Result<Option<&V>, Error>
where
K: Borrow<Q>,
Q: Eq + Hash,
Q: Eq + Hash + ?Sized,
{
Ok(self.search(k, store, conf)?.map(|kv| kv.value()))
}

#[inline]
pub fn remove_entry<Q: ?Sized, S>(
pub fn remove_entry<Q, S>(
&mut self,
k: &Q,
store: &S,
conf: &Config,
) -> Result<Option<(K, V)>, Error>
where
K: Borrow<Q>,
Q: Eq + Hash,
Q: Eq + Hash + ?Sized,
S: Blockstore,
{
let hash = H::hash(k);
Expand All @@ -212,21 +212,21 @@ where
}

/// Search for a key.
fn search<Q: ?Sized, S: Blockstore>(
fn search<Q, S: Blockstore>(
&self,
q: &Q,
store: &S,
conf: &Config,
) -> Result<Option<&KeyValuePair<K, V>>, Error>
where
K: Borrow<Q>,
Q: Eq + Hash,
Q: Eq + Hash + ?Sized,
{
let hash = H::hash(q);
self.get_value(&mut HashBits::new(&hash), conf, 0, q, store)
}

fn get_value<Q: ?Sized, S: Blockstore>(
fn get_value<Q, S: Blockstore>(
&self,
hashed_key: &mut HashBits,
conf: &Config,
Expand All @@ -236,7 +236,7 @@ where
) -> Result<Option<&KeyValuePair<K, V>>, Error>
where
K: Borrow<Q>,
Q: Eq + Hash,
Q: Eq + Hash + ?Sized,
{
let idx = hashed_key.next(conf.bit_width)?;

Expand Down Expand Up @@ -390,7 +390,7 @@ where
}

/// Internal method to delete entries.
fn rm_value<Q: ?Sized, S: Blockstore>(
fn rm_value<Q, S: Blockstore>(
&mut self,
hashed_key: &mut HashBits,
conf: &Config,
Expand All @@ -400,7 +400,7 @@ where
) -> Result<Option<(K, V)>, Error>
where
K: Borrow<Q>,
Q: Hash + Eq,
Q: Hash + Eq + ?Sized,
{
let idx = hashed_key.next(conf.bit_width)?;

Expand Down
4 changes: 2 additions & 2 deletions ipld/kamt/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ where
}
}

pub(crate) fn new_from<Q: Sized>(
pub(crate) fn new_from<Q>(
store: &'a BS,
root: &'a Node<K, V, H, N>,
key: &Q,
conf: &'a Config,
) -> Result<Self, Error>
where
K: Borrow<Q> + PartialOrd,
Q: PartialEq,
Q: PartialEq + Sized,
H: AsHashedKey<Q, N>,
{
let hashed_key = H::as_hashed_key(key);
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.76.0"
channel = "1.78.0"
components = ["clippy", "llvm-tools-preview", "rustfmt"]
targets = ["wasm32-unknown-unknown"]
2 changes: 1 addition & 1 deletion shared/tests/address_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ fn address_hashmap() {

// insert other value
let h2 = Address::new_id(2);
assert!(hm.get(&h2).is_none());
assert!(!hm.contains_key(&h2));
hm.insert(h2, 2);
assert_eq!(hm.get(&h2).unwrap(), &2);

Expand Down

0 comments on commit 863f6ef

Please sign in to comment.