Skip to content

Commit 863f6ef

Browse files
authored
chore: upgrade rust toolchain to 1.78.0 (#2006)
1 parent 2949ff7 commit 863f6ef

File tree

9 files changed

+38
-42
lines changed

9 files changed

+38
-42
lines changed

ipld/encoding/src/bytes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ pub mod strict_bytes {
2828
S: Serializer;
2929
}
3030

31-
impl<T: ?Sized> Serialize for T
31+
impl<T> Serialize for T
3232
where
33-
T: AsRef<[u8]>,
33+
T: AsRef<[u8]> + ?Sized,
3434
{
3535
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
3636
where

ipld/encoding/src/raw.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ impl serde::ser::Serializer for Serializer {
7575
Err(Error::KindNotSupported)
7676
}
7777

78-
fn serialize_some<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
78+
fn serialize_some<T>(self, _: &T) -> Result<Self::Ok, Self::Error>
7979
where
80-
T: serde::Serialize,
80+
T: serde::Serialize + ?Sized,
8181
{
8282
Err(Error::KindNotSupported)
8383
}
@@ -95,26 +95,22 @@ impl serde::ser::Serializer for Serializer {
9595
Err(Error::KindNotSupported)
9696
}
9797

98-
fn serialize_newtype_struct<T: ?Sized>(
99-
self,
100-
_: &'static str,
101-
_: &T,
102-
) -> Result<Self::Ok, Self::Error>
98+
fn serialize_newtype_struct<T>(self, _: &'static str, _: &T) -> Result<Self::Ok, Self::Error>
10399
where
104-
T: serde::Serialize,
100+
T: serde::Serialize + ?Sized,
105101
{
106102
Err(Error::KindNotSupported)
107103
}
108104

109-
fn serialize_newtype_variant<T: ?Sized>(
105+
fn serialize_newtype_variant<T>(
110106
self,
111107
_: &'static str,
112108
_: u32,
113109
_: &'static str,
114110
_: &T,
115111
) -> Result<Self::Ok, Self::Error>
116112
where
117-
T: serde::Serialize,
113+
T: serde::Serialize + ?Sized,
118114
{
119115
Err(Error::KindNotSupported)
120116
}

ipld/hamt/src/hamt.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ where
246246
/// assert_eq!(map.get(&2).unwrap(), None);
247247
/// ```
248248
#[inline]
249-
pub fn get<Q: ?Sized>(&self, k: &Q) -> Result<Option<&V>, Error>
249+
pub fn get<Q>(&self, k: &Q) -> Result<Option<&V>, Error>
250250
where
251251
K: Borrow<Q>,
252-
Q: Hash + Eq,
252+
Q: Hash + Eq + ?Sized,
253253
V: DeserializeOwned,
254254
{
255255
match self.root.get(k, self.store.borrow(), &self.conf)? {
@@ -278,10 +278,10 @@ where
278278
/// assert_eq!(map.contains_key(&2).unwrap(), false);
279279
/// ```
280280
#[inline]
281-
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> Result<bool, Error>
281+
pub fn contains_key<Q>(&self, k: &Q) -> Result<bool, Error>
282282
where
283283
K: Borrow<Q>,
284-
Q: Hash + Eq,
284+
Q: Hash + Eq + ?Sized,
285285
{
286286
Ok(self.root.get(k, self.store.borrow(), &self.conf)?.is_some())
287287
}
@@ -306,10 +306,10 @@ where
306306
/// assert_eq!(map.delete(&1).unwrap(), Some((1, "a".to_string())));
307307
/// assert_eq!(map.delete(&1).unwrap(), None);
308308
/// ```
309-
pub fn delete<Q: ?Sized>(&mut self, k: &Q) -> Result<Option<(K, V)>, Error>
309+
pub fn delete<Q>(&mut self, k: &Q) -> Result<Option<(K, V)>, Error>
310310
where
311311
K: Borrow<Q>,
312-
Q: Hash + Eq,
312+
Q: Hash + Eq + ?Sized,
313313
{
314314
let deleted = self.root.remove_entry(k, self.store.borrow(), &self.conf)?;
315315

@@ -410,15 +410,15 @@ where
410410
/// assert_eq!(next_key.unwrap(), numbers[2]);
411411
/// ```
412412
#[inline]
413-
pub fn for_each_ranged<Q: ?Sized, F>(
413+
pub fn for_each_ranged<Q, F>(
414414
&self,
415415
starting_key: Option<&Q>,
416416
max: Option<usize>,
417417
mut f: F,
418418
) -> Result<(usize, Option<K>), Error>
419419
where
420420
K: Borrow<Q> + Clone,
421-
Q: Eq + Hash,
421+
Q: Eq + Hash + ?Sized,
422422
V: DeserializeOwned,
423423
F: FnMut(&K, &V) -> anyhow::Result<()>,
424424
{
@@ -510,11 +510,11 @@ where
510510
///
511511
/// # anyhow::Ok(())
512512
/// ```
513-
pub fn iter_from<Q: ?Sized>(&self, key: &Q) -> Result<IterImpl<BS, V, K, H, Ver>, Error>
513+
pub fn iter_from<Q>(&self, key: &Q) -> Result<IterImpl<BS, V, K, H, Ver>, Error>
514514
where
515515
H: HashAlgorithm,
516516
K: Borrow<Q>,
517-
Q: Hash + Eq,
517+
Q: Hash + Eq + ?Sized,
518518
{
519519
IterImpl::new_from(&self.store, &self.root, key, &self.conf)
520520
}

ipld/hamt/src/hash_algorithm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use crate::{Hash, HashedKey};
1010

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

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

3737
impl HashAlgorithm for Sha256 {
38-
fn hash<X: ?Sized>(key: &X) -> HashedKey
38+
fn hash<X>(key: &X) -> HashedKey
3939
where
40-
X: Hash,
40+
X: Hash + ?Sized,
4141
{
4242
let mut hasher = Sha2HasherWrapper::default();
4343
key.hash(&mut hasher);

ipld/hamt/src/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
}
4444
}
4545

46-
pub(crate) fn new_from<Q: ?Sized>(
46+
pub(crate) fn new_from<Q>(
4747
store: &'a BS,
4848
root: &'a Node<K, V, H, Ver>,
4949
key: &Q,
@@ -52,7 +52,7 @@ where
5252
where
5353
H: HashAlgorithm,
5454
K: Borrow<Q> + PartialOrd,
55-
Q: Hash + Eq,
55+
Q: Hash + Eq + ?Sized,
5656
{
5757
let hashed_key = H::hash(key);
5858
let mut hash = HashBits::new(&hashed_key);

ipld/hamt/src/node.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -178,29 +178,29 @@ where
178178
}
179179

180180
#[inline]
181-
pub fn get<Q: ?Sized, S: Blockstore>(
181+
pub fn get<Q, S: Blockstore>(
182182
&self,
183183
k: &Q,
184184
store: &S,
185185
conf: &Config,
186186
) -> Result<Option<&V>, Error>
187187
where
188188
K: Borrow<Q>,
189-
Q: Eq + Hash,
189+
Q: Eq + Hash + ?Sized,
190190
{
191191
Ok(self.search(k, store, conf)?.map(|kv| kv.value()))
192192
}
193193

194194
#[inline]
195-
pub fn remove_entry<Q: ?Sized, S>(
195+
pub fn remove_entry<Q, S>(
196196
&mut self,
197197
k: &Q,
198198
store: &S,
199199
conf: &Config,
200200
) -> Result<Option<(K, V)>, Error>
201201
where
202202
K: Borrow<Q>,
203-
Q: Eq + Hash,
203+
Q: Eq + Hash + ?Sized,
204204
S: Blockstore,
205205
{
206206
let hash = H::hash(k);
@@ -212,21 +212,21 @@ where
212212
}
213213

214214
/// Search for a key.
215-
fn search<Q: ?Sized, S: Blockstore>(
215+
fn search<Q, S: Blockstore>(
216216
&self,
217217
q: &Q,
218218
store: &S,
219219
conf: &Config,
220220
) -> Result<Option<&KeyValuePair<K, V>>, Error>
221221
where
222222
K: Borrow<Q>,
223-
Q: Eq + Hash,
223+
Q: Eq + Hash + ?Sized,
224224
{
225225
let hash = H::hash(q);
226226
self.get_value(&mut HashBits::new(&hash), conf, 0, q, store)
227227
}
228228

229-
fn get_value<Q: ?Sized, S: Blockstore>(
229+
fn get_value<Q, S: Blockstore>(
230230
&self,
231231
hashed_key: &mut HashBits,
232232
conf: &Config,
@@ -236,7 +236,7 @@ where
236236
) -> Result<Option<&KeyValuePair<K, V>>, Error>
237237
where
238238
K: Borrow<Q>,
239-
Q: Eq + Hash,
239+
Q: Eq + Hash + ?Sized,
240240
{
241241
let idx = hashed_key.next(conf.bit_width)?;
242242

@@ -390,7 +390,7 @@ where
390390
}
391391

392392
/// Internal method to delete entries.
393-
fn rm_value<Q: ?Sized, S: Blockstore>(
393+
fn rm_value<Q, S: Blockstore>(
394394
&mut self,
395395
hashed_key: &mut HashBits,
396396
conf: &Config,
@@ -400,7 +400,7 @@ where
400400
) -> Result<Option<(K, V)>, Error>
401401
where
402402
K: Borrow<Q>,
403-
Q: Hash + Eq,
403+
Q: Hash + Eq + ?Sized,
404404
{
405405
let idx = hashed_key.next(conf.bit_width)?;
406406

ipld/kamt/src/iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ where
3434
}
3535
}
3636

37-
pub(crate) fn new_from<Q: Sized>(
37+
pub(crate) fn new_from<Q>(
3838
store: &'a BS,
3939
root: &'a Node<K, V, H, N>,
4040
key: &Q,
4141
conf: &'a Config,
4242
) -> Result<Self, Error>
4343
where
4444
K: Borrow<Q> + PartialOrd,
45-
Q: PartialEq,
45+
Q: PartialEq + Sized,
4646
H: AsHashedKey<Q, N>,
4747
{
4848
let hashed_key = H::as_hashed_key(key);

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.76.0"
2+
channel = "1.78.0"
33
components = ["clippy", "llvm-tools-preview", "rustfmt"]
44
targets = ["wasm32-unknown-unknown"]

shared/tests/address_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ fn address_hashmap() {
581581

582582
// insert other value
583583
let h2 = Address::new_id(2);
584-
assert!(hm.get(&h2).is_none());
584+
assert!(!hm.contains_key(&h2));
585585
hm.insert(h2, 2);
586586
assert_eq!(hm.get(&h2).unwrap(), &2);
587587

0 commit comments

Comments
 (0)