Skip to content

Commit 7ad4ef1

Browse files
committed
fix clippy warnings
1 parent b98f8b8 commit 7ad4ef1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+73
-84
lines changed

sqlx-cli/src/database.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unexpected_cfgs)]
12
use crate::migrate;
23
use crate::opt::ConnectOpts;
34
use console::{style, Term};

sqlx-cli/src/opt.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unexpected_cfgs)]
12
use std::ops::{Deref, Not};
23

34
use clap::{Args, Parser};

sqlx-core/src/any/arguments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'q> Arguments<'q> for AnyArguments<'q> {
3232

3333
pub struct AnyArgumentBuffer<'q>(#[doc(hidden)] pub Vec<AnyValueKind<'q>>);
3434

35-
impl<'q> Default for AnyArguments<'q> {
35+
impl Default for AnyArguments<'_> {
3636
fn default() -> Self {
3737
AnyArguments {
3838
values: AnyArgumentBuffer(vec![]),

sqlx-core/src/any/connection/backend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ pub trait AnyConnectionBackend: std::any::Any + Debug + Send + 'static {
8888
parameters: &[AnyTypeInfo],
8989
) -> BoxFuture<'c, crate::Result<AnyStatement>>;
9090

91-
fn describe<'q>(&'q mut self, sql: SqlStr) -> BoxFuture<'q, crate::Result<Describe<Any>>>;
91+
fn describe(&mut self, sql: SqlStr) -> BoxFuture<'_, crate::Result<Describe<Any>>>;
9292
}

sqlx-core/src/any/row.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl Row for AnyRow {
6363
}
6464
}
6565

