Skip to content

Commit 2098ac2

Browse files
authored
Merge pull request #1234 from paolobarbolini/clippy
Fix latest clippy warnings
2 parents 490c485 + 20f6bc5 commit 2098ac2

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

postgres-protocol/src/authentication/sasl.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl ScramSha256 {
180180
password,
181181
channel_binding,
182182
} => (nonce, password, channel_binding),
183-
_ => return Err(io::Error::new(io::ErrorKind::Other, "invalid SCRAM state")),
183+
_ => return Err(io::Error::other("invalid SCRAM state")),
184184
};
185185

186186
let message =
@@ -252,7 +252,7 @@ impl ScramSha256 {
252252
salted_password,
253253
auth_message,
254254
} => (salted_password, auth_message),
255-
_ => return Err(io::Error::new(io::ErrorKind::Other, "invalid SCRAM state")),
255+
_ => return Err(io::Error::other("invalid SCRAM state")),
256256
};
257257

258258
let message =
@@ -262,10 +262,7 @@ impl ScramSha256 {
262262

263263
let verifier = match parsed {
264264
ServerFinalMessage::Error(e) => {
265-
return Err(io::Error::new(
266-
io::ErrorKind::Other,
267-
format!("SCRAM error: {}", e),
268-
));
265+
return Err(io::Error::other(format!("SCRAM error: {}", e)));
269266
}
270267
ServerFinalMessage::Verifier(verifier) => verifier,
271268
};

postgres-protocol/src/types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub fn varbit_from_sql(mut buf: &[u8]) -> Result<Varbit<'_>, StdBox<dyn Error +
324324
if len < 0 {
325325
return Err("invalid varbit length: varbit < 0".into());
326326
}
327-
let bytes = (len as usize + 7) / 8;
327+
let bytes = (len as usize).div_ceil(8);
328328
if buf.len() != bytes {
329329
return Err("invalid message length: varbit mismatch".into());
330330
}

postgres/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Connection configuration.
22
3+
#![allow(clippy::doc_overindented_list_items)]
4+
35
use crate::connection::Connection;
46
use crate::Client;
57
use log::info;

postgres/src/copy_in_writer.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ impl Write for CopyInWriter<'_> {
5353
}
5454

5555
fn flush(&mut self) -> io::Result<()> {
56-
self.flush_inner()
57-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))
56+
self.flush_inner().map_err(io::Error::other)
5857
}
5958
}

postgres/src/copy_out_reader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl BufRead for CopyOutReader<'_> {
4141
.block_on(async { stream.next().await.transpose() })
4242
{
4343
Ok(Some(cur)) => self.cur = cur,
44-
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
44+
Err(e) => return Err(io::Error::other(e)),
4545
Ok(None) => break,
4646
};
4747
}

tokio-postgres/src/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Connection configuration.
22
3+
#![allow(clippy::doc_overindented_list_items)]
4+
35
#[cfg(feature = "runtime")]
46
use crate::connect::connect;
57
use crate::connect_raw::connect_raw;

0 commit comments

Comments
 (0)