Skip to content

Commit

Permalink
fix: Remove redundant imports (#2159)
Browse files Browse the repository at this point in the history
## Description

The rust beta compiler does not like redundant imports and fails on
them.  We have them mostly in tests, likely because of how the code
was grown.  This cleans up the redundant imports.

## Notes & open questions

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
  • Loading branch information
flub committed Apr 8, 2024
1 parent 1d51caa commit 43038df
Show file tree
Hide file tree
Showing 26 changed files with 15 additions and 56 deletions.
2 changes: 0 additions & 2 deletions iroh-bytes/src/downloader/test/dialer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

use std::{
collections::HashSet,
sync::Arc,
task::{Context, Poll},
time::Duration,
};

use parking_lot::RwLock;
Expand Down
2 changes: 0 additions & 2 deletions iroh-bytes/src/downloader/test/getter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Implementation of [`super::Getter`] used for testing.

use std::{sync::Arc, time::Duration};

use parking_lot::RwLock;

use super::*;
Expand Down
1 change: 0 additions & 1 deletion iroh-bytes/src/format/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ impl Collection {
#[cfg(test)]
mod tests {
use super::*;
use bao_tree::blake3;

#[test]
fn roundtrip_blob() {
Expand Down
1 change: 0 additions & 1 deletion iroh-bytes/src/protocol/range_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ mod tests {
use std::ops::Range;

use super::*;
use bao_tree::ChunkNum;
use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};
use proptest::prelude::*;

Expand Down
3 changes: 0 additions & 3 deletions iroh-bytes/src/store/bao_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ pub mod test_support {
BlockSize, ChunkRanges,
};
use futures::{Future, Stream, StreamExt};
use iroh_base::hash::Hash;
use rand::RngCore;
use range_collections::RangeSet2;
use tokio::io::{AsyncRead, AsyncReadExt};
Expand Down Expand Up @@ -867,8 +866,6 @@ pub mod test_support {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use bao_tree::{blake3, ChunkNum, ChunkRanges};
use futures::StreamExt;
use tests::test_support::{
Expand Down
1 change: 0 additions & 1 deletion iroh-bytes/src/store/fs/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use bao_tree::ChunkRanges;
use iroh_io::AsyncSliceReaderExt;
use std::io::Cursor;
use std::time::Duration;

use crate::store::bao_file::test_support::{
decode_response_into_batch, make_wire_data, random_test_data, simulate_remote, validate,
Expand Down
6 changes: 1 addition & 5 deletions iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,7 @@ fn decode_peer_data(peer_data: &PeerData) -> anyhow::Result<AddrInfo> {
mod test {
use std::time::Duration;

use iroh_net::NodeAddr;
use iroh_net::{
relay::{RelayMap, RelayMode},
MagicEndpoint,
};
use iroh_net::relay::{RelayMap, RelayMode};
use tokio::spawn;
use tokio::time::timeout;
use tokio_util::sync::CancellationToken;
Expand Down
2 changes: 1 addition & 1 deletion iroh-net/bench/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{convert::TryInto, net::SocketAddr, num::ParseIntError, str::FromStr};
use std::{net::SocketAddr, num::ParseIntError, str::FromStr};

use anyhow::{Context, Result};
use bytes::Bytes;
Expand Down
2 changes: 0 additions & 2 deletions iroh-net/src/bin/iroh-relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,9 @@ mod tests {
use std::net::Ipv4Addr;
use std::time::Duration;

use anyhow::Result;
use bytes::Bytes;
use http_body_util::BodyExt;
use iroh_base::node_addr::RelayUrl;
use iroh_net::key::SecretKey;
use iroh_net::relay::http::ClientBuilder;
use iroh_net::relay::ReceivedMessage;
use tokio::task::JoinHandle;
Expand Down
6 changes: 3 additions & 3 deletions iroh-net/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ mod tests {
collections::{BTreeSet, HashMap},
net::SocketAddr,
sync::Arc,
time::{Duration, SystemTime},
time::SystemTime,
};

use futures::{stream, StreamExt};
use futures::stream;
use parking_lot::Mutex;
use rand::Rng;

use crate::{key::SecretKey, relay::RelayMode, NodeAddr};
use crate::{key::SecretKey, relay::RelayMode};

use super::*;

Expand Down
1 change: 0 additions & 1 deletion iroh-net/src/magicsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2525,7 +2525,6 @@ pub(crate) mod tests {
use futures::StreamExt;
use iroh_test::CallOnDrop;
use rand::RngCore;
use tokio::task::JoinSet;

use crate::{relay::RelayMode, test_utils::run_relay_server, tls, MagicEndpoint};

Expand Down
4 changes: 1 addition & 3 deletions iroh-net/src/magicsock/node_map/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,12 +1387,10 @@ pub enum ConnectionType {
#[cfg(test)]
mod tests {
use std::net::Ipv4Addr;
use std::time::Duration;

use super::{
super::{NodeMap, NodeMapInner},
best_addr::BestAddr,
IpPort, *,
*,
};
use crate::key::SecretKey;

Expand Down
1 change: 0 additions & 1 deletion iroh-net/src/netcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ mod tests {
use tracing::info;

use crate::defaults::{DEFAULT_RELAY_STUN_PORT, EU_RELAY_HOSTNAME};
use crate::net::IpFamily;
use crate::ping::Pinger;
use crate::relay::RelayNode;

Expand Down
2 changes: 0 additions & 2 deletions iroh-net/src/netcheck/reportgen/hairpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ impl Actor {

#[cfg(test)]
mod tests {
use std::net::Ipv4Addr;

use bytes::BytesMut;
use tokio::sync::mpsc;
use tracing::info;
Expand Down
1 change: 0 additions & 1 deletion iroh-net/src/netcheck/reportgen/probes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ mod tests {
use pretty_assertions::assert_eq;

use crate::defaults::default_relay_map;
use crate::net::interfaces;
use crate::netcheck::RelayLatencies;

use super::*;
Expand Down
2 changes: 0 additions & 2 deletions iroh-net/src/relay/client_conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,6 @@ impl ClientConnIo {

#[cfg(test)]
mod tests {
use std::sync::Arc;

use crate::key::SecretKey;
use crate::relay::codec::{recv_frame, FrameType};

Expand Down
5 changes: 1 addition & 4 deletions iroh-net/src/relay/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,7 @@ mod tests {

use crate::{
key::SecretKey,
relay::{
client_conn::ClientConnBuilder,
codec::{recv_frame, DerpCodec, Frame, FrameType},
},
relay::codec::{recv_frame, DerpCodec, Frame, FrameType},
};

use anyhow::Result;
Expand Down
2 changes: 0 additions & 2 deletions iroh-net/src/relay/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,6 @@ pub(super) async fn recv_frame<S: Stream<Item = anyhow::Result<Frame>> + Unpin>(
mod tests {
use tokio_util::codec::{FramedRead, FramedWrite};

use crate::relay::codec::DerpCodec;

use super::*;

#[tokio::test]
Expand Down
4 changes: 1 addition & 3 deletions iroh-net/src/relay/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,15 +472,13 @@ mod tests {

use crate::relay::{
client::ClientBuilder,
client_conn::ClientConnBuilder,
codec::{recv_frame, DerpCodec, FrameType},
codec::{recv_frame, FrameType},
types::ClientInfo,
ReceivedMessage,
};
use tokio_util::codec::{FramedRead, FramedWrite};
use tracing_subscriber::{prelude::*, EnvFilter};

use anyhow::Result;
use bytes::Bytes;
use tokio::io::DuplexStream;

Expand Down
2 changes: 1 addition & 1 deletion iroh-net/src/stun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn parse_response(b: &[u8]) -> Result<(TransactionId, SocketAddr), Error> {
#[cfg(test)]
pub mod test {
use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
net::{IpAddr, Ipv4Addr},
sync::Arc,
};

Expand Down
1 change: 0 additions & 1 deletion iroh-sync/src/store/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,6 @@ fn into_entry(key: RecordsId, value: RecordsValue) -> SignedEntry {
#[cfg(test)]
mod tests {
use crate::ranger::Store as _;
use crate::NamespaceSecret;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion iroh-sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ mod tests {
use crate::{
actor::SyncHandle,
ranger::{Range, Store as _},
store::{self, fs::StoreInstance, OpenError, Query, SortBy, SortDirection, Store},
store::{fs::StoreInstance, OpenError, Query, SortBy, SortDirection, Store},
};

use super::*;
Expand Down
2 changes: 0 additions & 2 deletions iroh/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,10 @@ impl<D> NodeInner<D> {

#[cfg(test)]
mod tests {
use std::path::Path;
use std::time::Duration;

use anyhow::{bail, Context};
use bytes::Bytes;
use futures::StreamExt;
use iroh_bytes::provider::AddProgress;

use crate::rpc_protocol::{BlobAddPathRequest, BlobAddPathResponse, SetTagOption, WrapOption};
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/ticket/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod tests {
use super::*;
use iroh_base::base32;
use iroh_net::key::PublicKey;
use iroh_sync::{Capability, NamespaceId};
use iroh_sync::NamespaceId;
use iroh_test::{assert_eq_hex, hexdump::parse_hexdump};

#[test]
Expand Down
1 change: 0 additions & 1 deletion iroh/src/util/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ pub fn canonicalized_path_to_string(
#[cfg(test)]
mod tests {
use super::*;
use crate::util::fs::{path_content_info, PathContent};

#[test]
fn test_path_to_key_roundtrip() {
Expand Down
13 changes: 4 additions & 9 deletions iroh/tests/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,20 @@ async fn gc_hashseq_impl() -> Result<()> {
#[cfg(feature = "fs-store")]
mod file {
use super::*;
use std::{io, path::PathBuf, time::Duration};
use std::{io, path::PathBuf};

use anyhow::Result;
use bao_tree::{
io::fsm::{BaoContentItem, ResponseDecoderNext},
BaoTree, ChunkRanges,
BaoTree,
};
use bytes::Bytes;
use futures::StreamExt;
use iroh_io::AsyncSliceReaderExt;
use testdir::testdir;

use iroh_bytes::{
hashseq::HashSeq,
store::{
BaoBatchWriter, ConsistencyCheckProgress, Map, MapEntryMut, MapMut, ReportLevel, Store,
},
store::{BaoBatchWriter, ConsistencyCheckProgress, Map, MapEntryMut, ReportLevel},
util::progress::{FlumeProgressSender, ProgressSender as _},
BlobFormat, HashAndFormat, Tag, TempTag, IROH_BLOCK_SIZE,
TempTag,
};
use tokio::io::AsyncReadExt;

Expand Down

0 comments on commit 43038df

Please sign in to comment.