Skip to content

Commit

Permalink
fix unused export found in nightly rust (#1719)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dignifiedquire authored Oct 24, 2023
1 parent c50318d commit 88340de
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 48 deletions.
6 changes: 3 additions & 3 deletions iroh-bytes/src/protocol/range_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl RangeSpecSeq {
/// Thus the first call to `.next()` returns the range spec for the first blob, the next
/// call returns the range spec of the second blob, etc.
pub fn iter(&self) -> RequestRangeSpecIter<'_> {
let before_first = self.0.get(0).map(|(c, _)| *c).unwrap_or_default();
let before_first = self.0.first().map(|(c, _)| *c).unwrap_or_default();
RequestRangeSpecIter {
current: &EMPTY_RANGE_SPEC,
count: before_first,
Expand Down Expand Up @@ -269,7 +269,7 @@ pub struct RequestRangeSpecIter<'a> {

impl<'a> RequestRangeSpecIter<'a> {
pub fn new(ranges: &'a [(u64, RangeSpec)]) -> Self {
let before_first = ranges.get(0).map(|(c, _)| *c).unwrap_or_default();
let before_first = ranges.first().map(|(c, _)| *c).unwrap_or_default();
RequestRangeSpecIter {
current: &EMPTY_RANGE_SPEC,
count: before_first,
Expand Down Expand Up @@ -298,7 +298,7 @@ impl<'a> Iterator for RequestRangeSpecIter<'a> {
} else if let Some(((_, new), rest)) = self.remaining.split_first() {
// get next current value, new count, and set remaining
self.current = new;
self.count = rest.get(0).map(|(c, _)| *c).unwrap_or_default();
self.count = rest.first().map(|(c, _)| *c).unwrap_or_default();
self.remaining = rest;
continue;
} else {
Expand Down
6 changes: 3 additions & 3 deletions iroh-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ mod ranger;
pub mod store;
pub mod sync;

pub use heads::*;
pub use keys::*;
pub use sync::*;
pub use self::heads::*;
pub use self::keys::*;
pub use self::sync::*;
3 changes: 1 addition & 2 deletions iroh-sync/src/net/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,8 @@ impl BobState {
mod tests {
use crate::{
actor::OpenOpts,
keys::{AuthorId, Namespace},
store::{self, GetFilter, Store},
sync::Namespace,
AuthorId,
};
use anyhow::Result;
use iroh_bytes::Hash;
Expand Down
3 changes: 2 additions & 1 deletion iroh-sync/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use serde::{Deserialize, Serialize};

use crate::{
heads::AuthorHeads,
keys::{Author, Namespace},
ranger,
sync::{Author, Namespace, Replica, SignedEntry},
sync::{Replica, SignedEntry},
AuthorId, NamespaceId, PeerIdBytes,
};

Expand Down
5 changes: 2 additions & 3 deletions iroh-sync/src/store/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ use redb::{
};

use crate::{
keys::{Author, Namespace},
ranger::{Fingerprint, Range, RangeEntry},
store::Store as _,
sync::{
Author, Entry, EntrySignature, Namespace, Record, RecordIdentifier, Replica, SignedEntry,
},
sync::{Entry, EntrySignature, Record, RecordIdentifier, Replica, SignedEntry},
AuthorId, NamespaceId, PeerIdBytes,
};

Expand Down
3 changes: 2 additions & 1 deletion iroh-sync/src/store/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use iroh_bytes::Hash;
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard};

use crate::{
keys::{Author, Namespace},
ranger::{Fingerprint, Range, RangeEntry},
sync::{Author, Namespace, RecordIdentifier, Replica, SignedEntry},
sync::{RecordIdentifier, Replica, SignedEntry},
AuthorId, NamespaceId, PeerIdBytes, Record,
};

Expand Down
6 changes: 3 additions & 3 deletions iroh-sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use std::{
time::{Duration, SystemTime},
};

#[cfg(feature = "metrics")]
use crate::metrics::Metrics;
use bytes::{Bytes, BytesMut};
use derive_more::Deref;
#[cfg(feature = "metrics")]
Expand All @@ -25,8 +23,10 @@ use iroh_bytes::Hash;
use serde::{Deserialize, Serialize};

pub use crate::heads::AuthorHeads;
pub use crate::keys::*;
#[cfg(feature = "metrics")]
use crate::metrics::Metrics;
use crate::{
keys::{base32, Author, AuthorId, AuthorPublicKey, Namespace, NamespaceId, NamespacePublicKey},
ranger::{self, Fingerprint, InsertOutcome, Peer, RangeEntry, RangeKey, RangeValue},
store::{self, PublicKeyStore},
};
Expand Down
54 changes: 27 additions & 27 deletions iroh-test/src/hexdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ pub fn print_hexdump(bytes: impl AsRef<[u8]>, line_lengths: impl AsRef<[usize]>)
output
}

/// This is a macro to assert that two byte slices are equal.
///
/// It is like assert_eq!, but it will print a nicely formatted hexdump of the
/// two slices if they are not equal. This makes it much easier to track down
/// a difference in a large byte slice.
#[macro_export]
macro_rules! assert_eq_hex {
($a:expr, $b:expr) => {
assert_eq_hex!($a, $b, [])
};
($a:expr, $b:expr, $hint:expr) => {
let a = $a;
let b = $b;
let hint = $hint;
let ar: &[u8] = a.as_ref();
let br: &[u8] = b.as_ref();
let hintr: &[usize] = hint.as_ref();
if ar != br {
panic!(
"assertion failed: `(left == right)`\nleft:\n{}\nright:\n{}\n",
::iroh_test::hexdump::print_hexdump(ar, hintr),
::iroh_test::hexdump::print_hexdump(br, hintr),
)
}
};
}

#[cfg(test)]
mod tests {
use super::{parse_hexdump, print_hexdump};
Expand Down Expand Up @@ -151,30 +178,3 @@ mod tests {
assert_eq!(output, "01\n\n\n02 03\n04 05\n06 07\n08\n");
}
}

/// This is a macro to assert that two byte slices are equal.
///
/// It is like assert_eq!, but it will print a nicely formatted hexdump of the
/// two slices if they are not equal. This makes it much easier to track down
/// a difference in a large byte slice.
#[macro_export]
macro_rules! assert_eq_hex {
($a:expr, $b:expr) => {
assert_eq_hex!($a, $b, [])
};
($a:expr, $b:expr, $hint:expr) => {
let a = $a;
let b = $b;
let hint = $hint;
let ar: &[u8] = a.as_ref();
let br: &[u8] = b.as_ref();
let hintr: &[usize] = hint.as_ref();
if ar != br {
panic!(
"assertion failed: `(left == right)`\nleft:\n{}\nright:\n{}\n",
::iroh_test::hexdump::print_hexdump(ar, hintr),
::iroh_test::hexdump::print_hexdump(br, hintr),
)
}
};
}
2 changes: 1 addition & 1 deletion iroh/examples/dump-blob-stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn stream_children(initial: AtInitial) -> impl Stream<Item = io::Result<Bytes>>
let links: Box<[iroh_bytes::Hash]> = postcard::from_bytes(&links_bytes)
.map_err(|_| io::Error::new(io::ErrorKind::Other, "failed to parse links"))?;
let meta_link = *links
.get(0)
.first()
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "missing meta link"))?;
let (meta_end, _meta_bytes) = at_meta.next(meta_link).concatenate_into_vec().await?;
let mut curr = meta_end.next();
Expand Down
4 changes: 2 additions & 2 deletions iroh/src/rpc_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use iroh_net::{
use iroh_sync::{
actor::OpenState,
store::GetFilter,
sync::{NamespaceId, SignedEntry},
AuthorId,
sync::SignedEntry,
{AuthorId, NamespaceId},
};
use quic_rpc::{
message::{BidiStreaming, BidiStreamingMsg, Msg, RpcMsg, ServerStreaming, ServerStreamingMsg},
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/sync_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use iroh_bytes::{store::EntryStatus, util::runtime::Handle, Hash};
use iroh_gossip::net::Gossip;
use iroh_net::{key::PublicKey, MagicEndpoint, PeerAddr};
use iroh_sync::{
actor::SyncHandle, sync::NamespaceId, ContentStatus, ContentStatusCallback, Entry, InsertOrigin,
actor::SyncHandle, ContentStatus, ContentStatusCallback, Entry, InsertOrigin, NamespaceId,
};
use serde::{Deserialize, Serialize};
use tokio::sync::{mpsc, oneshot};
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/sync_engine/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use anyhow::anyhow;
use futures::Stream;
use iroh_bytes::{store::Store as BaoStore, util::BlobFormat};
use iroh_sync::{sync::Namespace, Author};
use iroh_sync::{Author, Namespace};
use tokio_stream::StreamExt;

use crate::{
Expand Down

0 comments on commit 88340de

Please sign in to comment.