Skip to content

Commit 1ae9134

Browse files
committed
fix: resolve auto-deref and other clippy warnings
- Remove explicit derefs that would be done by auto-deref - Fix needless borrows in various modules - Replace is_digit(10) with is_ascii_digit() - Fix doc list indentation in postgres/copy.rs
1 parent eb5177d commit 1ae9134

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ where
162162
Ok(())
163163
}
164164

165-
MaybeTlsStream::Upgrading => {
166-
Err(Error::Io(io::ErrorKind::ConnectionAborted.into()))
167-
}
165+
MaybeTlsStream::Upgrading => Err(Error::Io(io::ErrorKind::ConnectionAborted.into())),
168166
}
169167
}
170168
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async fn prepare(
4848

4949
// next we send the PARSE command to the server
5050
conn.stream.write(Parse {
51-
param_types: &*param_types,
51+
param_types: &param_types,
5252
query: sql,
5353
statement: id,
5454
});
@@ -228,7 +228,7 @@ impl PgConnection {
228228
formats: &[PgValueFormat::Binary],
229229
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap)]
230230
num_params: arguments.types.len() as i16,
231-
params: &*arguments.buffer,
231+
params: &arguments.buffer,
232232
result_formats: &[PgValueFormat::Binary],
233233
});
234234

sqlx-core/src/postgres/connection/sasl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub(crate) async fn authenticate(
107107
let client_key = mac.finalize().into_bytes();
108108

109109
// StoredKey := H(ClientKey)
110-
let stored_key = Sha256::digest(&client_key);
110+
let stored_key = Sha256::digest(client_key);
111111

112112
// client-final-message-without-proof
113113
let client_final_message_wo_proof = format!(
@@ -126,7 +126,7 @@ pub(crate) async fn authenticate(
126126

127127
// ClientSignature := HMAC(StoredKey, AuthMessage)
128128
let mut mac = Hmac::<Sha256>::new_from_slice(&stored_key).map_err(Error::protocol)?;
129-
mac.update(&auth_message.as_bytes());
129+
mac.update(auth_message.as_bytes());
130130

131131
let client_signature = mac.finalize().into_bytes();
132132

@@ -145,7 +145,7 @@ pub(crate) async fn authenticate(
145145

146146
// ServerSignature := HMAC(ServerKey, AuthMessage)
147147
let mut mac = Hmac::<Sha256>::new_from_slice(&server_key).map_err(Error::protocol)?;
148-
mac.update(&auth_message.as_bytes());
148+
mac.update(auth_message.as_bytes());
149149

150150
// client-final-message = client-final-message-without-proof "," proof
151151
let client_final_message = format!(
@@ -203,7 +203,7 @@ fn gen_nonce() -> String {
203203
fn hi<'a>(s: &'a str, salt: &'a [u8], iter_count: u32) -> Result<[u8; 32], Error> {
204204
let mut mac = Hmac::<Sha256>::new_from_slice(s.as_bytes()).map_err(Error::protocol)?;
205205

206-
mac.update(&salt);
206+
mac.update(salt);
207207
mac.update(&1u32.to_be_bytes());
208208

209209
let mut u = mac.finalize().into_bytes();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn parse_server_version(s: &str) -> Option<u32> {
203203
break;
204204
}
205205
}
206-
_ if ch.is_digit(10) => {
206+
_ if ch.is_ascii_digit() => {
207207
if chs.peek().is_none() {
208208
if let Ok(num) = u32::from_str(&s[from..]) {
209209
parts.push(num);

sqlx-core/src/postgres/copy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl PgConnection {
4242
///
4343
/// 1. by closing the connection, or:
4444
/// 2. by using another connection to kill the server process that is sending the data as shown
45-
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
45+
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
4646
///
4747
/// If you don't read the stream to completion, the next time the connection is used it will
4848
/// need to read and discard all the remaining queued data, which could take some time.
@@ -90,7 +90,7 @@ impl Pool<Postgres> {
9090
///
9191
/// 1. by closing the connection, or:
9292
/// 2. by using another connection to kill the server process that is sending the data as shown
93-
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
93+
/// [in this StackOverflow answer](https://stackoverflow.com/a/35319598).
9494
///
9595
/// If you don't read the stream to completion, the next time the connection is used it will
9696
/// need to read and discard all the remaining queued data, which could take some time.
@@ -208,7 +208,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
208208
// ensures the buffer isn't left in an inconsistent state
209209
let mut guard = BufGuard(&mut buf_stream.wbuf);
210210

211-
let buf: &mut Vec<u8> = &mut guard.0;
211+
let buf: &mut Vec<u8> = guard.0;
212212
buf.push(b'd'); // CopyData format code
213213
buf.resize(5, 0); // reserve space for the length
214214

sqlx-core/src/postgres/message/authentication.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ impl Decode<'_> for AuthenticationSaslContinue {
162162
Ok(Self {
163163
iterations,
164164
salt,
165-
nonce: from_utf8(&*nonce).map_err(Error::protocol)?.to_owned(),
166-
message: from_utf8(&*buf).map_err(Error::protocol)?.to_owned(),
165+
nonce: from_utf8(&nonce).map_err(Error::protocol)?.to_owned(),
166+
message: from_utf8(&buf).map_err(Error::protocol)?.to_owned(),
167167
})
168168
}
169169
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ impl FromStr for PgConnectOptions {
2828
let username = url.username();
2929
if !username.is_empty() {
3030
options = options.username(
31-
&*percent_decode_str(username)
31+
&percent_decode_str(username)
3232
.decode_utf8()
3333
.map_err(Error::config)?,
3434
);
3535
}
3636

3737
if let Some(password) = url.password() {
3838
options = options.password(
39-
&*percent_decode_str(password)
39+
&percent_decode_str(password)
4040
.decode_utf8()
4141
.map_err(Error::config)?,
4242
);

0 commit comments

Comments
 (0)