Skip to content

Commit

Permalink
Merge pull request #4369 from weiznich/bump/rust_1.83.0@origin
Browse files Browse the repository at this point in the history
Bump rustversion to 1.83 and fix new clippy lints
  • Loading branch information
weiznich committed Jan 28, 2025
1 parent ac69bb3 commit c0d44e8
Show file tree
Hide file tree
Showing 69 changed files with 300 additions and 214 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
allow:
dependency-type: "direct"
schedule:
interval: "weekly"
reviewers:
- "diesel/reviewer"
versioning-strategy: "widen"
2 changes: 1 addition & 1 deletion diesel/src/associations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub trait HasTable {
fn table() -> Self::Table;
}

impl<'a, T: HasTable> HasTable for &'a T {
impl<T: HasTable> HasTable for &T {
type Table = T::Table;

fn table() -> Self::Table {
Expand Down
16 changes: 9 additions & 7 deletions diesel/src/connection/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ impl DebugQuery for StrQueryHelper<'_> {}
/// implementation of the enum itself and any of its fields
/// is not guarantee to be stable.
//
// This types is carefully designed
// This type is carefully designed
// to avoid any potential overhead by
// taking references for all things
// and by not performing any additional
// work until required.
// In addition it's carefully designed
// not to be dependent on the actual backend
// type, as that makes it easier to to reuse
// type, as that makes it easier to reuse
// `Instrumentation` implementations in
// different a different context
// a different context
#[derive(Debug)]
#[non_exhaustive]
pub enum InstrumentationEvent<'a> {
Expand Down Expand Up @@ -243,7 +243,7 @@ impl<'a> InstrumentationEvent<'a> {
/// `tracing` and `log` are supposed to be part of their own
/// crates.
pub trait Instrumentation: Send + 'static {
/// The function that is invoced for each event
/// The function that is invoked for each event
fn on_connection_event(&mut self, event: InstrumentationEvent<'_>);
}

Expand All @@ -266,9 +266,11 @@ pub fn get_default_instrumentation() -> Option<Box<dyn Instrumentation>> {
///
/// // a simple logger that prints all events to stdout
/// fn simple_logger() -> Option<Box<dyn Instrumentation>> {
/// // we need the explicit argument type there due
/// // to bugs in rustc
/// Some(Box::new(|event: InstrumentationEvent<'_>| println!("{event:?}")))
/// // we need the explicit argument type there due
/// // to bugs in rustc
/// Some(Box::new(|event: InstrumentationEvent<'_>| {
/// println!("{event:?}")
/// }))
/// }
///
/// set_default_instrumentation(simple_logger);
Expand Down
5 changes: 4 additions & 1 deletion diesel/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ pub(crate) mod private {
where
T: super::LoadConnection<B>,
{
type Cursor<'conn, 'query> = <T as super::LoadConnection<B>>::Cursor<'conn, 'query> where T: 'conn;
type Cursor<'conn, 'query>
= <T as super::LoadConnection<B>>::Cursor<'conn, 'query>
where
T: 'conn;
}
}
4 changes: 2 additions & 2 deletions diesel/src/connection/statement_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub enum MaybeCached<'a, T: 'a> {
Cached(&'a mut T),
}

impl<'a, T> Deref for MaybeCached<'a, T> {
impl<T> Deref for MaybeCached<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
Expand All @@ -305,7 +305,7 @@ impl<'a, T> Deref for MaybeCached<'a, T> {
}
}

impl<'a, T> DerefMut for MaybeCached<'a, T> {
impl<T> DerefMut for MaybeCached<'_, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
match *self {
MaybeCached::CannotCache(ref mut x) => x,
Expand Down
12 changes: 6 additions & 6 deletions diesel/src/expression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<T: Expression + ?Sized> Expression for Box<T> {
type SqlType = T::SqlType;
}

impl<'a, T: Expression + ?Sized> Expression for &'a T {
impl<T: Expression + ?Sized> Expression for &T {
type SqlType = T::SqlType;
}

Expand Down Expand Up @@ -698,7 +698,7 @@ impl<T: ValidGrouping<GB> + ?Sized, GB> ValidGrouping<GB> for Box<T> {
type IsAggregate = T::IsAggregate;
}

impl<'a, T: ValidGrouping<GB> + ?Sized, GB> ValidGrouping<GB> for &'a T {
impl<T: ValidGrouping<GB> + ?Sized, GB> ValidGrouping<GB> for &T {
type IsAggregate = T::IsAggregate;
}

Expand Down Expand Up @@ -1027,16 +1027,16 @@ where
{
}

impl<'a, QS, ST, DB, GB, IsAggregate> QueryId
for dyn BoxableExpression<QS, DB, GB, IsAggregate, SqlType = ST> + 'a
impl<QS, ST, DB, GB, IsAggregate> QueryId
for dyn BoxableExpression<QS, DB, GB, IsAggregate, SqlType = ST> + '_
{
type QueryId = ();

const HAS_STATIC_QUERY_ID: bool = false;
}

impl<'a, QS, ST, DB, GB, IsAggregate> ValidGrouping<GB>
for dyn BoxableExpression<QS, DB, GB, IsAggregate, SqlType = ST> + 'a
impl<QS, ST, DB, GB, IsAggregate> ValidGrouping<GB>
for dyn BoxableExpression<QS, DB, GB, IsAggregate, SqlType = ST> + '_
{
type IsAggregate = IsAggregate;
}
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/insertable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub trait CanInsertInSingleQuery<DB: Backend> {
fn rows_to_insert(&self) -> Option<usize>;
}

impl<'a, T, DB> CanInsertInSingleQuery<DB> for &'a T
impl<T, DB> CanInsertInSingleQuery<DB> for &T
where
T: ?Sized + CanInsertInSingleQuery<DB>,
DB: Backend,
Expand Down
12 changes: 6 additions & 6 deletions diesel/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ pub type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>;
#[diesel(sql_type = Text)]
pub struct MigrationVersion<'a>(Cow<'a, str>);

impl<'a> MigrationVersion<'a> {
impl MigrationVersion<'_> {
/// Convert the current migration version into
/// an owned variant with static life time
pub fn as_owned(&self) -> MigrationVersion<'static> {
MigrationVersion(Cow::Owned(self.0.as_ref().to_owned()))
}
}

impl<'a, DB> FromSql<Text, DB> for MigrationVersion<'a>
impl<DB> FromSql<Text, DB> for MigrationVersion<'_>
where
String: FromSql<Text, DB>,
DB: Backend,
Expand All @@ -56,7 +56,7 @@ where
}
}

impl<'a> From<String> for MigrationVersion<'a> {
impl From<String> for MigrationVersion<'_> {
fn from(s: String) -> Self {
MigrationVersion(Cow::Owned(s))
}
Expand All @@ -74,7 +74,7 @@ impl<'a> From<&'a String> for MigrationVersion<'a> {
}
}

impl<'a> Display for MigrationVersion<'a> {
impl Display for MigrationVersion<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.0.as_ref())
}
Expand Down Expand Up @@ -140,7 +140,7 @@ pub trait MigrationSource<DB: Backend> {
fn migrations(&self) -> Result<Vec<Box<dyn Migration<DB>>>>;
}

impl<'a, DB: Backend> Migration<DB> for Box<dyn Migration<DB> + 'a> {
impl<DB: Backend> Migration<DB> for Box<dyn Migration<DB> + '_> {
fn run(&self, conn: &mut dyn BoxableConnection<DB>) -> Result<()> {
(**self).run(conn)
}
Expand All @@ -158,7 +158,7 @@ impl<'a, DB: Backend> Migration<DB> for Box<dyn Migration<DB> + 'a> {
}
}

impl<'a, DB: Backend> Migration<DB> for &'a dyn Migration<DB> {
impl<DB: Backend> Migration<DB> for &dyn Migration<DB> {
fn run(&self, conn: &mut dyn BoxableConnection<DB>) -> Result<()> {
(**self).run(conn)
}
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl RawConnection {
ffi::mysql_options(
result.0.as_ptr(),
ffi::mysql_option::MYSQL_SET_CHARSET_NAME,
b"utf8mb4\0".as_ptr() as *const libc::c_void,
c"utf8mb4".as_ptr() as *const libc::c_void,
)
};
assert_eq!(
Expand Down
10 changes: 7 additions & 3 deletions diesel/src/mysql/connection/stmt/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'a> StatementIterator<'a> {
}
}

impl<'a> Iterator for StatementIterator<'a> {
impl Iterator for StatementIterator<'_> {
type Item = QueryResult<MysqlRow>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'a> Iterator for StatementIterator<'a> {
}
}

impl<'a> ExactSizeIterator for StatementIterator<'a> {
impl ExactSizeIterator for StatementIterator<'_> {
fn len(&self) -> usize {
self.len
}
Expand Down Expand Up @@ -154,7 +154,11 @@ impl PrivateMysqlRow {
impl RowSealed for MysqlRow {}

impl<'a> Row<'a, Mysql> for MysqlRow {
type Field<'f> = MysqlField<'f> where 'a: 'f, Self: 'f;
type Field<'f>
= MysqlField<'f>
where
'a: 'f,
Self: 'f;
type InnerPartialRow = Self;

fn field_count(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/connection/stmt/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub(in crate::mysql::connection) struct MysqlFieldMetadata<'a>(
std::marker::PhantomData<&'a ()>,
);

impl<'a> MysqlFieldMetadata<'a> {
impl MysqlFieldMetadata<'_> {
pub(in crate::mysql::connection) fn field_name(&self) -> Option<&str> {
if self.0.name.is_null() {
None
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/mysql/connection/stmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub(super) struct StatementUse<'a> {
inner: MaybeCached<'a, Statement>,
}

impl<'a> StatementUse<'a> {
impl StatementUse<'_> {
pub(in crate::mysql::connection) fn affected_rows(&self) -> QueryResult<usize> {
let affected_rows = unsafe { ffi::mysql_stmt_affected_rows(self.inner.stmt.as_ptr()) };
affected_rows
Expand Down Expand Up @@ -211,7 +211,7 @@ impl<'a> StatementUse<'a> {
}
}

impl<'a> Drop for StatementUse<'a> {
impl Drop for StatementUse<'_> {
fn drop(&mut self) {
unsafe {
ffi::mysql_stmt_free_result(self.inner.stmt.as_ptr());
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/mysql/query_builder/limit_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where
}
}

impl<'a> QueryFragment<Mysql> for BoxedLimitOffsetClause<'a, Mysql> {
impl QueryFragment<Mysql> for BoxedLimitOffsetClause<'_, Mysql> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Mysql>) -> QueryResult<()> {
match (self.limit.as_ref(), self.offset.as_ref()) {
(Some(limit), Some(offset)) => {
Expand Down
8 changes: 4 additions & 4 deletions diesel/src/pg/connection/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<'conn> CopyFromSink<'conn> {
}
}

impl<'conn> Write for CopyFromSink<'conn> {
impl Write for CopyFromSink<'_> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
self.conn
.put_copy_data(buf)
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'conn> CopyToBuffer<'conn> {
}
}

impl<'conn> Drop for CopyToBuffer<'conn> {
impl Drop for CopyToBuffer<'_> {
#[allow(unsafe_code)] // ffi code
fn drop(&mut self) {
if !self.ptr.is_null() {
Expand All @@ -80,7 +80,7 @@ impl<'conn> Drop for CopyToBuffer<'conn> {
}
}

impl<'conn> Read for CopyToBuffer<'conn> {
impl Read for CopyToBuffer<'_> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
let data = self.fill_buf()?;
let len = usize::min(buf.len(), data.len());
Expand All @@ -90,7 +90,7 @@ impl<'conn> Read for CopyToBuffer<'conn> {
}
}

impl<'conn> BufRead for CopyToBuffer<'conn> {
impl BufRead for CopyToBuffer<'_> {
#[allow(unsafe_code)] // ffi code + ptr arithmetic
fn fill_buf(&mut self) -> std::io::Result<&[u8]> {
if self.data_slice().is_empty() {
Expand Down
4 changes: 2 additions & 2 deletions diesel/src/pg/connection/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'conn, 'query> RowByRowCursor<'conn, 'query> {
}
}

impl<'conn, 'query> Iterator for RowByRowCursor<'conn, 'query> {
impl Iterator for RowByRowCursor<'_, '_> {
type Item = crate::QueryResult<PgRow>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<'conn, 'query> Iterator for RowByRowCursor<'conn, 'query> {
}
}

impl<'conn, 'query> Drop for RowByRowCursor<'conn, 'query> {
impl Drop for RowByRowCursor<'_, '_> {
fn drop(&mut self) {
loop {
let res = super::update_transaction_manager_status(
Expand Down
8 changes: 6 additions & 2 deletions diesel/src/pg/connection/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ impl PgRow {
impl RowSealed for PgRow {}

impl<'a> Row<'a, Pg> for PgRow {
type Field<'f> = PgField<'f> where 'a: 'f, Self: 'f;
type Field<'f>
= PgField<'f>
where
'a: 'f,
Self: 'f;
type InnerPartialRow = Self;

fn field_count(&self) -> usize {
Expand Down Expand Up @@ -81,7 +85,7 @@ impl<'a> Field<'a, Pg> for PgField<'a> {
}
}

impl<'a> TypeOidLookup for PgField<'a> {
impl TypeOidLookup for PgField<'_> {
fn lookup(&self) -> std::num::NonZeroU32 {
self.db_result.column_type(self.col_idx)
}
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/pg/expression/array_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ where
}
}

impl<'a, ST, QS, DB, GB> AsArrayExpression<ST> for BoxedSelectStatement<'a, ST, QS, DB, GB>
impl<ST, QS, DB, GB> AsArrayExpression<ST> for BoxedSelectStatement<'_, ST, QS, DB, GB>
where
ST: 'static,
Self: SelectQuery<SqlType = ST>,
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/pg/expression/expression_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ pub(in crate::pg) mod private {
}
}

impl<'a> JsonRemoveIndex for Vec<&'a str> {
impl JsonRemoveIndex for Vec<&str> {
type Expression = crate::dsl::AsExprOf<Self, Array<Text>>;

fn into_json_index_expression(self) -> Self::Expression {
Expand Down
5 changes: 3 additions & 2 deletions diesel/src/pg/query_builder/copy/copy_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl<'f> Field<'f, Pg> for CopyField<'f> {
}

#[cfg(feature = "postgres")]
impl<'a> TypeOidLookup for CopyField<'a> {
impl TypeOidLookup for CopyField<'_> {
fn lookup(&self) -> std::num::NonZeroU32 {
self.result.column_type(self.col_idx)
}
Expand Down Expand Up @@ -181,7 +181,8 @@ impl<'a> RowIndex<&'a str> for CopyRow<'_> {

#[cfg(feature = "postgres")]
impl<'a> Row<'a, Pg> for CopyRow<'_> {
type Field<'f> = CopyField<'f>
type Field<'f>
= CopyField<'f>
where
'a: 'f,
Self: 'f;
Expand Down
2 changes: 1 addition & 1 deletion diesel/src/pg/query_builder/limit_offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ where
}
}

impl<'a> QueryFragment<Pg> for BoxedLimitOffsetClause<'a, Pg> {
impl QueryFragment<Pg> for BoxedLimitOffsetClause<'_, Pg> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
if let Some(ref limit) = self.limit {
limit.walk_ast(out.reborrow())?;
Expand Down
Loading

0 comments on commit c0d44e8

Please sign in to comment.