From db34a9c06df4e95fcc7ba5be817b3b34a0d4fe67 Mon Sep 17 00:00:00 2001 From: Joao Neves Date: Fri, 22 May 2020 16:49:16 +0200 Subject: [PATCH 1/3] Fix clippy lint warnings regarding indirect structural matches --- postgres-types/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgres-types/src/lib.rs b/postgres-types/src/lib.rs index dbde5eb04..58641bc9a 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 } } From d6a59fbee2713215c727293542e0c755ef727eb0 Mon Sep 17 00:00:00 2001 From: Joao Neves Date: Tue, 26 May 2020 11:23:13 +0200 Subject: [PATCH 2/3] Fix additional future_incompatible warnings after rebase --- postgres-types/src/lib.rs | 8 ++++---- postgres-types/src/special.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/postgres-types/src/lib.rs b/postgres-types/src/lib.rs index 58641bc9a..e90997530 100644 --- a/postgres-types/src/lib.rs +++ b/postgres-types/src/lib.rs @@ -536,8 +536,8 @@ 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 +830,8 @@ 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..38a4dddba 100644 --- a/postgres-types/src/special.rs +++ b/postgres-types/src/special.rs @@ -75,8 +75,8 @@ 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 +99,8 @@ 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, } } From 693a7dcf824e5ee7728efa112a10976e26ce29d7 Mon Sep 17 00:00:00 2001 From: Joao Neves Date: Tue, 26 May 2020 11:40:54 +0200 Subject: [PATCH 3/3] cargo fmt previous changes --- postgres-types/src/lib.rs | 18 ++++++++++++++++-- postgres-types/src/special.rs | 8 ++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/postgres-types/src/lib.rs b/postgres-types/src/lib.rs index e90997530..0daaf90bf 100644 --- a/postgres-types/src/lib.rs +++ b/postgres-types/src/lib.rs @@ -537,7 +537,14 @@ impl<'a> FromSql<'a> for &'a str { fn accepts(ty: &Type) -> bool { match ty { - typ if *typ == Type::VARCHAR || *typ == Type::TEXT || *typ == Type::BPCHAR || *typ == Type::NAME || *typ == Type::UNKNOWN => true, + 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, } @@ -831,7 +838,14 @@ impl<'a> ToSql for &'a str { fn accepts(ty: &Type) -> bool { match ty { - typ if *typ == Type::VARCHAR || *typ == Type::TEXT || *typ == Type::BPCHAR || *typ == Type::NAME || *typ == Type::UNKNOWN => true, + 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 38a4dddba..a5d60dd2e 100644 --- a/postgres-types/src/special.rs +++ b/postgres-types/src/special.rs @@ -76,7 +76,9 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for Timestamp { fn accepts(ty: &Type) -> bool { match ty { - typ if (*typ == Type::TIMESTAMP || *typ == Type::TIMESTAMPTZ) && T::accepts(&ty) => true, + typ if (*typ == Type::TIMESTAMP || *typ == Type::TIMESTAMPTZ) && T::accepts(&ty) => { + true + } _ => false, } } @@ -100,7 +102,9 @@ impl ToSql for Timestamp { fn accepts(ty: &Type) -> bool { match ty { - typ if (*typ == Type::TIMESTAMP || *typ == Type::TIMESTAMPTZ) && T::accepts(&ty) => true, + typ if (*typ == Type::TIMESTAMP || *typ == Type::TIMESTAMPTZ) && T::accepts(&ty) => { + true + } _ => false, } }