From 088db45e412b48571347df1e1976ceb6da2e80c8 Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Sat, 31 Mar 2018 19:16:40 +0200 Subject: [PATCH] feat(all): Add more compiler lints --- lettre/src/file/error.rs | 4 ++-- lettre/src/lib.rs | 7 ++++--- lettre/src/sendmail/error.rs | 2 +- lettre/src/smtp/client/mod.rs | 2 +- lettre/src/smtp/client/net.rs | 1 + lettre/src/smtp/commands.rs | 10 +++++----- lettre/src/smtp/error.rs | 10 +++++----- lettre/src/smtp/extension.rs | 2 +- lettre/src/smtp/mod.rs | 5 ++++- lettre/src/smtp/response.rs | 3 +-- lettre/src/stub/mod.rs | 2 +- lettre_email/src/lib.rs | 4 +++- 12 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lettre/src/file/error.rs b/lettre/src/file/error.rs index 026477b..62d0c38 100644 --- a/lettre/src/file/error.rs +++ b/lettre/src/file/error.rs @@ -34,8 +34,8 @@ impl StdError for Error { fn cause(&self) -> Option<&StdError> { match *self { - Io(ref err) => Some(&*err as &StdError), - JsonSerialization(ref err) => Some(&*err as &StdError), + Io(ref err) => Some(&*err), + JsonSerialization(ref err) => Some(&*err), _ => None, } } diff --git a/lettre/src/lib.rs b/lettre/src/lib.rs index 62aa6a6..0994f44 100644 --- a/lettre/src/lib.rs +++ b/lettre/src/lib.rs @@ -5,8 +5,9 @@ //! #![doc(html_root_url = "https://docs.rs/lettre/0.8.0")] -#![deny(missing_docs, unsafe_code, unstable_features, warnings)] - +#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, + trivial_casts, trivial_numeric_casts, unsafe_code, unstable_features, + unused_import_braces, unused_qualifications)] #[cfg(feature = "smtp-transport")] extern crate base64; #[cfg(feature = "smtp-transport")] @@ -52,7 +53,7 @@ use std::error::Error as StdError; use std::str::FromStr; /// Error type for email content -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub enum Error { /// Missing from in envelope MissingFrom, diff --git a/lettre/src/sendmail/error.rs b/lettre/src/sendmail/error.rs index f46919a..6b9a4aa 100644 --- a/lettre/src/sendmail/error.rs +++ b/lettre/src/sendmail/error.rs @@ -30,7 +30,7 @@ impl StdError for Error { fn cause(&self) -> Option<&StdError> { match *self { - Io(ref err) => Some(&*err as &StdError), + Io(ref err) => Some(&*err), _ => None, } } diff --git a/lettre/src/smtp/client/mod.rs b/lettre/src/smtp/client/mod.rs index 32c090f..d34212f 100644 --- a/lettre/src/smtp/client/mod.rs +++ b/lettre/src/smtp/client/mod.rs @@ -18,7 +18,7 @@ pub mod net; pub mod mock; /// The codec used for transparency -#[derive(Default, Debug)] +#[derive(Default, Clone, Copy, Debug)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct ClientCodec { escape_count: u8, diff --git a/lettre/src/smtp/client/net.rs b/lettre/src/smtp/client/net.rs index c89c5ce..fab5956 100644 --- a/lettre/src/smtp/client/net.rs +++ b/lettre/src/smtp/client/net.rs @@ -8,6 +8,7 @@ use std::time::Duration; /// Parameters to use for secure clients #[derive(Clone)] +#[allow(missing_debug_implementations)] pub struct ClientTlsParameters { /// A connector from `native-tls` pub connector: TlsConnector, diff --git a/lettre/src/smtp/commands.rs b/lettre/src/smtp/commands.rs index 8fa4e9a..9052a14 100644 --- a/lettre/src/smtp/commands.rs +++ b/lettre/src/smtp/commands.rs @@ -32,7 +32,7 @@ impl EhloCommand { } /// STARTTLS command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct StarttlsCommand; @@ -104,7 +104,7 @@ impl RcptCommand { } /// DATA command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct DataCommand; @@ -116,7 +116,7 @@ impl Display for DataCommand { } /// QUIT command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct QuitCommand; @@ -128,7 +128,7 @@ impl Display for QuitCommand { } /// NOOP command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct NoopCommand; @@ -206,7 +206,7 @@ impl ExpnCommand { } /// RSET command -#[derive(PartialEq, Clone, Debug)] +#[derive(PartialEq, Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub struct RsetCommand; diff --git a/lettre/src/smtp/error.rs b/lettre/src/smtp/error.rs index c2e592f..b74d24b 100644 --- a/lettre/src/smtp/error.rs +++ b/lettre/src/smtp/error.rs @@ -73,11 +73,11 @@ impl StdError for Error { fn cause(&self) -> Option<&StdError> { match *self { - ChallengeParsing(ref err) => Some(&*err as &StdError), - Utf8Parsing(ref err) => Some(&*err as &StdError), - Io(ref err) => Some(&*err as &StdError), - Tls(ref err) => Some(&*err as &StdError), - Parsing(ref err) => Some(&*err as &StdError), + ChallengeParsing(ref err) => Some(&*err), + Utf8Parsing(ref err) => Some(&*err), + Io(ref err) => Some(&*err), + Tls(ref err) => Some(&*err), + Parsing(ref err) => Some(&*err), _ => None, } } diff --git a/lettre/src/smtp/extension.rs b/lettre/src/smtp/extension.rs index c5d02d0..65dbd52 100644 --- a/lettre/src/smtp/extension.rs +++ b/lettre/src/smtp/extension.rs @@ -212,7 +212,7 @@ impl Display for MailParameter { } /// Values for the `BODY` parameter to `MAIL FROM` -#[derive(PartialEq, Eq, Clone, Debug)] +#[derive(PartialEq, Eq, Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum MailBodyParameter { /// `7BIT` diff --git a/lettre/src/smtp/mod.rs b/lettre/src/smtp/mod.rs index 824f315..af0d7f6 100644 --- a/lettre/src/smtp/mod.rs +++ b/lettre/src/smtp/mod.rs @@ -66,6 +66,7 @@ pub const NUL: &str = "\0"; /// How to apply TLS to a client connection #[derive(Clone)] +#[allow(missing_debug_implementations)] pub enum ClientSecurity { /// Insecure connection None, @@ -79,7 +80,7 @@ pub enum ClientSecurity { } /// Configures connection reuse behavior -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Copy)] #[cfg_attr(feature = "serde-impls", derive(Serialize, Deserialize))] pub enum ConnectionReuseParameters { /// Unlimitied connection reuse @@ -91,6 +92,7 @@ pub enum ConnectionReuseParameters { } /// Contains client configuration +#[allow(missing_debug_implementations)] pub struct SmtpTransportBuilder { /// Enable connection reuse connection_reuse: ConnectionReuseParameters, @@ -199,6 +201,7 @@ struct State { } /// Structure that implements the high level SMTP client +#[allow(missing_debug_implementations)] pub struct SmtpTransport { /// Information about the server /// Value is None before HELO/EHLO diff --git a/lettre/src/smtp/response.rs b/lettre/src/smtp/response.rs index e574854..4be3015 100644 --- a/lettre/src/smtp/response.rs +++ b/lettre/src/smtp/response.rs @@ -1,7 +1,6 @@ //! SMTP response, containing a mandatory return code and an optional text //! message -use self::Severity::*; use nom::{crlf, ErrorKind as NomErrorKind, IResult as NomResult}; use nom::simple_errors::Err as NomError; use std::fmt::{Display, Formatter, Result}; @@ -147,7 +146,7 @@ impl Response { /// Tells if the response is positive pub fn is_positive(&self) -> bool { match self.code.severity { - PositiveCompletion | PositiveIntermediate => true, + Severity::PositiveCompletion | Severity::PositiveIntermediate => true, _ => false, } } diff --git a/lettre/src/stub/mod.rs b/lettre/src/stub/mod.rs index ae5595b..2e6247c 100644 --- a/lettre/src/stub/mod.rs +++ b/lettre/src/stub/mod.rs @@ -7,7 +7,7 @@ use SendableEmail; use std::io::Read; /// This transport logs the message envelope and returns the given response -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct StubEmailTransport { response: StubResult, } diff --git a/lettre_email/src/lib.rs b/lettre_email/src/lib.rs index 11cb5fc..16a1b70 100644 --- a/lettre_email/src/lib.rs +++ b/lettre_email/src/lib.rs @@ -2,7 +2,9 @@ //! #![doc(html_root_url = "https://docs.rs/lettre_email/0.8.0")] -#![deny(missing_docs, unsafe_code, unstable_features, warnings, missing_debug_implementations)] +#![deny(missing_docs, missing_debug_implementations, missing_copy_implementations, + trivial_casts, trivial_numeric_casts, unsafe_code, unstable_features, + unused_import_braces, unused_qualifications)] extern crate base64; extern crate email as email_format;