diff --git a/.circleci/config.yml b/.circleci/config.yml index 68edc5c1..b2d7fb73 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -35,7 +35,7 @@ jobs: - run: rustc --version > ~/rust-version - *RESTORE_DEPS - run: cargo fmt --all -- --check - - run: cargo clippy --all + - run: cargo clippy --all --all-targets --all-features - run: cargo test --all - run: cargo test --manifest-path tokio-postgres/Cargo.toml --no-default-features - run: cargo test --manifest-path tokio-postgres/Cargo.toml --all-features diff --git a/codegen/src/sqlstate.rs b/codegen/src/sqlstate.rs index c940f016..2da7e8dc 100644 --- a/codegen/src/sqlstate.rs +++ b/codegen/src/sqlstate.rs @@ -86,7 +86,7 @@ fn make_map(codes: &LinkedHashMap>, file: &mut BufWriter = " ) .unwrap(); diff --git a/tokio-postgres/src/error/sqlstate.rs b/tokio-postgres/src/error/sqlstate.rs index 27ee6353..60c18e42 100644 --- a/tokio-postgres/src/error/sqlstate.rs +++ b/tokio-postgres/src/error/sqlstate.rs @@ -775,7 +775,7 @@ impl SqlState { /// XX002 pub const INDEX_CORRUPTED: SqlState = SqlState(Cow::Borrowed("XX002")); } -#[cfg_attr(rustfmt, rustfmt_skip)] +#[rustfmt::skip] static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map { key: 3213172566270843353, disps: ::phf::Slice::Static(&[ diff --git a/tokio-postgres/src/types/chrono_04.rs b/tokio-postgres/src/types/chrono_04.rs index 91ec6a80..e414a93f 100644 --- a/tokio-postgres/src/types/chrono_04.rs +++ b/tokio-postgres/src/types/chrono_04.rs @@ -103,7 +103,7 @@ impl ToSql for DateTime { impl<'a> FromSql<'a> for NaiveDate { fn from_sql(_: &Type, raw: &[u8]) -> Result> { let jd = types::date_from_sql(raw)?; - Ok(base().date() + Duration::days(jd as i64)) + Ok(base().date() + Duration::days(i64::from(jd))) } accepts!(DATE); @@ -112,7 +112,7 @@ impl<'a> FromSql<'a> for NaiveDate { impl ToSql for NaiveDate { fn to_sql(&self, _: &Type, w: &mut Vec) -> Result> { let jd = self.signed_duration_since(base().date()).num_days(); - if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 { + if jd > i64::from(i32::max_value()) || jd < i64::from(i32::min_value()) { return Err("value too large to transmit".into()); } diff --git a/tokio-postgres/tests/test/types/chrono_04.rs b/tokio-postgres/tests/test/types/chrono_04.rs index 224a5487..eb001806 100644 --- a/tokio-postgres/tests/test/types/chrono_04.rs +++ b/tokio-postgres/tests/test/types/chrono_04.rs @@ -5,7 +5,7 @@ use crate::types::test_type; #[test] fn test_naive_date_time_params() { - fn make_check<'a>(time: &'a str) -> (Option, &'a str) { + fn make_check(time: &str) -> (Option, &str) { ( Some(NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()), time, @@ -24,7 +24,7 @@ fn test_naive_date_time_params() { #[test] fn test_with_special_naive_date_time_params() { - fn make_check<'a>(time: &'a str) -> (Timestamp, &'a str) { + fn make_check(time: &str) -> (Timestamp, &str) { ( Timestamp::Value( NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(), @@ -46,7 +46,7 @@ fn test_with_special_naive_date_time_params() { #[test] fn test_date_time_params() { - fn make_check<'a>(time: &'a str) -> (Option>, &'a str) { + fn make_check(time: &str) -> (Option>, &str) { ( Some( Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'") @@ -68,7 +68,7 @@ fn test_date_time_params() { #[test] fn test_with_special_date_time_params() { - fn make_check<'a>(time: &'a str) -> (Timestamp>, &'a str) { + fn make_check(time: &str) -> (Timestamp>, &str) { ( Timestamp::Value( Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'") @@ -91,7 +91,7 @@ fn test_with_special_date_time_params() { #[test] fn test_date_params() { - fn make_check<'a>(time: &'a str) -> (Option, &'a str) { + fn make_check(time: &str) -> (Option, &str) { ( Some(NaiveDate::parse_from_str(time, "'%Y-%m-%d'").unwrap()), time, @@ -110,7 +110,7 @@ fn test_date_params() { #[test] fn test_with_special_date_params() { - fn make_check<'a>(date: &'a str) -> (Date, &'a str) { + fn make_check(date: &str) -> (Date, &str) { ( Date::Value(NaiveDate::parse_from_str(date, "'%Y-%m-%d'").unwrap()), date, @@ -130,7 +130,7 @@ fn test_with_special_date_params() { #[test] fn test_time_params() { - fn make_check<'a>(time: &'a str) -> (Option, &'a str) { + fn make_check(time: &str) -> (Option, &str) { ( Some(NaiveTime::parse_from_str(time, "'%H:%M:%S.%f'").unwrap()), time, diff --git a/tokio-postgres/tests/test/types/mod.rs b/tokio-postgres/tests/test/types/mod.rs index 5c9e81f4..9fd42ca4 100644 --- a/tokio-postgres/tests/test/types/mod.rs +++ b/tokio-postgres/tests/test/types/mod.rs @@ -99,8 +99,8 @@ fn test_i32_params() { test_type( "INT", &[ - (Some(2147483548i32), "2147483548"), - (Some(-2147483548i32), "-2147483548"), + (Some(2_147_483_548i32), "2147483548"), + (Some(-2_147_483_548i32), "-2147483548"), (None, "NULL"), ], ); @@ -111,8 +111,8 @@ fn test_oid_params() { test_type( "OID", &[ - (Some(2147483548u32), "2147483548"), - (Some(4000000000), "4000000000"), + (Some(2_147_483_548u32), "2147483548"), + (Some(4_000_000_000), "4000000000"), (None, "NULL"), ], ); @@ -123,8 +123,8 @@ fn test_i64_params() { test_type( "BIGINT", &[ - (Some(9223372036854775708i64), "9223372036854775708"), - (Some(-9223372036854775708i64), "-9223372036854775708"), + (Some(9_223_372_036_854_775_708i64), "9223372036854775708"), + (Some(-9_223_372_036_854_775_708i64), "-9223372036854775708"), (None, "NULL"), ], ); @@ -343,6 +343,7 @@ fn test_array_params() { ); } +#[allow(clippy::eq_op)] fn test_nan_param(sql_type: &str) where T: PartialEq + ToSql + FromSqlOwned, @@ -616,7 +617,7 @@ fn system_time() { "'1969-12-31 23:59:58.99'", ), ( - Some(UNIX_EPOCH + Duration::from_millis(946684800 * 1000 + 1_010)), + Some(UNIX_EPOCH + Duration::from_millis(946_684_800 * 1000 + 1_010)), "'2000-01-01 00:00:01.01'", ), (None, "NULL"),