diff --git a/postgres-types/src/lib.rs b/postgres-types/src/lib.rs index dbde5eb04..0daaf90bf 100644 --- a/postgres-types/src/lib.rs +++ b/postgres-types/src/lib.rs @@ -106,7 +106,7 @@ //! } //! ``` #![doc(html_root_url = "https://docs.rs/postgres-types/0.1")] -#![warn(clippy::all, rust_2018_idioms, missing_docs)] +#![warn(clippy::all, future_incompatible, rust_2018_idioms, missing_docs)] use fallible_iterator::FallibleIterator; use postgres_protocol::types::{self, ArrayDimension}; @@ -144,8 +144,8 @@ const NSEC_PER_USEC: u64 = 1_000; macro_rules! accepts { ($($expected:ident),+) => ( fn accepts(ty: &$crate::Type) -> bool { - match *ty { - $($crate::Type::$expected)|+ => true, + match ty { + $(typ if *typ == $crate::Type::$expected => true,)* _ => false } } @@ -536,8 +536,15 @@ impl<'a> FromSql<'a> for &'a str { } fn accepts(ty: &Type) -> bool { - match *ty { - Type::VARCHAR | Type::TEXT | Type::BPCHAR | Type::NAME | Type::UNKNOWN => true, + match ty { + typ if *typ == Type::VARCHAR + || *typ == Type::TEXT + || *typ == Type::BPCHAR + || *typ == Type::NAME + || *typ == Type::UNKNOWN => + { + true + } ref ty if ty.name() == "citext" => true, _ => false, } @@ -830,8 +837,15 @@ impl<'a> ToSql for &'a str { } fn accepts(ty: &Type) -> bool { - match *ty { - Type::VARCHAR | Type::TEXT | Type::BPCHAR | Type::NAME | Type::UNKNOWN => true, + match ty { + typ if *typ == Type::VARCHAR + || *typ == Type::TEXT + || *typ == Type::BPCHAR + || *typ == Type::NAME + || *typ == Type::UNKNOWN => + { + true + } ref ty if ty.name() == "citext" => true, _ => false, } diff --git a/postgres-types/src/special.rs b/postgres-types/src/special.rs index 5a2d7bc08..a5d60dd2e 100644 --- a/postgres-types/src/special.rs +++ b/postgres-types/src/special.rs @@ -75,8 +75,10 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for Timestamp { } fn accepts(ty: &Type) -> bool { - match *ty { - Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true, + match ty { + typ if (*typ == Type::TIMESTAMP || *typ == Type::TIMESTAMPTZ) && T::accepts(&ty) => { + true + } _ => false, } } @@ -99,8 +101,10 @@ impl ToSql for Timestamp { } fn accepts(ty: &Type) -> bool { - match *ty { - Type::TIMESTAMP | Type::TIMESTAMPTZ if T::accepts(ty) => true, + match ty { + typ if (*typ == Type::TIMESTAMP || *typ == Type::TIMESTAMPTZ) && T::accepts(&ty) => { + true + } _ => false, } }