Skip to content

Commit 88340de

Browse files
fix unused export found in nightly rust (#1719)
Actual issue was a double reexport which went unnoticed in older rustc versions. Thanks to @bvanjoi in rust-lang/rust#117120 (comment) for pointing out the problem
1 parent c50318d commit 88340de

File tree

12 files changed

+48
-48
lines changed

12 files changed

+48
-48
lines changed

iroh-bytes/src/protocol/range_spec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl RangeSpecSeq {
230230
/// Thus the first call to `.next()` returns the range spec for the first blob, the next
231231
/// call returns the range spec of the second blob, etc.
232232
pub fn iter(&self) -> RequestRangeSpecIter<'_> {
233-
let before_first = self.0.get(0).map(|(c, _)| *c).unwrap_or_default();
233+
let before_first = self.0.first().map(|(c, _)| *c).unwrap_or_default();
234234
RequestRangeSpecIter {
235235
current: &EMPTY_RANGE_SPEC,
236236
count: before_first,
@@ -269,7 +269,7 @@ pub struct RequestRangeSpecIter<'a> {
269269

270270
impl<'a> RequestRangeSpecIter<'a> {
271271
pub fn new(ranges: &'a [(u64, RangeSpec)]) -> Self {
272-
let before_first = ranges.get(0).map(|(c, _)| *c).unwrap_or_default();
272+
let before_first = ranges.first().map(|(c, _)| *c).unwrap_or_default();
273273
RequestRangeSpecIter {
274274
current: &EMPTY_RANGE_SPEC,
275275
count: before_first,
@@ -298,7 +298,7 @@ impl<'a> Iterator for RequestRangeSpecIter<'a> {
298298
} else if let Some(((_, new), rest)) = self.remaining.split_first() {
299299
// get next current value, new count, and set remaining
300300
self.current = new;
301-
self.count = rest.get(0).map(|(c, _)| *c).unwrap_or_default();
301+
self.count = rest.first().map(|(c, _)| *c).unwrap_or_default();
302302
self.remaining = rest;
303303
continue;
304304
} else {

iroh-sync/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ mod ranger;
4040
pub mod store;
4141
pub mod sync;
4242

43-
pub use heads::*;
44-
pub use keys::*;
45-
pub use sync::*;
43+
pub use self::heads::*;
44+
pub use self::keys::*;
45+
pub use self::sync::*;

iroh-sync/src/net/codec.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,8 @@ impl BobState {
295295
mod tests {
296296
use crate::{
297297
actor::OpenOpts,
298+
keys::{AuthorId, Namespace},
298299
store::{self, GetFilter, Store},
299-
sync::Namespace,
300-
AuthorId,
301300
};
302301
use anyhow::Result;
303302
use iroh_bytes::Hash;

iroh-sync/src/store.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use serde::{Deserialize, Serialize};
99

1010
use crate::{
1111
heads::AuthorHeads,
12+
keys::{Author, Namespace},
1213
ranger,
13-
sync::{Author, Namespace, Replica, SignedEntry},
14+
sync::{Replica, SignedEntry},
1415
AuthorId, NamespaceId, PeerIdBytes,
1516
};
1617

iroh-sync/src/store/fs.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ use redb::{
1919
};
2020

2121
use crate::{
22+
keys::{Author, Namespace},
2223
ranger::{Fingerprint, Range, RangeEntry},
2324
store::Store as _,
24-
sync::{
25-
Author, Entry, EntrySignature, Namespace, Record, RecordIdentifier, Replica, SignedEntry,
26-
},
25+
sync::{Entry, EntrySignature, Record, RecordIdentifier, Replica, SignedEntry},
2726
AuthorId, NamespaceId, PeerIdBytes,
2827
};
2928

iroh-sync/src/store/memory.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use iroh_bytes::Hash;
1212
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard};
1313

1414
use crate::{
15+
keys::{Author, Namespace},
1516
ranger::{Fingerprint, Range, RangeEntry},
16-
sync::{Author, Namespace, RecordIdentifier, Replica, SignedEntry},
17+
sync::{RecordIdentifier, Replica, SignedEntry},
1718
AuthorId, NamespaceId, PeerIdBytes, Record,
1819
};
1920

iroh-sync/src/sync.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use std::{
1313
time::{Duration, SystemTime},
1414
};
1515

16-
#[cfg(feature = "metrics")]
17-
use crate::metrics::Metrics;
1816
use bytes::{Bytes, BytesMut};
1917
use derive_more::Deref;
2018
#[cfg(feature = "metrics")]
@@ -25,8 +23,10 @@ use iroh_bytes::Hash;
2523
use serde::{Deserialize, Serialize};
2624

2725
pub use crate::heads::AuthorHeads;
28-
pub use crate::keys::*;
26+
#[cfg(feature = "metrics")]
27+
use crate::metrics::Metrics;
2928
use crate::{
29+
keys::{base32, Author, AuthorId, AuthorPublicKey, Namespace, NamespaceId, NamespacePublicKey},
3030
ranger::{self, Fingerprint, InsertOutcome, Peer, RangeEntry, RangeKey, RangeValue},
3131
store::{self, PublicKeyStore},
3232
};

iroh-test/src/hexdump.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,33 @@ pub fn print_hexdump(bytes: impl AsRef<[u8]>, line_lengths: impl AsRef<[usize]>)
6565
output
6666
}
6767

68+
/// This is a macro to assert that two byte slices are equal.
69+
///
70+
/// It is like assert_eq!, but it will print a nicely formatted hexdump of the
71+
/// two slices if they are not equal. This makes it much easier to track down
72+
/// a difference in a large byte slice.
73+
#[macro_export]
74+
macro_rules! assert_eq_hex {
75+
($a:expr, $b:expr) => {
76+
assert_eq_hex!($a, $b, [])
77+
};
78+
($a:expr, $b:expr, $hint:expr) => {
79+
let a = $a;
80+
let b = $b;
81+
let hint = $hint;
82+
let ar: &[u8] = a.as_ref();
83+
let br: &[u8] = b.as_ref();
84+
let hintr: &[usize] = hint.as_ref();
85+
if ar != br {
86+
panic!(
87+
"assertion failed: `(left == right)`\nleft:\n{}\nright:\n{}\n",
88+
::iroh_test::hexdump::print_hexdump(ar, hintr),
89+
::iroh_test::hexdump::print_hexdump(br, hintr),
90+
)
91+
}
92+
};
93+
}
94+
6895
#[cfg(test)]
6996
mod tests {
7097
use super::{parse_hexdump, print_hexdump};
@@ -151,30 +178,3 @@ mod tests {
151178
assert_eq!(output, "01\n\n\n02 03\n04 05\n06 07\n08\n");
152179
}
153180
}
154-
155-
/// This is a macro to assert that two byte slices are equal.
156-
///
157-
/// It is like assert_eq!, but it will print a nicely formatted hexdump of the
158-
/// two slices if they are not equal. This makes it much easier to track down
159-
/// a difference in a large byte slice.
160-
#[macro_export]
161-
macro_rules! assert_eq_hex {
162-
($a:expr, $b:expr) => {
163-
assert_eq_hex!($a, $b, [])
164-
};
165-
($a:expr, $b:expr, $hint:expr) => {
166-
let a = $a;
167-
let b = $b;
168-
let hint = $hint;
169-
let ar: &[u8] = a.as_ref();
170-
let br: &[u8] = b.as_ref();
171-
let hintr: &[usize] = hint.as_ref();
172-
if ar != br {
173-
panic!(
174-
"assertion failed: `(left == right)`\nleft:\n{}\nright:\n{}\n",
175-
::iroh_test::hexdump::print_hexdump(ar, hintr),
176-
::iroh_test::hexdump::print_hexdump(br, hintr),
177-
)
178-
}
179-
};
180-
}

iroh/examples/dump-blob-stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn stream_children(initial: AtInitial) -> impl Stream<Item = io::Result<Bytes>>
115115
let links: Box<[iroh_bytes::Hash]> = postcard::from_bytes(&links_bytes)
116116
.map_err(|_| io::Error::new(io::ErrorKind::Other, "failed to parse links"))?;
117117
let meta_link = *links
118-
.get(0)
118+
.first()
119119
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "missing meta link"))?;
120120
let (meta_end, _meta_bytes) = at_meta.next(meta_link).concatenate_into_vec().await?;
121121
let mut curr = meta_end.next();

iroh/src/rpc_protocol.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use iroh_net::{
2222
use iroh_sync::{
2323
actor::OpenState,
2424
store::GetFilter,
25-
sync::{NamespaceId, SignedEntry},
26-
AuthorId,
25+
sync::SignedEntry,
26+
{AuthorId, NamespaceId},
2727
};
2828
use quic_rpc::{
2929
message::{BidiStreaming, BidiStreamingMsg, Msg, RpcMsg, ServerStreaming, ServerStreamingMsg},

iroh/src/sync_engine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use iroh_bytes::{store::EntryStatus, util::runtime::Handle, Hash};
1313
use iroh_gossip::net::Gossip;
1414
use iroh_net::{key::PublicKey, MagicEndpoint, PeerAddr};
1515
use iroh_sync::{
16-
actor::SyncHandle, sync::NamespaceId, ContentStatus, ContentStatusCallback, Entry, InsertOrigin,
16+
actor::SyncHandle, ContentStatus, ContentStatusCallback, Entry, InsertOrigin, NamespaceId,
1717
};
1818
use serde::{Deserialize, Serialize};
1919
use tokio::sync::{mpsc, oneshot};

iroh/src/sync_engine/rpc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use anyhow::anyhow;
44
use futures::Stream;
55
use iroh_bytes::{store::Store as BaoStore, util::BlobFormat};
6-
use iroh_sync::{sync::Namespace, Author};
6+
use iroh_sync::{Author, Namespace};
77
use tokio_stream::StreamExt;
88

99
use crate::{

0 commit comments

Comments
 (0)