More clippy

This commit is contained in:
Steven Fackler 2019-03-05 18:26:55 -08:00
parent 23b83e5153
commit 9e4f4d3496
6 changed files with 20 additions and 19 deletions

View File

@ -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

View File

@ -86,7 +86,7 @@ fn make_map(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<Fil
write!(
file,
"
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
)
.unwrap();

View File

@ -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(&[

View File

@ -103,7 +103,7 @@ impl ToSql for DateTime<FixedOffset> {
impl<'a> FromSql<'a> for NaiveDate {
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
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<u8>) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
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());
}

View File

@ -5,7 +5,7 @@ use crate::types::test_type;
#[test]
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()),
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<NaiveDateTime>, &'a str) {
fn make_check(time: &str) -> (Timestamp<NaiveDateTime>, &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<DateTime<Utc>>, &'a str) {
fn make_check(time: &str) -> (Option<DateTime<Utc>>, &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<DateTime<Utc>>, &'a str) {
fn make_check(time: &str) -> (Timestamp<DateTime<Utc>>, &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<NaiveDate>, &'a str) {
fn make_check(time: &str) -> (Option<NaiveDate>, &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<NaiveDate>, &'a str) {
fn make_check(date: &str) -> (Date<NaiveDate>, &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<NaiveTime>, &'a str) {
fn make_check(time: &str) -> (Option<NaiveTime>, &str) {
(
Some(NaiveTime::parse_from_str(time, "'%H:%M:%S.%f'").unwrap()),
time,

View File

@ -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<T>(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"),