Skip to content

Commit 0715089

Browse files
committed
fix: clippy warnings for mysql and final sqlite modules
- Fix unnecessary_cast in sqlite/statement/virtual.rs - Add is_empty() method to MySqlArguments to fix len_without_is_empty - Fix explicit_auto_deref in mysql/column.rs and mysql/options/parse.rs - Fix needless_borrows_for_generic_args in mysql/connection/auth.rs - Fix borrow_deref_ref in mysql/connection/auth.rs - Fix needless_borrow in mysql/connection/auth.rs and executor.rs - Remove unused lifetime in mysql/connection/executor.rs - Fix get_first by using first() instead of get(0)
1 parent 2d30b57 commit 0715089

File tree

7 files changed

+18
-13
lines changed

7 files changed

+18
-13
lines changed

sqlx-core/src/mysql/arguments.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ impl MySqlArguments {
3131
pub fn len(&self) -> usize {
3232
self.types.len()
3333
}
34+
35+
#[doc(hidden)]
36+
pub fn is_empty(&self) -> bool {
37+
self.types.is_empty()
38+
}
3439
}
3540

3641
impl<'q> Arguments<'q> for MySqlArguments {

sqlx-core/src/mysql/column.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl Column for MySqlColumn {
2424
}
2525

2626
fn name(&self) -> &str {
27-
&*self.name
27+
&self.name
2828
}
2929

3030
fn type_info(&self) -> &MySqlTypeInfo {

sqlx-core/src/mysql/connection/auth.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn scramble_sha1(password: &str, nonce: &Chain<Bytes, Bytes>) -> Vec<u8> {
7676

7777
let mut pw_hash = ctx.finalize_reset();
7878

79-
ctx.update(&pw_hash);
79+
ctx.update(pw_hash);
8080

8181
let pw_hash_hash = ctx.finalize_reset();
8282

@@ -100,7 +100,7 @@ fn scramble_sha256(password: &str, nonce: &Chain<Bytes, Bytes>) -> Vec<u8> {
100100

101101
let mut pw_hash = ctx.finalize_reset();
102102

103-
ctx.update(&pw_hash);
103+
ctx.update(pw_hash);
104104

105105
let pw_hash_hash = ctx.finalize_reset();
106106

@@ -141,10 +141,10 @@ async fn encrypt_rsa<'s>(
141141

142142
let (a, b) = (nonce.first_ref(), nonce.last_ref());
143143
let mut nonce = Vec::with_capacity(a.len() + b.len());
144-
nonce.extend_from_slice(&*a);
145-
nonce.extend_from_slice(&*b);
144+
nonce.extend_from_slice(a);
145+
nonce.extend_from_slice(b);
146146

147-
xor_eq(&mut pass, &*nonce);
147+
xor_eq(&mut pass, &nonce);
148148

149149
// client sends an RSA encrypted password
150150
let pkey = parse_rsa_pub_key(rsa_pub_key)?;
@@ -179,5 +179,5 @@ fn parse_rsa_pub_key(key: &[u8]) -> Result<RsaPublicKey, Error> {
179179
// we are receiving a PKCS#8 RSA Public Key at all
180180
// times from MySQL
181181

182-
RsaPublicKey::from_public_key_pem(&pem).map_err(Error::protocol)
182+
RsaPublicKey::from_public_key_pem(pem).map_err(Error::protocol)
183183
}

sqlx-core/src/mysql/connection/executor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use futures_util::{pin_mut, TryStreamExt};
2525
use std::{borrow::Cow, sync::Arc};
2626

2727
impl MySqlConnection {
28-
async fn get_or_prepare<'c>(
28+
async fn get_or_prepare(
2929
&mut self,
3030
sql: &str,
3131
persistent: bool,
@@ -289,7 +289,7 @@ impl<'c> Executor<'c> for &'c mut MySqlConnection {
289289

290290
let (_, metadata) = self.get_or_prepare(sql, false).await?;
291291

292-
let columns = (&*metadata.columns).clone();
292+
let columns = (*metadata.columns).clone();
293293

294294
let nullable = columns
295295
.iter()
@@ -335,7 +335,7 @@ fn recv_next_result_column(def: &ColumnDefinition, ordinal: usize) -> Result<MyS
335335
(name, _) => UStr::new(name),
336336
};
337337

338-
let type_info = MySqlTypeInfo::from_column(&def);
338+
let type_info = MySqlTypeInfo::from_column(def);
339339

340340
Ok(MySqlColumn {
341341
name,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl MySqlStream {
149149
// TODO: packet joining
150150

151151
if payload
152-
.get(0)
152+
.first()
153153
.ok_or(err_protocol!("Packet empty"))?
154154
.eq(&0xff)
155155
{

sqlx-core/src/mysql/options/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl FromStr for MySqlConnectOptions {
2222
let username = url.username();
2323
if !username.is_empty() {
2424
options = options.username(
25-
&*percent_decode_str(username)
25+
&percent_decode_str(username)
2626
.decode_utf8()
2727
.map_err(Error::config)?,
2828
);

sqlx-core/src/sqlite/statement/virtual.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn prepare(
191191
conn,
192192
query_ptr,
193193
query_len,
194-
flags as u32,
194+
flags,
195195
&mut statement_handle,
196196
&mut tail,
197197
)

0 commit comments

Comments
 (0)