Skip to content

Commit 9e4f4d3

Browse files
committed
More clippy
1 parent 23b83e5 commit 9e4f4d3

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- run: rustc --version > ~/rust-version
3636
- *RESTORE_DEPS
3737
- run: cargo fmt --all -- --check
38-
- run: cargo clippy --all
38+
- run: cargo clippy --all --all-targets --all-features
3939
- run: cargo test --all
4040
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --no-default-features
4141
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --all-features

codegen/src/sqlstate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn make_map(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<Fil
8686
write!(
8787
file,
8888
"
89-
#[cfg_attr(rustfmt, rustfmt_skip)]
89+
#[rustfmt::skip]
9090
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
9191
)
9292
.unwrap();

tokio-postgres/src/error/sqlstate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl SqlState {
775775
/// XX002
776776
pub const INDEX_CORRUPTED: SqlState = SqlState(Cow::Borrowed("XX002"));
777777
}
778-
#[cfg_attr(rustfmt, rustfmt_skip)]
778+
#[rustfmt::skip]
779779
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = ::phf::Map {
780780
key: 3213172566270843353,
781781
disps: ::phf::Slice::Static(&[

tokio-postgres/src/types/chrono_04.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl ToSql for DateTime<FixedOffset> {
103103
impl<'a> FromSql<'a> for NaiveDate {
104104
fn from_sql(_: &Type, raw: &[u8]) -> Result<NaiveDate, Box<dyn Error + Sync + Send>> {
105105
let jd = types::date_from_sql(raw)?;
106-
Ok(base().date() + Duration::days(jd as i64))
106+
Ok(base().date() + Duration::days(i64::from(jd)))
107107
}
108108

109109
accepts!(DATE);
@@ -112,7 +112,7 @@ impl<'a> FromSql<'a> for NaiveDate {
112112
impl ToSql for NaiveDate {
113113
fn to_sql(&self, _: &Type, w: &mut Vec<u8>) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
114114
let jd = self.signed_duration_since(base().date()).num_days();
115-
if jd > i32::max_value() as i64 || jd < i32::min_value() as i64 {
115+
if jd > i64::from(i32::max_value()) || jd < i64::from(i32::min_value()) {
116116
return Err("value too large to transmit".into());
117117
}
118118

tokio-postgres/tests/test/types/chrono_04.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::types::test_type;
55

66
#[test]
77
fn test_naive_date_time_params() {
8-
fn make_check<'a>(time: &'a str) -> (Option<NaiveDateTime>, &'a str) {
8+
fn make_check(time: &str) -> (Option<NaiveDateTime>, &str) {
99
(
1010
Some(NaiveDateTime::parse_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'").unwrap()),
1111
time,
@@ -24,7 +24,7 @@ fn test_naive_date_time_params() {
2424

2525
#[test]
2626
fn test_with_special_naive_date_time_params() {
27-
fn make_check<'a>(time: &'a str) -> (Timestamp<NaiveDateTime>, &'a str) {
27+
fn make_check(time: &str) -> (Timestamp<NaiveDateTime>, &str) {
2828
(
2929
Timestamp::Value(
3030
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() {
4646

4747
#[test]
4848
fn test_date_time_params() {
49-
fn make_check<'a>(time: &'a str) -> (Option<DateTime<Utc>>, &'a str) {
49+
fn make_check(time: &str) -> (Option<DateTime<Utc>>, &str) {
5050
(
5151
Some(
5252
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
@@ -68,7 +68,7 @@ fn test_date_time_params() {
6868

6969
#[test]
7070
fn test_with_special_date_time_params() {
71-
fn make_check<'a>(time: &'a str) -> (Timestamp<DateTime<Utc>>, &'a str) {
71+
fn make_check(time: &str) -> (Timestamp<DateTime<Utc>>, &str) {
7272
(
7373
Timestamp::Value(
7474
Utc.datetime_from_str(time, "'%Y-%m-%d %H:%M:%S.%f'")
@@ -91,7 +91,7 @@ fn test_with_special_date_time_params() {
9191

9292
#[test]
9393
fn test_date_params() {
94-
fn make_check<'a>(time: &'a str) -> (Option<NaiveDate>, &'a str) {
94+
fn make_check(time: &str) -> (Option<NaiveDate>, &str) {
9595
(
9696
Some(NaiveDate::parse_from_str(time, "'%Y-%m-%d'").unwrap()),
9797
time,
@@ -110,7 +110,7 @@ fn test_date_params() {
110110

111111
#[test]
112112
fn test_with_special_date_params() {
113-
fn make_check<'a>(date: &'a str) -> (Date<NaiveDate>, &'a str) {
113+
fn make_check(date: &str) -> (Date<NaiveDate>, &str) {
114114
(
115115
Date::Value(NaiveDate::parse_from_str(date, "'%Y-%m-%d'").unwrap()),
116116
date,
@@ -130,7 +130,7 @@ fn test_with_special_date_params() {
130130

131131
#[test]
132132
fn test_time_params() {
133-
fn make_check<'a>(time: &'a str) -> (Option<NaiveTime>, &'a str) {
133+
fn make_check(time: &str) -> (Option<NaiveTime>, &str) {
134134
(
135135
Some(NaiveTime::parse_from_str(time, "'%H:%M:%S.%f'").unwrap()),
136136
time,

tokio-postgres/tests/test/types/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ fn test_i32_params() {
9999
test_type(
100100
"INT",
101101
&[
102-
(Some(2147483548i32), "2147483548"),
103-
(Some(-2147483548i32), "-2147483548"),
102+
(Some(2_147_483_548i32), "2147483548"),
103+
(Some(-2_147_483_548i32), "-2147483548"),
104104
(None, "NULL"),
105105
],
106106
);
@@ -111,8 +111,8 @@ fn test_oid_params() {
111111
test_type(
112112
"OID",
113113
&[
114-
(Some(2147483548u32), "2147483548"),
115-
(Some(4000000000), "4000000000"),
114+
(Some(2_147_483_548u32), "2147483548"),
115+
(Some(4_000_000_000), "4000000000"),
116116
(None, "NULL"),
117117
],
118118
);
@@ -123,8 +123,8 @@ fn test_i64_params() {
123123
test_type(
124124
"BIGINT",
125125
&[
126-
(Some(9223372036854775708i64), "9223372036854775708"),
127-
(Some(-9223372036854775708i64), "-9223372036854775708"),
126+
(Some(9_223_372_036_854_775_708i64), "9223372036854775708"),
127+
(Some(-9_223_372_036_854_775_708i64), "-9223372036854775708"),
128128
(None, "NULL"),
129129
],
130130
);
@@ -343,6 +343,7 @@ fn test_array_params() {
343343
);
344344
}
345345

346+
#[allow(clippy::eq_op)]
346347
fn test_nan_param<T>(sql_type: &str)
347348
where
348349
T: PartialEq + ToSql + FromSqlOwned,
@@ -616,7 +617,7 @@ fn system_time() {
616617
"'1969-12-31 23:59:58.99'",
617618
),
618619
(
619-
Some(UNIX_EPOCH + Duration::from_millis(946684800 * 1000 + 1_010)),
620+
Some(UNIX_EPOCH + Duration::from_millis(946_684_800 * 1000 + 1_010)),
620621
"'2000-01-01 00:00:01.01'",
621622
),
622623
(None, "NULL"),

0 commit comments

Comments
 (0)