More clippy
This commit is contained in:
parent
23b83e5153
commit
9e4f4d3496
@ -35,7 +35,7 @@ jobs:
|
|||||||
- run: rustc --version > ~/rust-version
|
- run: rustc --version > ~/rust-version
|
||||||
- *RESTORE_DEPS
|
- *RESTORE_DEPS
|
||||||
- run: cargo fmt --all -- --check
|
- run: cargo fmt --all -- --check
|
||||||
- run: cargo clippy --all
|
- run: cargo clippy --all --all-targets --all-features
|
||||||
- run: cargo test --all
|
- 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 --no-default-features
|
||||||
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --all-features
|
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --all-features
|
||||||
|
@ -86,7 +86,7 @@ fn make_map(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<Fil
|
|||||||
write!(
|
write!(
|
||||||
file,
|
file,
|
||||||
"
|
"
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
#[rustfmt::skip]
|
||||||
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
|
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -775,7 +775,7 @@ impl SqlState {
|
|||||||
/// XX002
|
/// XX002
|
||||||
pub const INDEX_CORRUPTED: SqlState = SqlState(Cow::Borrowed("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 {
|
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
|
||||||
key: 3213172566270843353,
|
key: 3213172566270843353,
|
||||||
disps: ::phf::Slice::Static(&[
|
disps: ::phf::Slice::Static(&[
|
||||||
|
@ -103,7 +103,7 @@ impl ToSql for DateTime<FixedOffset> {
|
|||||||
impl<'a> FromSql<'a> for NaiveDate {
|
impl<'a> FromSql<'a> for NaiveDate {
|
||||||
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
|
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
|
||||||
let jd = types::date_from_sql(raw)?;
|
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);
|
accepts!(DATE);
|
||||||
@ -112,7 +112,7 @@ impl<'a> FromSql<'a> for NaiveDate {
|
|||||||
impl ToSql for NaiveDate {
|
impl ToSql for NaiveDate {
|
||||||
fn to_sql(&self, _: &Type, w: &mut Vec<u8>) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
|
fn to_sql(&self, _: &Type, w: &mut Vec<u8>) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
|
||||||
let jd = self.signed_duration_since(base().date()).num_days();
|
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());
|
return Err("value too large to transmit".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use crate::types::test_type;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_naive_date_time_params() {
|
fn test_naive_date_time_params() {
|
||||||
fn make_check<'a>(time: &'a str) -> (Option<NaiveDateTime>, &'a str) {
|
fn make_check(time: &str) -> (Option<NaiveDateTime>, &str) {
|
||||||
(
|
(
|
||||||
Some(NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()),
|
Some(NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()),
|
||||||
time,
|
time,
|
||||||
@ -24,7 +24,7 @@ fn test_naive_date_time_params() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_with_special_naive_date_time_params() {
|
fn test_with_special_naive_date_time_params() {
|
||||||
fn make_check<'a>(time: &'a str) -> (Timestamp<NaiveDateTime>, &'a str) {
|
fn make_check(time: &str) -> (Timestamp<NaiveDateTime>, &str) {
|
||||||
(
|
(
|
||||||
Timestamp::Value(
|
Timestamp::Value(
|
||||||
NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap(),
|
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]
|
#[test]
|
||||||
fn test_date_time_params() {
|
fn test_date_time_params() {
|
||||||
fn make_check<'a>(time: &'a str) -> (Option<DateTime<Utc>>, &'a str) {
|
fn make_check(time: &str) -> (Option<DateTime<Utc>>, &str) {
|
||||||
(
|
(
|
||||||
Some(
|
Some(
|
||||||
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
|
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
|
||||||
@ -68,7 +68,7 @@ fn test_date_time_params() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_with_special_date_time_params() {
|
fn test_with_special_date_time_params() {
|
||||||
fn make_check<'a>(time: &'a str) -> (Timestamp<DateTime<Utc>>, &'a str) {
|
fn make_check(time: &str) -> (Timestamp<DateTime<Utc>>, &str) {
|
||||||
(
|
(
|
||||||
Timestamp::Value(
|
Timestamp::Value(
|
||||||
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
|
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
|
||||||
@ -91,7 +91,7 @@ fn test_with_special_date_time_params() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_params() {
|
fn test_date_params() {
|
||||||
fn make_check<'a>(time: &'a str) -> (Option<NaiveDate>, &'a str) {
|
fn make_check(time: &str) -> (Option<NaiveDate>, &str) {
|
||||||
(
|
(
|
||||||
Some(NaiveDate::parse_from_str(time, "'%Y-%m-%d'").unwrap()),
|
Some(NaiveDate::parse_from_str(time, "'%Y-%m-%d'").unwrap()),
|
||||||
time,
|
time,
|
||||||
@ -110,7 +110,7 @@ fn test_date_params() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_with_special_date_params() {
|
fn test_with_special_date_params() {
|
||||||
fn make_check<'a>(date: &'a str) -> (Date<NaiveDate>, &'a str) {
|
fn make_check(date: &str) -> (Date<NaiveDate>, &str) {
|
||||||
(
|
(
|
||||||
Date::Value(NaiveDate::parse_from_str(date, "'%Y-%m-%d'").unwrap()),
|
Date::Value(NaiveDate::parse_from_str(date, "'%Y-%m-%d'").unwrap()),
|
||||||
date,
|
date,
|
||||||
@ -130,7 +130,7 @@ fn test_with_special_date_params() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_time_params() {
|
fn test_time_params() {
|
||||||
fn make_check<'a>(time: &'a str) -> (Option<NaiveTime>, &'a str) {
|
fn make_check(time: &str) -> (Option<NaiveTime>, &str) {
|
||||||
(
|
(
|
||||||
Some(NaiveTime::parse_from_str(time, "'%H:%M:%S.%f'").unwrap()),
|
Some(NaiveTime::parse_from_str(time, "'%H:%M:%S.%f'").unwrap()),
|
||||||
time,
|
time,
|
||||||
|
@ -99,8 +99,8 @@ fn test_i32_params() {
|
|||||||
test_type(
|
test_type(
|
||||||
"INT",
|
"INT",
|
||||||
&[
|
&[
|
||||||
(Some(2147483548i32), "2147483548"),
|
(Some(2_147_483_548i32), "2147483548"),
|
||||||
(Some(-2147483548i32), "-2147483548"),
|
(Some(-2_147_483_548i32), "-2147483548"),
|
||||||
(None, "NULL"),
|
(None, "NULL"),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -111,8 +111,8 @@ fn test_oid_params() {
|
|||||||
test_type(
|
test_type(
|
||||||
"OID",
|
"OID",
|
||||||
&[
|
&[
|
||||||
(Some(2147483548u32), "2147483548"),
|
(Some(2_147_483_548u32), "2147483548"),
|
||||||
(Some(4000000000), "4000000000"),
|
(Some(4_000_000_000), "4000000000"),
|
||||||
(None, "NULL"),
|
(None, "NULL"),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -123,8 +123,8 @@ fn test_i64_params() {
|
|||||||
test_type(
|
test_type(
|
||||||
"BIGINT",
|
"BIGINT",
|
||||||
&[
|
&[
|
||||||
(Some(9223372036854775708i64), "9223372036854775708"),
|
(Some(9_223_372_036_854_775_708i64), "9223372036854775708"),
|
||||||
(Some(-9223372036854775708i64), "-9223372036854775708"),
|
(Some(-9_223_372_036_854_775_708i64), "-9223372036854775708"),
|
||||||
(None, "NULL"),
|
(None, "NULL"),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -343,6 +343,7 @@ fn test_array_params() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::eq_op)]
|
||||||
fn test_nan_param<T>(sql_type: &str)
|
fn test_nan_param<T>(sql_type: &str)
|
||||||
where
|
where
|
||||||
T: PartialEq + ToSql + FromSqlOwned,
|
T: PartialEq + ToSql + FromSqlOwned,
|
||||||
@ -616,7 +617,7 @@ fn system_time() {
|
|||||||
"'1969-12-31 23:59:58.99'",
|
"'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'",
|
"'2000-01-01 00:00:01.01'",
|
||||||
),
|
),
|
||||||
(None, "NULL"),
|
(None, "NULL"),
|
||||||
|
Loading…
Reference in New Issue
Block a user