Skip to content

Commit

Permalink
Make all warnings across crates and binaries consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
bluejekyll committed Mar 8, 2021
1 parent a44d441 commit 603a3ad
Show file tree
Hide file tree
Showing 107 changed files with 383 additions and 223 deletions.
27 changes: 19 additions & 8 deletions bin/src/named.rs
Expand Up @@ -22,7 +22,17 @@
//! --tls-port=PORT Override the listening port for TLS connections
//! ```

#![warn(missing_docs, clippy::dbg_macro, clippy::unimplemented)]
// BINARY WARNINGS
#![warn(
clippy::dbg_macro,
clippy::unimplemented,
missing_copy_implementations,
missing_docs,
non_snake_case,
non_upper_case_globals,
rust_2018_idioms,
unreachable_pub
)]
#![recursion_limit = "128"]

#[macro_use]
Expand Down Expand Up @@ -230,14 +240,15 @@ const TLS_PORT_ARG: &str = "tls-port";
const HTTPS_PORT_ARG: &str = "https-port";

/// Args struct for all options
#[allow(dead_code)]
struct Args {
pub flag_quiet: bool,
pub flag_debug: bool,
pub flag_config: String,
pub flag_zonedir: Option<String>,
pub flag_port: Option<u16>,
pub flag_tls_port: Option<u16>,
pub flag_https_port: Option<u16>,
pub(crate) flag_quiet: bool,
pub(crate) flag_debug: bool,
pub(crate) flag_config: String,
pub(crate) flag_zonedir: Option<String>,
pub(crate) flag_port: Option<u16>,
pub(crate) flag_tls_port: Option<u16>,
pub(crate) flag_https_port: Option<u16>,
}

impl<'a> From<ArgMatches<'a>> for Args {
Expand Down
12 changes: 12 additions & 0 deletions crates/async-std-resolver/src/lib.rs
Expand Up @@ -5,6 +5,18 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

// LIBRARY WARNINGS
#![warn(
clippy::dbg_macro,
clippy::print_stdout,
clippy::unimplemented,
missing_copy_implementations,
missing_docs,
non_snake_case,
non_upper_case_globals,
rust_2018_idioms,
unreachable_pub
)]
#![allow(clippy::needless_doctest_main)]

