Skip to content

Commit

Permalink
Fix Clippy warnings on nightly (#2810)
Browse files Browse the repository at this point in the history
Our nightly build is failing due to some dead code warnings that aren't being
triggered on stable.

This change runs `cargo +nightly clippy --fix` and then manually fixes the
remaining issues.

This change also updates the nightly and beta workflows so that they may be
triggered manually.
  • Loading branch information
olix0r authored Mar 19, 2024
1 parent 5e97665 commit c5cff4b
Show file tree
Hide file tree
Showing 30 changed files with 33 additions and 79 deletions.
1 change: 1 addition & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: rust-beta

on:
workflow_dispatch: {}
pull_request:
paths:
- justfile
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: rust-nightly

on:
workflow_dispatch: {}
pull_request:
paths:
- justfile
Expand Down
2 changes: 1 addition & 1 deletion hyper-balance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ mod tests {
assert!(wk.upgrade().is_none());
}

struct Handle(Arc<()>);
struct Handle(#[allow(dead_code)] Arc<()>);
impl Handle {
fn new() -> (Self, Weak<()>) {
let strong = Arc::new(());
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/admin/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ mod tests {
use super::*;
use http::method::Method;
use std::time::Duration;
use tokio::{sync::mpsc, time::timeout};
use tokio::time::timeout;
use tower::util::ServiceExt;

const TIMEOUT: Duration = Duration::from_secs(1);
Expand Down
4 changes: 1 addition & 3 deletions linkerd/app/gateway/src/http/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use super::*;
use linkerd_app_core::{
proxy::http,
svc::{NewService, ServiceExt},
tls,
trace::test::trace_init,
Error, NameAddr,
NameAddr,
};
use linkerd_app_inbound::GatewayLoop;
use linkerd_proxy_server_policy as policy;
Expand Down
5 changes: 1 addition & 4 deletions linkerd/app/inbound/src/accept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ mod tests {
test_util,
};
use futures::future;
use linkerd_app_core::{
svc::{NewService, ServiceExt},
Error,
};
use linkerd_app_core::svc::{NewService, ServiceExt};
use linkerd_proxy_server_policy::{Authentication, Authorization, Meta, ServerPolicy};
use std::sync::Arc;

Expand Down
4 changes: 2 additions & 2 deletions linkerd/app/inbound/src/detect/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use futures::future;
use linkerd_app_core::{
io::AsyncWriteExt,
svc::{NewService, ServiceExt},
trace, Error,
trace,
};
use linkerd_proxy_server_policy::{Authentication, Authorization, Meta, Protocol, ServerPolicy};
use linkerd_proxy_server_policy::{Authentication, Authorization, Meta, ServerPolicy};
use std::sync::Arc;

const HTTP1: &[u8] = b"GET / HTTP/1.1\r\nhost: example.com\r\n\r\n";
Expand Down
1 change: 0 additions & 1 deletion linkerd/app/inbound/src/policy/http/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::*;
use crate::policy::{Authentication, Authorization, Meta, Protocol, ServerPolicy};
use linkerd_app_core::{svc::Service, Infallible};
use std::sync::Arc;

macro_rules! conn {
($client:expr, $dst:expr) => {{
Expand Down
7 changes: 2 additions & 5 deletions linkerd/app/inbound/src/policy/tcp/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use super::*;
use crate::policy::*;
use linkerd_app_core::{proxy::http, Error};
use linkerd_proxy_server_policy::{
authz::Suffix, Authentication, Authorization, Protocol, ServerPolicy,
};
use std::{collections::BTreeSet, sync::Arc};
use linkerd_app_core::proxy::http;
use std::collections::BTreeSet;

#[derive(Clone)]
pub(crate) struct MockSvc;
Expand Down
7 changes: 2 additions & 5 deletions linkerd/app/integration/src/tests/identity.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use crate::*;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
time::{Duration, SystemTime},
sync::atomic::{AtomicBool, Ordering},
time::SystemTime,
};

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/integration/src/tests/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ mod http2 {

mod grpc_retry {
use super::*;
use http::header::{HeaderMap, HeaderName, HeaderValue};
use http::header::{HeaderName, HeaderValue};
static GRPC_STATUS: HeaderName = HeaderName::from_static("grpc-status");
static GRPC_STATUS_OK: HeaderValue = HeaderValue::from_static("0");
static GRPC_STATUS_UNAVAILABLE: HeaderValue = HeaderValue::from_static("14");
Expand Down
1 change: 0 additions & 1 deletion linkerd/app/integration/src/tests/transparency.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::*;
use std::error::Error as _;
use tokio::sync::mpsc;
use tokio::time::timeout;

#[tokio::test]
Expand Down
10 changes: 3 additions & 7 deletions linkerd/app/outbound/src/discover/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ use crate::test_util::*;
use linkerd_app_core::{
io,
svc::{NewService, Service, ServiceExt},
transport::addrs::OrigDstAddr,
};
use std::{
net::SocketAddr,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
},
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
use tokio::time;

Expand Down
6 changes: 1 addition & 5 deletions linkerd/app/outbound/src/http/handle_proxy_error_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ fn update_response<B>(rsp: &mut http::Response<B>, closable: bool) -> bool {
#[cfg(test)]
mod test {
use super::*;
use futures::future;
use linkerd_app_core::{
svc::{self, ServiceExt},
Infallible,
};
use linkerd_app_core::{svc::ServiceExt, Infallible};
use linkerd_tracing::test;
use tokio::time;

Expand Down
4 changes: 2 additions & 2 deletions linkerd/app/outbound/src/http/logical/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use super::*;
use crate::test_util::*;
use ::http::StatusCode;
use linkerd_app_core::{
errors, exp_backoff::ExponentialBackoff, svc::NewService, svc::ServiceExt, trace, Error,
errors, exp_backoff::ExponentialBackoff, svc::NewService, svc::ServiceExt, trace,
};
use linkerd_proxy_client_policy as client_policy;
use parking_lot::Mutex;
use std::{collections::HashMap, net::SocketAddr, sync::Arc, time::Duration};
use tokio::{sync::watch, task, time};
use tokio::{task, time};
use tracing::Instrument;

const AUTHORITY: &str = "logical.test.svc.cluster.local";
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/src/ingress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ impl From<RequestTarget> for Addr {
#[cfg(test)]
mod tests {
use super::*;
use svc::{NewService, ServiceExt};
use svc::NewService;
use tokio::{io::AsyncReadExt, io::AsyncWriteExt, time};
use tower_test::mock;

Expand Down
5 changes: 2 additions & 3 deletions linkerd/app/outbound/src/opaq/logical/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::test_util::*;
use io::AsyncWriteExt;
use linkerd_app_core::{
errors::{self, FailFastError},
io::{self, AsyncReadExt},
profiles::{self, Profile},
svc::{self, NewService, ServiceExt},
io::AsyncReadExt,
svc::{NewService, ServiceExt},
};
use std::net::SocketAddr;
use tokio::time;
Expand Down
4 changes: 1 addition & 3 deletions linkerd/app/outbound/src/tcp/tagged_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ where
#[cfg(test)]
mod test {
use super::*;
use futures::future;
use linkerd_app_core::{
io::{self, AsyncWriteExt},
tls,
transport::{ClientAddr, Local},
transport_header::{self, TransportHeader},
transport_header,
};
use tower::util::{service_fn, ServiceExt};

Expand Down
16 changes: 1 addition & 15 deletions linkerd/app/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use crate::spire;
pub use linkerd_app_core::identity::{client, Id};
use linkerd_app_core::{
control, dns,
exp_backoff::{ExponentialBackoff, ExponentialBackoffStream},
identity::{
client::linkerd::Certify, creds, CertMetrics, Credentials, DerX509, Mode, WithCertMetrics,
},
metrics::{prom, ControlHttp as ClientMetrics},
Error, Result,
Result,
};
use std::{future::Future, pin::Pin, time::SystemTime};
use tokio::sync::watch;
Expand Down Expand Up @@ -47,9 +46,6 @@ pub struct Identity {

pub type Task = Pin<Box<dyn Future<Output = ()> + Send + 'static>>;

#[derive(Clone, Debug)]
struct Recover(ExponentialBackoff);

/// Wraps a credential with a watch sender that notifies receivers when the store has been updated
/// at least once.
struct NotifyReady {
Expand Down Expand Up @@ -177,13 +173,3 @@ impl Identity {
self.task
}
}

// === impl Recover ===

impl<E: Into<Error>> linkerd_error::Recover<E> for Recover {
type Backoff = ExponentialBackoffStream;

fn recover(&self, _: E) -> Result<Self::Backoff, E> {
Ok(self.0.stream())
}
}
4 changes: 2 additions & 2 deletions linkerd/http-retry/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ where
if !rest.is_end_stream() {
let res = futures::ready!(Pin::new(rest).poll_trailers(cx)).map(|tlrs| {
if state.trailers.is_none() {
state.trailers = tlrs.clone();
state.trailers.clone_from(&tlrs);
}
tlrs
});
Expand Down Expand Up @@ -503,7 +503,7 @@ impl<B> BodyState<B> {
#[cfg(test)]
mod tests {
use super::*;
use http::{HeaderMap, HeaderValue};
use http::HeaderValue;

#[tokio::test]
async fn replays_one_chunk() {
Expand Down
4 changes: 2 additions & 2 deletions linkerd/idle-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ where
Self { inner, idle }
}

pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<Cached<V>>
pub fn get<Q>(&self, key: &Q) -> Option<Cached<V>>
where
K: Borrow<Q>,
Q: Hash + Eq + fmt::Debug,
Q: Hash + Eq + fmt::Debug + ?Sized,
V: Clone,
{
let cache = self.inner.read();
Expand Down
4 changes: 2 additions & 2 deletions linkerd/meshtls/rustls/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Server {
let mut orig_rx = self.rx;

let mut c = (**orig_rx.borrow_and_update()).clone();
c.alpn_protocols = alpn_protocols.clone();
c.alpn_protocols.clone_from(&alpn_protocols);
let (tx, rx) = watch::channel(c.into());

// Spawn a background task that watches the optional server configuration and publishes it
Expand All @@ -74,7 +74,7 @@ impl Server {
}

let mut c = (*orig_rx.borrow().clone()).clone();
c.alpn_protocols = alpn_protocols.clone();
c.alpn_protocols.clone_from(&alpn_protocols);
let _ = tx.send(c.into());
}
});
Expand Down
3 changes: 1 addition & 2 deletions linkerd/meshtls/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use linkerd_meshtls as meshtls;
use linkerd_proxy_transport::{
addrs::*,
listen::{Addrs, Bind, BindTcp},
ConnectTcp, Keepalive, ListenAddr,
ConnectTcp, Keepalive,
};
use linkerd_stack::{
layer::Layer, service_fn, ExtractParam, InsertParam, NewService, Param, ServiceExt,
Expand All @@ -21,7 +21,6 @@ use linkerd_tls_test_util as test_util;
use rcgen::{BasicConstraints, Certificate, CertificateParams, IsCa, SanType};
use std::str::FromStr;
use std::{
future::Future,
net::SocketAddr,
sync::mpsc,
time::{Duration, SystemTime},
Expand Down
1 change: 0 additions & 1 deletion linkerd/proxy/api-resolve/src/pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ pub(crate) fn to_sock_addr(pb: TcpAddress) -> Option<SocketAddr> {
#[cfg(test)]
mod tests {
use super::*;
use crate::api::destination::TlsIdentity;
use linkerd2_proxy_api::destination::tls_identity::{
DnsLikeIdentity, Strategy, UriLikeIdentity,
};
Expand Down
5 changes: 1 addition & 4 deletions linkerd/proxy/http/src/classify/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,8 @@ impl<C: ClassifyEos, B> PinnedDrop for ResponseBody<C, B> {
#[cfg(test)]
mod tests {
use super::*;
use crate::classify::ClassifyResponse;
use linkerd_error::Error;
use linkerd_http_box::BoxBody;
use linkerd_http_classify::ClassifyEos;
use tokio::{sync::mpsc, time};
use tokio::time;
use tokio_test::assert_ready;
use tower_test::mock;

Expand Down
3 changes: 1 addition & 2 deletions linkerd/proxy/spire-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ mod tests {
use super::*;
use crate::api::Svid;
use linkerd_error::Result;
use linkerd_identity::{Credentials, DerX509, Id};
use linkerd_identity::DerX509;
use rcgen::{Certificate, CertificateParams, SanType, SerialNumber};
use std::time::SystemTime;
use tokio::sync::watch;

fn gen_svid(id: Id, subject_alt_names: Vec<SanType>, serial: SerialNumber) -> Svid {
let mut params = CertificateParams::default();
Expand Down
1 change: 0 additions & 1 deletion linkerd/proxy/tap/src/grpc/match_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ impl TryFrom<observe_request::r#match::Http> for HttpMatch {
#[cfg(test)]
mod tests {
use super::*;
use ipnet::{Ipv4Net, Ipv6Net};
use linkerd2_proxy_api::http_types;
use quickcheck::*;
use std::collections::HashMap;
Expand Down
1 change: 0 additions & 1 deletion linkerd/stack/src/failfast/test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::*;
use std::time::Duration;
use tokio_test::{assert_pending, assert_ready, assert_ready_err, assert_ready_ok, task};
use tower_test::mock::{self, Spawn};

Expand Down
1 change: 0 additions & 1 deletion linkerd/stack/src/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ impl<T, N, S: Clone> Clone for Lazy<T, N, S> {
mod tests {
use super::*;
use crate::layer::Layer;
use std::sync::Arc;
use tokio_test::{assert_pending, assert_ready_ok};
use tower::ServiceExt;
use tower_test::mock;
Expand Down
1 change: 0 additions & 1 deletion linkerd/stack/src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::NewService;
use tokio::sync::watch;
use tower::ServiceExt;
use tower_test::mock;
Expand Down

0 comments on commit c5cff4b

Please sign in to comment.