Skip to content

Commit

Permalink
Bump rustversion to 1.83 and fix new clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
weiznich committed Nov 29, 2024
1 parent a24d0ca commit 8f21a45
Show file tree
Hide file tree
Showing 70 changed files with 250 additions and 212 deletions.
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
4 changes: 4 additions & 0 deletions diesel/src/connection/instrumentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub enum InstrumentationEvent<'a> {
// these constructors exist to
// keep `#[non_exhaustive]` on all the variants
// and to gate the constructors on the unstable feature
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
impl<'a> InstrumentationEvent<'a> {
/// Create a new `InstrumentationEvent::StartEstablishConnection` event
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
Expand Down Expand Up @@ -351,6 +352,7 @@ impl DerefMut for DynInstrumentation {
}

impl DynInstrumentation {
/// Create a instance of the default instrumentation provider
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
Expand All @@ -361,6 +363,7 @@ impl DynInstrumentation {
}
}

/// Create a noop instrumentation provider instance
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
Expand All @@ -371,6 +374,7 @@ impl DynInstrumentation {
}
}

/// register an event with the given instrumentation implementation
#[diesel_derives::__diesel_public_if(
feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
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 @@ -601,6 +601,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/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,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 @@ -314,7 +314,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 @@ -161,7 +161,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 @@ -701,7 +701,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 @@ -1030,16 +1030,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 @@ -84,7 +84,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 @@ -121,7 +121,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 @@ -175,7 +175,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 @@ -3804,7 +3804,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
8 changes: 4 additions & 4 deletions diesel/src/pg/query_builder/on_constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ pub struct OnConstraint<'a> {
constraint_name: &'a str,
}

impl<'a> QueryId for OnConstraint<'a> {
impl QueryId for OnConstraint<'_> {
type QueryId = ();

const HAS_STATIC_QUERY_ID: bool = false;
}

impl<'a> QueryFragment<Pg, crate::pg::backend::PgOnConflictClause>
for ConflictTarget<OnConstraint<'a>>
impl QueryFragment<Pg, crate::pg::backend::PgOnConflictClause>
for ConflictTarget<OnConstraint<'_>>
{
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
out.unsafe_to_cache_prepared();
Expand All @@ -70,4 +70,4 @@ impl<'a> QueryFragment<Pg, crate::pg::backend::PgOnConflictClause>
}
}

impl<'a, Table> OnConflictTarget<Table> for ConflictTarget<OnConstraint<'a>> {}
impl<Table> OnConflictTarget<Table> for ConflictTarget<OnConstraint<'_>> {}
Loading

0 comments on commit 8f21a45

Please sign in to comment.