//! The Resolver is responsible for performing recursive queries to lookup domain names.
Expand Down
4 changes: 2 additions & 2 deletions crates/async-std-resolver/src/net.rs
Expand Up @@ -33,7 +33,7 @@ impl UdpSocket for AsyncStdUdpSocket {

fn poll_recv_from(
&self,
cx: &mut Context,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<(usize, SocketAddr)>> {
let fut = self.0.recv_from(buf);
Expand All @@ -48,7 +48,7 @@ impl UdpSocket for AsyncStdUdpSocket {

fn poll_send_to(
&self,
cx: &mut Context,
cx: &mut Context<'_>,
buf: &[u8],
target: SocketAddr,
) -> Poll<io::Result<usize>> {
Expand Down
7 changes: 5 additions & 2 deletions crates/async-std-resolver/src/runtime.rs
Expand Up @@ -44,7 +44,7 @@ use crate::time::AsyncStdTime;
/// [timer]: crate::time
/// [mod]: index.html
/// [`new`]: #method.new
#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct AsyncStdRuntime;

impl Executor for AsyncStdRuntime {
Expand All @@ -57,7 +57,7 @@ impl Executor for AsyncStdRuntime {
}
}

#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct AsyncStdRuntimeHandle;
impl Spawn for AsyncStdRuntimeHandle {
fn spawn_bg<F>(&mut self, future: F)
Expand All @@ -82,5 +82,8 @@ impl AsyncStdRuntime {
}
}

/// AsyncStd default connection
pub type AsyncStdConnection = GenericConnection;

/// AsyncStd default connection provider
pub type AsyncStdConnectionProvider = GenericConnectionProvider<AsyncStdRuntime>;
1 change: 1 addition & 0 deletions crates/async-std-resolver/src/time.rs
Expand Up @@ -12,6 +12,7 @@ use async_trait::async_trait;
use trust_dns_resolver::proto::Time;

/// AsyncStd backed timer implementation
#[derive(Clone, Copy)]
pub struct AsyncStdTime;

#[async_trait]
Expand Down
6 changes: 3 additions & 3 deletions crates/client/src/client/async_client.rs
Expand Up @@ -30,7 +30,7 @@ use crate::rr::{DNSClass, Name, Record, RecordSet, RecordType};
// TODO: this should be configurable
// > An EDNS buffer size of 1232 bytes will avoid fragmentation on nearly all current networks.
// https://dnsflagday.net/2020/
pub const MAX_PAYLOAD_LEN: u16 = 1232;
pub(crate) const MAX_PAYLOAD_LEN: u16 = 1232;

/// A DNS Client implemented over futures-rs.
///
Expand Down Expand Up @@ -144,7 +144,7 @@ where
{
type Output = Result<(AsyncClient, DnsExchangeBackground<S, TokioTime>), ProtoError>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let result = ready!(self.0.poll_unpin(cx));
let client_background = result.map(|(exchange, bg)| (AsyncClient { exchange }, bg));

Expand Down Expand Up @@ -584,7 +584,7 @@ where
{
type Output = Result<DnsResponse, ClientError>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
self.0.poll_unpin(cx).map_err(ClientError::from)
}
}
2 changes: 1 addition & 1 deletion crates/client/src/client/async_secure_client.rs
Expand Up @@ -139,7 +139,7 @@ where
{
type Output = Result<(AsyncDnssecClient, DnsExchangeBackground<S, TokioTime>), ProtoError>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let result = ready!(self.client_connect.poll_unpin(cx));
let trust_anchor = self
.trust_anchor
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/client/client.rs
Expand Up @@ -32,7 +32,7 @@ use crate::rr::dnssec::TrustAnchor;
use crate::rr::{DNSClass, Name, Record, RecordSet, RecordType};

#[allow(clippy::type_complexity)]
pub type NewFutureObj<H> = Pin<
pub(crate) type NewFutureObj<H> = Pin<
Box<
dyn Future<
Output = Result<
Expand Down
6 changes: 3 additions & 3 deletions crates/client/src/client/rc_future.rs
Expand Up @@ -15,15 +15,15 @@ use futures_util::{future::Fuse, ready, FutureExt};

#[allow(clippy::type_complexity)]
#[must_use = "futures do nothing unless polled"]
pub struct RcFuture<F: Future>
pub(crate) struct RcFuture<F: Future>
where
F: Future + Send + Unpin,
F::Output: Clone + Send,
{
future_and_result: Arc<Mutex<(Fuse<F>, Option<F::Output>)>>,
}

pub fn rc_future<F>(future: F) -> RcFuture<F>
pub(crate) fn rc_future<F>(future: F) -> RcFuture<F>
where
F: Future + Unpin,
F::Output: Clone + Send,
Expand All @@ -41,7 +41,7 @@ where
{
type Output = F::Output;

fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// try and get a mutable reference to execute the future
// at least one caller should be able to get a mut reference... others will
// wait for it to complete.
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/error/client_error.rs
Expand Up @@ -85,7 +85,7 @@ impl Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
cfg_if::cfg_if! {
if #[cfg(feature = "backtrace")] {
if let Some(ref backtrace) = self.backtrack {
Expand Down
17 changes: 10 additions & 7 deletions crates/client/src/error/dnssec_error.rs
Expand Up @@ -27,6 +27,7 @@ use crate::proto::{trace, ExtBacktrace};
pub type Result<T> = ::std::result::Result<T, Error>;

/// The error kind for dnssec errors that get returned in the crate
#[allow(unreachable_pub)]
#[derive(Debug, Error)]
pub enum ErrorKind {
/// An error with an arbitrary message, referenced as &'static str
Expand Down Expand Up @@ -92,7 +93,7 @@ impl Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
cfg_if::cfg_if! {
if #[cfg(feature = "backtrace")] {
if let Some(ref backtrace) = self.backtrack {
Expand Down Expand Up @@ -157,15 +158,16 @@ impl From<SslErrorStack> for Error {
}
}

#[allow(unreachable_pub)]
#[cfg(not(feature = "openssl"))]
pub mod not_openssl {
use std;

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub struct SslErrorStack;

impl std::fmt::Display for SslErrorStack {
fn fmt(&self, _: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
Ok(())
}
}
Expand All @@ -177,18 +179,19 @@ pub mod not_openssl {
}
}

#[allow(unreachable_pub)]
#[cfg(not(feature = "ring"))]
pub mod not_ring {
use std;

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub struct KeyRejected;

#[derive(Debug, Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub struct Unspecified;

impl std::fmt::Display for KeyRejected {
fn fmt(&self, _: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
Ok(())
}
}
Expand All @@ -200,7 +203,7 @@ pub mod not_ring {
}

impl std::fmt::Display for Unspecified {
fn fmt(&self, _: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/error/lexer_error.rs
Expand Up @@ -83,7 +83,7 @@ impl From<ErrorKind> for Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
cfg_if::cfg_if! {
if #[cfg(feature = "backtrace")] {
if let Some(ref backtrace) = self.backtrack {
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/error/parse_error.rs
Expand Up @@ -116,7 +116,7 @@ impl Error {
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
cfg_if::cfg_if! {
if #[cfg(feature = "backtrace")] {
if let Some(ref backtrace) = self.backtrack {
Expand Down
19 changes: 13 additions & 6 deletions crates/client/src/lib.rs
Expand Up @@ -13,17 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// LIBRARY WARNINGS
#![warn(
clippy::dbg_macro,
clippy::print_stdout,
clippy::unimplemented,
missing_copy_implementations,
missing_docs,
non_snake_case,
non_upper_case_globals,
rust_2018_idioms,
unreachable_pub
)]
#![allow(
clippy::needless_doctest_main,
clippy::unknown_clippy_lints,
clippy::single_component_path_imports
)]
#![warn(
missing_docs,
clippy::dbg_macro,
clippy::print_stdout,
clippy::unimplemented
)]
#![recursion_limit = "1024"]

//! Trust-DNS is intended to be a fully compliant domain name server and client library.
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/multicast/mdns_client_connection.rs
Expand Up @@ -21,7 +21,7 @@ use crate::rr::dnssec::Signer;
/// MDNS based DNS Client connection
///
/// Use with `trust_dns_client::client::Client` impls
#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct MdnsClientConnection {
multicast_addr: SocketAddr,
packet_ttl: Option<u32>,
Expand Down
4 changes: 2 additions & 2 deletions crates/client/src/op/lower_query.rs
Expand Up @@ -72,7 +72,7 @@ impl From<Query> for LowerQuery {
}

impl BinEncodable for LowerQuery {
fn emit(&self, encoder: &mut BinEncoder) -> ProtoResult<()> {
fn emit(&self, encoder: &mut BinEncoder<'_>) -> ProtoResult<()> {
self.original.emit(encoder)
}
}
Expand All @@ -85,7 +85,7 @@ impl<'r> BinDecodable<'r> for LowerQuery {
}

impl Display for LowerQuery {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(
f,
"name: {} type: {} class: {}",
Expand Down
2 changes: 1 addition & 1 deletion crates/client/src/rr/dnssec/key_format.rs
Expand Up @@ -270,7 +270,7 @@ impl KeyFormat {
mod tests {
#![allow(clippy::dbg_macro, clippy::print_stdout)]

pub use super::*;
use super::*;

#[test]
#[cfg(feature = "openssl")]
Expand Down
2 changes: 2 additions & 0 deletions crates/client/src/rr/dnssec/mod.rs
Expand Up @@ -66,11 +66,13 @@ mod faux_key_type {
impl<K: HasPrivate> HasPublic for K {}

/// Faux implementation of the Openssl Public key types
#[derive(Clone, Copy)]
pub enum Public {}

impl HasPublic for Public {}

/// Faux implementation of the Openssl Public key types
#[derive(Clone, Copy)]
pub enum Private {}

impl HasPrivate for Private {}
Expand Down
4 changes: 2 additions & 2 deletions crates/client/src/rr/dnssec/signer.rs
Expand Up @@ -248,7 +248,7 @@ pub struct Signer {

/// Placeholder type for when OpenSSL and *ring* are disabled; enable OpenSSL and Ring for support
#[cfg(not(any(feature = "openssl", feature = "ring")))]
#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct Signer;

#[cfg(any(feature = "openssl", feature = "ring"))]
Expand Down Expand Up @@ -587,7 +587,7 @@ mod tests {
use crate::rr::rdata::{DNSSECRData, SIG};
use crate::rr::{DNSClass, Name, Record, RecordType};

pub use super::*;
use super::*;

fn assert_send_and_sync<T: Send + Sync>() {}

Expand Down

0 comments on commit 603a3ad

Please sign in to comment.