66-
impl<'i> ColumnIndex<AnyRow> for &'i str {
66+
impl ColumnIndex<AnyRow> for &'_ str {
6767
fn index(&self, row: &AnyRow) -> Result<usize, Error> {
6868
row.column_names
6969
.get(*self)

sqlx-core/src/any/statement.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl Statement for AnyStatement {
5555
impl_statement_query!(AnyArguments<'_>);
5656
}
5757

58-
impl<'i> ColumnIndex<AnyStatement> for &'i str {
58+
impl ColumnIndex<AnyStatement> for &'_ str {
5959
fn index(&self, statement: &AnyStatement) -> Result<usize, Error> {
6060
statement
6161
.column_names
@@ -65,7 +65,7 @@ impl<'i> ColumnIndex<AnyStatement> for &'i str {
6565
}
6666
}
6767

68-
impl<'q> AnyStatement {
68+
impl AnyStatement {
6969
#[doc(hidden)]
7070
pub fn try_from_statement<S>(
7171
statement: S,

sqlx-core/src/ext/async_stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<T> Yielder<T> {
9595
}
9696
}
9797

98-
impl<'a, T> Stream for TryAsyncStream<'a, T> {
98+
impl<T> Stream for TryAsyncStream<'_, T> {
9999
type Item = Result<T, Error>;
100100

101101
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {

sqlx-core/src/io/encode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub trait ProtocolEncode<'en, Context = ()> {
99
fn encode_with(&self, buf: &mut Vec<u8>, context: Context) -> Result<(), crate::Error>;
1010
}
1111

12-
impl<'en, C> ProtocolEncode<'en, C> for &'_ [u8] {
12+
impl<C> ProtocolEncode<'_, C> for &'_ [u8] {
1313
fn encode_with(&self, buf: &mut Vec<u8>, _context: C) -> Result<(), crate::Error> {
1414
buf.extend_from_slice(self);
1515
Ok(())

sqlx-core/src/net/socket/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct Read<'a, S: ?Sized, B> {
6262
buf: &'a mut B,
6363
}
6464

65-
impl<'a, S: ?Sized, B> Future for Read<'a, S, B>
65+
impl<S: ?Sized, B> Future for Read<'_, S, B>
6666
where
6767
S: Socket,
6868
B: ReadBuf,
@@ -90,7 +90,7 @@ pub struct Write<'a, S: ?Sized> {
9090
buf: &'a [u8],
9191
}
9292

93-
impl<'a, S: ?Sized> Future for Write<'a, S>
93+
impl<S: ?Sized> Future for Write<'_, S>
9494
where
9595
S: Socket,
9696
{
@@ -116,7 +116,7 @@ pub struct Flush<'a, S: ?Sized> {
116116
socket: &'a mut S,
117117
}
118118

119-
impl<'a, S: Socket + ?Sized> Future for Flush<'a, S> {
119+
impl<S: Socket + ?Sized> Future for Flush<'_, S> {
120120
type Output = io::Result<()>;
121121

122122
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
@@ -128,7 +128,7 @@ pub struct Shutdown<'a, S: ?Sized> {
128128
socket: &'a mut S,
129129
}
130130

131-
impl<'a, S: ?Sized> Future for Shutdown<'a, S>
131+
impl<S: ?Sized> Future for Shutdown<'_, S>
132132
where
133133
S: Socket,
134134
{

sqlx-core/src/pool/inner.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ pub(super) fn is_beyond_max_lifetime<DB: Database>(
452452
) -> bool {
453453
options
454454
.max_lifetime
455-
.map_or(false, |max| live.created_at.elapsed() > max)
455+
.is_some_and(|max| live.created_at.elapsed() > max)
456456
}
457457

458458
/// Returns `true` if the connection has exceeded `options.idle_timeout` if set, `false` otherwise.
459459
fn is_beyond_idle_timeout<DB: Database>(idle: &Idle<DB>, options: &PoolOptions<DB>) -> bool {
460460
options
461461
.idle_timeout
462-
.map_or(false, |timeout| idle.idle_since.elapsed() > timeout)
462+
.is_some_and(|timeout| idle.idle_since.elapsed() > timeout)
463463
}
464464

465465
async fn check_idle_conn<DB: Database>(

sqlx-core/src/pool/maybe.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub enum MaybePoolConnection<'c, DB: Database> {
88
PoolConnection(PoolConnection<DB>),
99
}
1010

11-
impl<'c, DB: Database> Deref for MaybePoolConnection<'c, DB> {
11+
impl<DB: Database> Deref for MaybePoolConnection<'_, DB> {
1212
type Target = DB::Connection;
1313

1414
#[inline]
@@ -20,7 +20,7 @@ impl<'c, DB: Database> Deref for MaybePoolConnection<'c, DB> {
2020
}
2121
}
2222

23-
impl<'c, DB: Database> DerefMut for MaybePoolConnection<'c, DB> {
23+
impl<DB: Database> DerefMut for MaybePoolConnection<'_, DB> {
2424
#[inline]
2525
fn deref_mut(&mut self) -> &mut Self::Target {
2626
match self {
@@ -30,7 +30,7 @@ impl<'c, DB: Database> DerefMut for MaybePoolConnection<'c, DB> {
3030
}
3131
}
3232

33-
impl<'c, DB: Database> From<PoolConnection<DB>> for MaybePoolConnection<'c, DB> {
33+
impl<DB: Database> From<PoolConnection<DB>> for MaybePoolConnection<'_, DB> {
3434
fn from(v: PoolConnection<DB>) -> Self {
3535
MaybePoolConnection::PoolConnection(v)
3636
}

sqlx-core/src/query.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'q, DB: Database> Query<'q, DB, <DB as Database>::Arguments<'q>> {
121121
}
122122
}
123123

124-
impl<'q, DB, A> Query<'q, DB, A>
124+
impl<DB, A> Query<'_, DB, A>
125125
where
126126
DB: Database + HasStatementCache,
127127
{
@@ -498,9 +498,9 @@ where
498498
}
499499

500500
/// Execute a single SQL query as a prepared statement (explicitly created).
501-
pub fn query_statement<'q, DB>(
502-
statement: &'q DB::Statement,
503-
) -> Query<'q, DB, <DB as Database>::Arguments<'_>>
501+
pub fn query_statement<DB>(
502+
statement: &DB::Statement,
503+
) -> Query<'_, DB, <DB as Database>::Arguments<'_>>
504504
where
505505
DB: Database,
506506
{

sqlx-core/src/query_as.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'q, DB: Database, O> QueryAs<'q, DB, O, <DB as Database>::Arguments<'q>> {
5858
}
5959
}
6060

61-
impl<'q, DB, O, A> QueryAs<'q, DB, O, A>
61+
impl<DB, O, A> QueryAs<'_, DB, O, A>
6262
where
6363
DB: Database + HasStatementCache,
6464
{
@@ -387,9 +387,9 @@ where
387387
}
388388

389389
// Make a SQL query from a statement, that is mapped to a concrete type.
390-
pub fn query_statement_as<'q, DB, O>(
391-
statement: &'q DB::Statement,
392-
) -> QueryAs<'q, DB, O, <DB as Database>::Arguments<'_>>
390+
pub fn query_statement_as<DB, O>(
391+
statement: &DB::Statement,
392+
) -> QueryAs<'_, DB, O, <DB as Database>::Arguments<'_>>
393393
where
394394
DB: Database,
395395
O: for<'r> FromRow<'r, DB::Row>,

sqlx-core/src/query_builder.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
arguments: Option<<DB as Database>::Arguments<'args>>,
3434
}
3535

36-
impl<'args, DB: Database> Default for QueryBuilder<'args, DB> {
36+
impl<DB: Database> Default for QueryBuilder<'_, DB> {
3737
fn default() -> Self {
3838
QueryBuilder {
3939
init_len: 0,
@@ -198,7 +198,6 @@ where
198198
/// assert!(sql.ends_with("in (?, ?) "));
199199
/// # }
200200
/// ```
201-
202201
pub fn separated<'qb, Sep>(&'qb mut self, separator: Sep) -> Separated<'qb, 'args, DB, Sep>
203202
where
204203
'args: 'qb,

sqlx-core/src/query_scalar.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'q, DB: Database, O> QueryScalar<'q, DB, O, <DB as Database>::Arguments<'q>
5555
}
5656
}
5757

58-
impl<'q, DB, O, A> QueryScalar<'q, DB, O, A>
58+
impl<DB, O, A> QueryScalar<'_, DB, O, A>
5959
where
6060
DB: Database + HasStatementCache,
6161
{
@@ -367,9 +367,9 @@ where
367367
}
368368

369369
// Make a SQL query from a statement, that is mapped to a concrete value.
370-
pub fn query_statement_scalar<'q, DB, O>(
371-
statement: &'q DB::Statement,
372-
) -> QueryScalar<'q, DB, O, <DB as Database>::Arguments<'_>>
370+
pub fn query_statement_scalar<DB, O>(
371+
statement: &DB::Statement,
372+
) -> QueryScalar<'_, DB, O, <DB as Database>::Arguments<'_>>
373373
where
374374
DB: Database,
375375
(O,): for<'r> FromRow<'r, DB::Row>,

sqlx-core/src/raw_sql.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,14 @@ impl<'q, DB: Database> Execute<'q, DB> for RawSql {
137137
}
138138
}
139139

140-
impl<'q> RawSql {
140+
impl RawSql {
141141
/// Execute the SQL string and return the total number of rows affected.
142142
#[inline]
143143
pub async fn execute<'e, E>(
144144
self,
145145
executor: E,
146146
) -> crate::Result<<E::Database as Database>::QueryResult>
147147
where
148-
'q: 'e,
149148
E: Executor<'e>,
150149
{
151150
executor.execute(self).await
@@ -158,7 +157,6 @@ impl<'q> RawSql {
158157
executor: E,
159158
) -> BoxStream<'e, crate::Result<<E::Database as Database>::QueryResult>>
160159
where
161-
'q: 'e,
162160
E: Executor<'e>,
163161
{
164162
executor.execute_many(self)
@@ -173,7 +171,6 @@ impl<'q> RawSql {
173171
executor: E,
174172
) -> BoxStream<'e, Result<<E::Database as Database>::Row, Error>>
175173
where
176-
'q: 'e,
177174
E: Executor<'e>,
178175
{
179176
executor.fetch(self)
@@ -195,7 +192,6 @@ impl<'q> RawSql {
195192
>,
196193
>
197194
where
198-
'q: 'e,
199195
E: Executor<'e>,
200196
{
201197
executor.fetch_many(self)
@@ -214,7 +210,6 @@ impl<'q> RawSql {
214210
executor: E,
215211
) -> crate::Result<Vec<<E::Database as Database>::Row>>
216212
where
217-
'q: 'e,
218213
E: Executor<'e>,
219214
{
220215
executor.fetch_all(self).await
@@ -238,7 +233,6 @@ impl<'q> RawSql {
238233
executor: E,
239234
) -> crate::Result<<E::Database as Database>::Row>
240235
where
241-
'q: 'e,
242236
E: Executor<'e>,
243237
{
244238
executor.fetch_one(self).await
@@ -262,7 +256,6 @@ impl<'q> RawSql {
262256
executor: E,
263257
) -> crate::Result<<E::Database as Database>::Row>
264258
where
265-
'q: 'e,
266259
E: Executor<'e>,
267260
{
268261
executor.fetch_one(self).await

sqlx-core/src/rt/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub enum JoinHandle<T> {
2626
pub async fn timeout<F: Future>(duration: Duration, f: F) -> Result<F::Output, TimeoutError> {
2727
#[cfg(feature = "_rt-tokio")]
2828
if rt_tokio::available() {
29+
#[allow(clippy::needless_return)]
2930
return tokio::time::timeout(duration, f)
3031
.await
3132
.map_err(|_| TimeoutError(()));
@@ -116,6 +117,7 @@ pub async fn yield_now() {
116117
pub fn test_block_on<F: Future>(f: F) -> F::Output {
117118
#[cfg(feature = "_rt-tokio")]
118119
{
120+
#[allow(clippy::needless_return)]
119121
return tokio::runtime::Builder::new_current_thread()
120122
.enable_all()
121123
.build()

sqlx-core/src/sql_str.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pub trait SqlSafeStr {
4242

4343
impl SqlSafeStr for &'static str {
4444
#[inline]
45-
4645
fn into_sql_str(self) -> SqlStr {
4746
SqlStr(Repr::Static(self))
4847
}
@@ -68,7 +67,7 @@ pub struct AssertSqlSafe<T>(pub T);
6867
/// Note: copies the string.
6968
///
7069
/// It is recommended to pass one of the supported owned string types instead.
71-
impl<'a> SqlSafeStr for AssertSqlSafe<&'a str> {
70+
impl SqlSafeStr for AssertSqlSafe<&str> {
7271
#[inline]
7372
fn into_sql_str(self) -> SqlStr {
7473
SqlStr(Repr::Arced(self.0.into()))

sqlx-core/src/transaction.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ where
183183
// }
184184
// }
185185

186-
impl<'c, DB> Debug for Transaction<'c, DB>
186+
impl<DB> Debug for Transaction<'_, DB>
187187
where
188188
DB: Database,
189189
{
@@ -193,7 +193,7 @@ where
193193
}
194194
}
195195

196-
impl<'c, DB> Deref for Transaction<'c, DB>
196+
impl<DB> Deref for Transaction<'_, DB>
197197
where
198198
DB: Database,
199199
{
@@ -205,7 +205,7 @@ where
205205
}
206206
}
207207

208-
impl<'c, DB> DerefMut for Transaction<'c, DB>
208+
impl<DB> DerefMut for Transaction<'_, DB>
209209
where
210210
DB: Database,
211211
{
@@ -219,13 +219,13 @@ where
219219
// `PgAdvisoryLockGuard`.
220220
//
221221
// See: https://github.com/launchbadge/sqlx/issues/2520
222-
impl<'c, DB: Database> AsMut<DB::Connection> for Transaction<'c, DB> {
222+
impl<DB: Database> AsMut<DB::Connection> for Transaction<'_, DB> {
223223
fn as_mut(&mut self) -> &mut DB::Connection {
224224
&mut self.connection
225225
}
226226
}
227227

228-
impl<'c, 't, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'c, DB> {
228+
impl<'t, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'_, DB> {
229229
type Database = DB;
230230

231231
type Connection = &'t mut <DB as Database>::Connection;
@@ -241,7 +241,7 @@ impl<'c, 't, DB: Database> crate::acquire::Acquire<'t> for &'t mut Transaction<'
241241
}
242242
}
243243

244-
impl<'c, DB> Drop for Transaction<'c, DB>
244+
impl<DB> Drop for Transaction<'_, DB>
245245
where
246246
DB: Database,
247247
{

sqlx-core/src/type_checking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ where
112112
}
113113
}
114114

115-
impl<'v, DB> Debug for FmtValue<'v, DB>
115+
impl<DB> Debug for FmtValue<'_, DB>
116116
where
117117
DB: Database,
118118
{

0 commit comments

Comments
 (0)