Skip to content

Commit 6df4fdb

Browse files
committed
fix: clippy warnings in mysql testing and mssql modules
- Fix op_ref by using direct comparison in mysql/migrate.rs - Fix needless_borrows_for_generic_args in mysql/testing/mod.rs - Fix drop_non_drop by using let binding instead of drop - Fix single_char_add_str by using push() with char literal - Fix explicit_auto_deref in mssql/column.rs and establish.rs - Fix io_other_error by using std::io::Error::other() - Fix unnecessary_map_or by using is_some_and() - Fix unit_arg by using Default::default() - Add allow for let_unit_value due to platform differences
1 parent ad510f2 commit 6df4fdb

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

sqlx-core/src/mssql/arguments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl MssqlArguments {
8686
// @p1 int, @p2 nvarchar(10), ...
8787

8888
if !declarations.is_empty() {
89-
declarations.push_str(",");
89+
declarations.push(',');
9090
}
9191

9292
declarations.push_str(name);

sqlx-core/src/mssql/column.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl Column for MssqlColumn {
3333
}
3434

3535
fn name(&self) -> &str {
36-
&*self.name
36+
&self.name
3737
}
3838

3939
fn type_info(&self) -> &MssqlTypeInfo {

sqlx-core/src/mssql/connection/establish.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ impl MssqlConnection {
4343
stream.setup_encryption().await?;
4444
}
4545
(Encrypt::Required, Encrypt::Off | Encrypt::NotSupported) => {
46-
return Err(Error::Tls(Box::new(std::io::Error::new(
47-
std::io::ErrorKind::Other,
46+
return Err(Error::Tls(Box::new(std::io::Error::other(
4847
"TLS encryption required but not supported by server",
4948
))));
5049
}
@@ -73,7 +72,7 @@ impl MssqlConnection {
7372
server_name: &options.server_name,
7473
client_interface_name: &options.client_interface_name,
7574
language: &options.language,
76-
database: &*options.database,
75+
database: &options.database,
7776
client_id: [0; 6],
7877
};
7978

sqlx-core/src/mssql/connection/prepare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) async fn prepare(
2828

2929
for m in PARAMS_RE.captures_iter(sql) {
3030
if !params.is_empty() {
31-
params.push_str(",");
31+
params.push(',');
3232
}
3333

3434
params.push_str(&m[0]);

sqlx-core/src/mssql/connection/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl MssqlStream {
142142
// TDS communicates in streams of packets that are themselves streams of messages
143143
pub(super) async fn recv_message(&mut self) -> Result<Message, Error> {
144144
loop {
145-
while self.response.as_ref().map_or(false, |r| !r.1.is_empty()) {
145+
while self.response.as_ref().is_some_and(|r| !r.1.is_empty()) {
146146
let buf = if let Some((_, buf)) = self.response.as_mut() {
147147
buf
148148
} else {

sqlx-core/src/mssql/connection/tls_prelogin_stream_wrapper.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ impl<S: AsyncRead + AsyncWrite + Unpin + Send> AsyncRead for TlsPreloginWrapper<
100100

101101
let read = header_buf.filled().len();
102102
if read == 0 {
103-
return Poll::Ready(Ok(PollReadOut::default()));
103+
return Poll::Ready(Ok(Default::default()));
104104
}
105105

106106
inner.header_pos += read;
107107
}
108108

109109
let header: PacketHeader = Decode::decode(Bytes::copy_from_slice(&inner.header_buf))
110-
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
110+
.map_err(|err| io::Error::other(err))?;
111111

112112
inner.read_remaining = usize::from(header.length) - HEADER_BYTES;
113113

@@ -121,6 +121,7 @@ impl<S: AsyncRead + AsyncWrite + Unpin + Send> AsyncRead for TlsPreloginWrapper<
121121
let max_read = std::cmp::min(inner.read_remaining, buf.remaining());
122122
let mut limited_buf = buf.take(max_read);
123123

124+
#[allow(clippy::let_unit_value)]
124125
let res = ready!(Pin::new(&mut inner.stream).poll_read(cx, &mut limited_buf))?;
125126

126127
let read = limited_buf.filled().len();
@@ -152,14 +153,14 @@ impl<S: AsyncRead + AsyncWrite + Unpin + Send> AsyncRead for TlsPreloginWrapper<
152153
let read = ready!(Pin::new(&mut inner.stream).poll_read(cx, header_buf))?;
153154

154155
if read == 0 {
155-
return Poll::Ready(Ok(PollReadOut::default()));
156+
return Poll::Ready(Ok(Default::default()));
156157
}
157158

158159
inner.header_pos += read;
159160
}
160161

161162
let header: PacketHeader = Decode::decode(Bytes::copy_from_slice(&inner.header_buf))
162-
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
163+
.map_err(|err| io::Error::other(err))?;
163164

164165
inner.read_remaining = usize::from(header.length) - HEADER_BYTES;
165166

sqlx-core/src/mysql/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
192192
.map_err(MigrateError::AccessMigrationMetadata)?;
193193

194194
if let Some(checksum) = checksum {
195-
if checksum == &*migration.checksum {
195+
if checksum == *migration.checksum {
196196
Ok(())
197197
} else {
198198
Err(MigrateError::VersionMismatch(migration.version))

sqlx-core/src/mysql/testing/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl TestSupport for MySql {
4545
.await?;
4646

4747
query("delete from _sqlx_test_databases where db_id = ?")
48-
.bind(&db_id)
48+
.bind(db_id)
4949
.execute(&mut conn)
5050
.await?;
5151

@@ -127,7 +127,7 @@ async fn test_context(args: &TestArgs) -> Result<TestContext<MySql>, Error> {
127127
}
128128

129129
query("insert into _sqlx_test_databases(test_path) values (?)")
130-
.bind(&args.test_path)
130+
.bind(args.test_path)
131131
.execute(&mut conn)
132132
.await?;
133133

@@ -199,7 +199,8 @@ async fn do_cleanup(conn: &mut MySqlConnection) -> Result<usize, Error> {
199199
separated.push_bind(db_id);
200200
}
201201

202-
drop(separated);
202+
// Finalize the separated query builder
203+
let _ = separated;
203204

204205
query.push(")").build().execute(&mut *conn).await?;
205206

0 commit comments

Comments
 (0)