Skip to content

Commit

Permalink
Fix some clippy and deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Sep 25, 2023
1 parent e0716e2 commit 9f04d8a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions diesel/src/connection/transaction_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ mod test {
.collect::<Vec<_>>();

results.sort_by_key(|r| r.is_err());
assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results);
assert!(results[0].is_ok(), "Got {:?} instead", results);
// Note that contrary to Postgres, this is not a commit failure
assert!(
matches!(&results[1], Err(DatabaseError(SerializationFailure, _))),
Expand Down Expand Up @@ -982,7 +982,7 @@ mod test {
.collect::<Vec<_>>();

results.sort_by_key(|r| r.is_err());
assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results);
assert!(results[0].is_ok(), "Got {:?} instead", results);
assert!(
matches!(&results[1], Err(DatabaseError(SerializationFailure, _))),
"Got {:?} instead",
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/pg/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ mod tests {

results.sort_by_key(|r| r.is_err());

assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results);
assert!(results[0].is_ok(), "Got {:?} instead", results);
assert!(
matches!(&results[1], Err(DatabaseError(SerializationFailure, _))),
"Got {:?} instead",
Expand Down Expand Up @@ -966,7 +966,7 @@ mod tests {

results.sort_by_key(|r| r.is_err());

assert!(matches!(results[0], Ok(_)), "Got {:?} instead", results);
assert!(results[0].is_ok(), "Got {:?} instead", results);
assert!(
matches!(&results[1], Err(DatabaseError(SerializationFailure, _))),
"Got {:?} instead",
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/pg/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ToSql<Timestamptz, Pg> for NaiveDateTime {
impl FromSql<Timestamptz, Pg> for DateTime<Utc> {
fn from_sql(bytes: PgValue<'_>) -> deserialize::Result<Self> {
let naive_date_time = <NaiveDateTime as FromSql<Timestamptz, Pg>>::from_sql(bytes)?;
Ok(DateTime::from_utc(naive_date_time, Utc))
Ok(Utc.from_utc_datetime(&naive_date_time))
}
}

Expand Down
4 changes: 2 additions & 2 deletions diesel/src/query_builder/query_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ mod tests {
}

#[test]
#[cfg(features = "postgres")]
#[cfg(feature = "postgres")]
fn boxed_queries_do_not_have_static_query_id() {
use pg::Pg;
use crate::pg::Pg;
assert!(query_id(users::table.into_boxed::<Pg>()).is_none());
}
}
2 changes: 1 addition & 1 deletion diesel/src/sqlite/connection/sqlite_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'row, 'stmt, 'query> SqliteValue<'row, 'stmt, 'query> {
let s = unsafe {
let ptr = ffi::sqlite3_value_text(self.value.as_ptr());
let len = ffi::sqlite3_value_bytes(self.value.as_ptr());
let bytes = slice::from_raw_parts(ptr as *const u8, len as usize);
let bytes = slice::from_raw_parts(ptr, len as usize);
// The string is guaranteed to be utf8 according to
// https://www.sqlite.org/c3ref/value_blob.html
str::from_utf8_unchecked(bytes)
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/sqlite/types/date_and_time/chrono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl FromSql<TimestamptzSqlite, Sqlite> for DateTime<Utc> {
// Fallback on assuming Utc
let naive_date_time =
<NaiveDateTime as FromSql<TimestamptzSqlite, Sqlite>>::from_sql(value)?;
Ok(DateTime::from_utc(naive_date_time, Utc))
Ok(Utc.from_utc_datetime(&naive_date_time))
}
}

Expand Down
2 changes: 1 addition & 1 deletion diesel_cli/tests/migration_generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Creating migrations.\\d{4}-\\d{2}-\\d{2}-\\d{6}_hello.down.sql\
let captured_timestamps = Regex::new(r"(?P<stamp>[\d-]*)_hello").unwrap();
let mut stamps_found = 0;
for caps in captured_timestamps.captures_iter(result.stdout()) {
let timestamp = Utc.datetime_from_str(&caps["stamp"], TIMESTAMP_FORMAT);
let timestamp = NaiveDateTime::parse_from_str(&caps["stamp"], TIMESTAMP_FORMAT);
assert!(
timestamp.is_ok(),
"Found invalid timestamp format: {:?}",
Expand Down
2 changes: 1 addition & 1 deletion diesel_tests/tests/schema_inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod postgres {
ts: (Bound::Included(dt), Bound::Unbounded),
tstz: (
Bound::Unbounded,
Bound::Excluded(DateTime::<Utc>::from_utc(dt, Utc)),
Bound::Excluded(Utc.from_utc_datetime(&dt)),
),
date: (Bound::Included(dt.date()), Bound::Unbounded),
};
Expand Down
2 changes: 1 addition & 1 deletion diesel_tests/tests/types_roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ mod pg_types {
}

pub fn mk_datetime(data: (i64, u32)) -> DateTime<Utc> {
DateTime::from_utc(mk_pg_naive_datetime(data), Utc)
Utc.from_utc_datetime(&mk_pg_naive_datetime(data))
}
}

Expand Down

0 comments on commit 9f04d8a

Please sign in to comment.