cleanup all clippy warnings

This commit is contained in:
Benjamin Fry 2019-10-17 12:43:32 -07:00
parent f8920e8422
commit 8bcfdd3c4f
28 changed files with 68 additions and 45 deletions

View File

@ -57,15 +57,15 @@ where
// check if someone else stored the result
if let Some(result) = stored_result.as_ref() {
return Poll::Ready(result.clone());
Poll::Ready(result.clone())
} else {
// the poll on the future should wake this thread
return Poll::Pending;
Poll::Pending
}
} else {
// TODO: track wakers in a queue instead...
cx.waker().wake_by_ref();
return Poll::Pending;
Poll::Pending
}
}
}

View File

@ -237,7 +237,7 @@ impl DnsRequestSender for HttpsClientStream {
let bytes = match message.to_vec() {
Ok(bytes) => bytes,
Err(err) => return HttpsClientResponse(Box::pin(future::err(err.into()))),
Err(err) => return HttpsClientResponse(Box::pin(future::err(err))),
};
let message = SerialMessage::new(bytes, self.name_server);
@ -250,7 +250,7 @@ impl DnsRequestSender for HttpsClientStream {
}
fn error_response(error: ProtoError) -> Self::DnsResponseFuture {
HttpsClientResponse(Box::pin(future::err(error.into())))
HttpsClientResponse(Box::pin(future::err(error)))
}
fn shutdown(&mut self) {
@ -272,7 +272,7 @@ impl Stream for HttpsClientStream {
// just checking if the connection is ok
match self.h2.poll_ready(cx) {
Poll::Ready(Ok(r)) => Poll::Ready(Some(Ok(r))),
Poll::Ready(Ok(())) => Poll::Ready(Some(Ok(()))),
Poll::Pending => Poll::Pending,
Poll::Ready(Err(e)) => Poll::Ready(Some(Err(ProtoError::from(format!(
"h2 stream errored: {}",
@ -357,6 +357,7 @@ struct TlsConfig {
}
#[allow(clippy::large_enum_variant)]
#[allow(clippy::type_complexity)]
enum HttpsClientConnectState {
ConnectTcp {
name_server: SocketAddr,
@ -408,7 +409,7 @@ impl Future for HttpsClientConnectState {
let connect = Box::pin(TokioTcpStream::connect(name_server));
HttpsClientConnectState::TcpConnecting {
connect,
name_server: name_server,
name_server,
tls: tls.take(),
}
}
@ -432,7 +433,7 @@ impl Future for HttpsClientConnectState {
let tls = tls.connect(dns_name, tcp);
HttpsClientConnectState::TlsConnecting {
name_server_name,
name_server: name_server,
name_server,
tls,
}
}
@ -454,7 +455,7 @@ impl Future for HttpsClientConnectState {
let handshake = handshake.handshake(tls);
HttpsClientConnectState::H2Handshake {
name_server_name: Arc::clone(&name_server_name),
name_server: name_server,
name_server,
handshake: Box::pin(handshake),
}
}
@ -477,7 +478,7 @@ impl Future for HttpsClientConnectState {
HttpsClientConnectState::Connected(Some(HttpsClientStream {
name_server_name: Arc::clone(&name_server_name),
name_server: name_server,
name_server,
h2: send_request,
is_shutdown: false,
}))

View File

@ -118,10 +118,12 @@ pub fn verify<T>(name_server: &str, request: &Request<T>) -> HttpsResult<()> {
let accept = accept.ok_or_else(|| "Accept is unspecified")?;
// TODO: switch to mime::APPLICATION_DNS when that stabilizes
if !accept.iter().any(|q| {
let any_application_and_dns = |q: &QualityItem<Mime>| -> bool {
(q.item.type_() == crate::MIME_APPLICATION && q.item.subtype() == crate::MIME_DNS_BINARY)
}) {
};
// TODO: switch to mime::APPLICATION_DNS when that stabilizes
if !accept.iter().any(any_application_and_dns) {
return Err("does not accept content type".into());
}

View File

@ -56,6 +56,7 @@ impl TlsClientStreamBuilder {
///
/// * `name_server` - IP and Port for the remote DNS resolver
/// * `dns_name` - The DNS name, Subject Public Key Info (SPKI) name, as associated to a certificate
#[allow(clippy::type_complexity)]
pub fn build(
self,
name_server: SocketAddr,

View File

@ -112,6 +112,7 @@ impl TlsStreamBuilder {
///
/// * `name_server` - IP and Port for the remote DNS resolver
/// * `dns_name` - The DNS name, Public Key Info (SPKI) name, as associated to a certificate
#[allow(clippy::type_complexity)]
pub fn build(
self,
name_server: SocketAddr,

View File

@ -64,6 +64,7 @@ impl TlsClientStreamBuilder {
///
/// * `name_server` - IP and Port for the remote DNS resolver
/// * `dns_name` - The DNS name, Subject Public Key Info (SPKI) name, as associated to a certificate
#[allow(clippy::type_complexity)]
pub fn build(
self,
name_server: SocketAddr,

View File

@ -201,6 +201,7 @@ impl TlsStreamBuilder {
///
/// * `name_server` - IP and Port for the remote DNS resolver
/// * `dns_name` - The DNS name, Subject Public Key Info (SPKI) name, as associated to a certificate
#[allow(clippy::type_complexity)]
pub fn build(
self,
name_server: SocketAddr,

View File

@ -414,11 +414,9 @@ mod tests {
let mut decoder: BinDecoder = BinDecoder::new(bytes);
let read_rdata = read(&mut decoder, Restrict::new(bytes.len() as u16));
assert!(
read_rdata.is_ok(),
format!("error decoding: {:?}", read_rdata.unwrap_err())
);
assert_eq!(rdata, read_rdata.unwrap());
let read_rdata = read_rdata.expect("error decoding");
assert_eq!(rdata, read_rdata);
assert!(rdata
.to_digest(
&Name::parse("www.example.com.", None).unwrap(),

View File

@ -230,6 +230,7 @@ impl<S: tokio_io::AsyncRead + tokio_io::AsyncWrite> TcpStream<S> {
impl<S: tokio_io::AsyncRead + tokio_io::AsyncWrite + Unpin> Stream for TcpStream<S> {
type Item = io::Result<SerialMessage>;
#[allow(clippy::cognitive_complexity)]
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {
let peer = self.peer_addr;
let (socket, outbound_messages, send_state, read_state) = self.pollable_split();
@ -266,7 +267,7 @@ impl<S: tokio_io::AsyncRead + tokio_io::AsyncWrite + Unpin> Stream for TcpStream
}
// get current state
let current_state = mem::replace(send_state, None);
let current_state = send_state.take();
// switch states
match current_state {
@ -291,7 +292,7 @@ impl<S: tokio_io::AsyncRead + tokio_io::AsyncWrite + Unpin> Stream for TcpStream
}
Some(WriteTcpState::Flushing) => {
// At this point we successfully delivered the entire message.
mem::replace(send_state, None);
send_state.take();
}
None => (),
};
@ -433,12 +434,12 @@ impl<S: tokio_io::AsyncRead + tokio_io::AsyncWrite + Unpin> Stream for TcpStream
if let Some(buffer) = ret_buf {
debug!("returning buffer");
let src_addr = self.peer_addr;
return Poll::Ready(Some(Ok(SerialMessage::new(buffer, src_addr))));
Poll::Ready(Some(Ok(SerialMessage::new(buffer, src_addr))))
} else {
debug!("bottomed out");
// at a minimum the outbound_messages should have been polled,
// which will wake this future up later...
return Poll::Pending;
Poll::Pending
}
}
}

View File

@ -187,6 +187,7 @@ impl<S: Send, MF: MessageFinalizer> Stream for UdpClientStream<S, MF> {
}
/// A future that resolves to
#[allow(clippy::type_complexity)]
pub struct UdpResponse(
Pin<Box<dyn Future<Output = Result<Result<DnsResponse, ProtoError>, Elapsed>> + Send>>,
);

View File

@ -60,6 +60,7 @@ impl<S: UdpSocket + Send + 'static> UdpStream<S> {
///
/// a tuple of a Future Stream which will handle sending and receiving messages, and a
/// handle which can be used to send messages into the stream.
#[allow(clippy::type_complexity)]
pub fn new(
name_server: SocketAddr,
) -> (
@ -127,6 +128,7 @@ impl<S: UdpSocket + Send + 'static> UdpStream<S> {
}
impl<S: Send> UdpStream<S> {
#[allow(clippy::type_complexity)]
fn pollable_split(
&mut self,
) -> (

View File

@ -212,6 +212,7 @@ impl<H: DnsHandle + Unpin> DnsHandle for SecureDnsHandle<H> {
}
/// A future to verify all RRSets in a returned Message.
#[allow(clippy::type_complexity)]
struct VerifyRrsetsFuture {
message_result: Option<DnsResponse>,
rrsets: SelectAll<Pin<Box<dyn Future<Output = Result<Rrset, ProtoError>> + Send>>>,
@ -220,6 +221,7 @@ struct VerifyRrsetsFuture {
/// this pulls all records returned in a Message response and returns a future which will
/// validate all of them.
#[allow(clippy::type_complexity)]
fn verify_rrsets<H: DnsHandle + Unpin>(
handle: &SecureDnsHandle<H>,
message_result: DnsResponse,

View File

@ -17,6 +17,7 @@ use proto::error::ProtoError;
use proto::BufDnsStreamHandle;
use trust_dns_native_tls::{TlsClientStream, TlsClientStreamBuilder};
#[allow(clippy::type_complexity)]
pub(crate) fn new_tls_stream(
socket_addr: SocketAddr,
dns_name: String,

View File

@ -17,6 +17,7 @@ use proto::error::ProtoError;
use proto::BufDnsStreamHandle;
use trust_dns_openssl::{TlsClientStream, TlsClientStreamBuilder};
#[allow(clippy::type_complexity)]
pub(crate) fn new_tls_stream(
socket_addr: SocketAddr,
dns_name: String,

View File

@ -37,6 +37,7 @@ lazy_static! {
};
}
#[allow(clippy::type_complexity)]
pub(crate) fn new_tls_stream(
socket_addr: SocketAddr,
dns_name: String,

View File

@ -27,6 +27,7 @@ pub type TlsClientStream = TcpClientStream<tokio_rustls::client::TlsStream<Tokio
///
/// * `name_server` - IP and Port for the remote DNS resolver
/// * `dns_name` - The DNS name, Subject Public Key Info (SPKI) name, as associated to a certificate
#[allow(clippy::type_complexity)]
pub fn tls_client_connect(
name_server: SocketAddr,
dns_name: String,

View File

@ -66,6 +66,7 @@ pub fn tls_from_stream<S: tokio_io::AsyncRead + tokio_io::AsyncWrite>(
///
/// * `name_server` - IP and Port for the remote DNS resolver
/// * `dns_name` - The DNS name, Subject Public Key Info (SPKI) name, as associated to a certificate
#[allow(clippy::type_complexity)]
pub fn tls_connect(
name_server: SocketAddr,
dns_name: String,

View File

@ -282,6 +282,7 @@ impl LookupObject for EmptyLookup {
}
/// A boxed lookup future
#[allow(clippy::type_complexity)]
pub struct BoxedLookupFuture(
Pin<Box<dyn Future<Output = Result<Box<dyn LookupObject>, LookupError>> + Send>>,
);

View File

@ -648,6 +648,7 @@ impl<R: ResponseHandler> AuthorityLookup<R> {
}
impl<R: ResponseHandler> AuthorityLookup<R> {
#[allow(clippy::type_complexity)]
fn split(
&mut self,
) -> (

View File

@ -467,7 +467,6 @@ pub fn main() {
// Ideally the processing would be n-threads for receiving, which hand off to m-threads for
// request handling. It would generally be the case that n <= m.
info!("Server starting up");
()
}));
io_loop.spawn(server_future);

View File

@ -363,8 +363,6 @@ impl<T: RequestHandler> ServerFuture<T> {
})
.map(|_: Result<(), ()>| ()),
);
()
})
.map_err(move |e| debug!("error handling TLS stream {}: {}", src_addr, e))
.map(|_: Result<(), ()>| Ok(()))

View File

@ -80,17 +80,17 @@ where
Poll::Pending => {
if let Some(ref mut timeout) = self.timeout {
match timeout.poll_unpin(cx) {
Poll::Pending => return Poll::Pending,
Poll::Pending => Poll::Pending,
Poll::Ready(()) => {
debug!("timeout on stream");
return Poll::Ready(Some(Err(io::Error::new(
Poll::Ready(Some(Err(io::Error::new(
io::ErrorKind::TimedOut,
format!("nothing ready in {:?}", self.timeout_duration),
))));
))))
}
}
} else {
return Poll::Pending;
Poll::Pending
}
}
}

View File

@ -12,7 +12,7 @@ cargo check
for p in ${packages_ordered:?} ; do
cargo update -p trust-dns-proto
cargo update -p trust-dns
cargo update -p trust-dns-client
cargo update -p trust-dns-resolver
echo "====> dry-run publish $p"
cargo publish --verbose --locked --dry-run --manifest-path crates/${p:?}/Cargo.toml

View File

@ -2,22 +2,26 @@
set -e
cargo clippy --version || rustup component add clippy-preview
CARGO=${CARGO:-cargo}
cargo clean -p trust-dns
cargo clean -p trust-dns-proto
cargo clean -p trust-dns-server
cargo clean -p trust-dns-resolver
cargo clean -p trust-dns-rustls
cargo clean -p trust-dns-openssl
cargo clean -p trust-dns-https
cargo clean -p trust-dns-native-tls
cargo clean -p trust-dns-compatibility
cargo clean -p trust-dns-integration
echo "Using cargo: $CARGO"
$CARGO clippy --version || rustup component add clippy
$CARGO clean -p trust-dns-client
$CARGO clean -p trust-dns-proto
$CARGO clean -p trust-dns-server
$CARGO clean -p trust-dns-resolver
$CARGO clean -p trust-dns-rustls
$CARGO clean -p trust-dns-openssl
$CARGO clean -p trust-dns-https
$CARGO clean -p trust-dns-native-tls
$CARGO clean -p trust-dns-compatibility
$CARGO clean -p trust-dns-integration
TARGETS_OPTS="--all --lib --examples --tests --bins"
CLIPPY_OPTS="-D warnings"
cargo clippy ${TARGETS_OPTS:?} -- ${CLIPPY_OPTS:?}
cargo clippy ${TARGETS_OPTS:?} --all-features -- ${CLIPPY_OPTS:?}
cargo clippy ${TARGETS_OPTS:?} --no-default-features -- ${CLIPPY_OPTS:?}
$CARGO clippy ${TARGETS_OPTS:?} -- ${CLIPPY_OPTS:?}
$CARGO clippy ${TARGETS_OPTS:?} --all-features -- ${CLIPPY_OPTS:?}
$CARGO clippy ${TARGETS_OPTS:?} --no-default-features -- ${CLIPPY_OPTS:?}

View File

@ -53,6 +53,7 @@ pub struct TestClientStream {
#[allow(unused)]
impl TestClientStream {
#[allow(clippy::type_complexity)]
pub fn new(
catalog: Arc<Mutex<Catalog>>,
) -> (
@ -191,6 +192,7 @@ pub struct NeverReturnsClientStream {
#[allow(dead_code)]
impl NeverReturnsClientStream {
#[allow(clippy::type_complexity)]
pub fn new() -> (
Pin<Box<dyn Future<Output = Result<Self, ProtoError>> + Send>>,
StreamHandle,
@ -254,6 +256,7 @@ impl NeverReturnsClientConnection {
}
}
#[allow(clippy::type_complexity)]
impl ClientConnection for NeverReturnsClientConnection {
type Sender = DnsMultiplexer<NeverReturnsClientStream, Signer>;
type Response = <Self::Sender as DnsRequestSender>::DnsResponseFuture;

View File

@ -46,6 +46,7 @@ impl TlsClientConnection {
}
}
#[allow(clippy::type_complexity)]
impl ClientConnection for TlsClientConnection {
type Sender = DnsMultiplexer<TlsClientStream, Signer>;
type Response = <Self::Sender as DnsRequestSender>::DnsResponseFuture;

View File

@ -49,6 +49,7 @@ impl TestClientConnection {
}
}
#[allow(clippy::type_complexity)]
impl ClientConnection for TestClientConnection {
type Sender = DnsMultiplexer<TestClientStream, Signer>;
type Response = <Self::Sender as DnsRequestSender>::DnsResponseFuture;

View File

@ -284,7 +284,6 @@ fn server_thread_udp(udp_socket: UdpSocket, server_continue: Arc<AtomicBool>) {
let server = ServerFuture::new(catalog);
io_loop.block_on::<Pin<Box<dyn Future<Output = ()> + Send>>>(Box::pin(future::lazy(|_| {
server.register_socket(udp_socket);
()
})));
while server_continue.load(Ordering::Relaxed) {