Skip to content

Commit 3ff26ba

Browse files
style: fix latest clippy warnings
1 parent e1cd6be commit 3ff26ba

File tree

28 files changed

+58
-68
lines changed

28 files changed

+58
-68
lines changed

codegen/src/sqlstate.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ fn make_code(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<Fi
7272
file,
7373
r#"
7474
Inner::E{code} => "{code}","#,
75-
code = code,
7675
)
7776
.unwrap();
7877
}
@@ -97,8 +96,6 @@ fn make_consts(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<
9796
/// {code}
9897
pub const {name}: SqlState = SqlState(Inner::E{code});
9998
"#,
100-
name = name,
101-
code = code,
10299
)
103100
.unwrap();
104101
}
@@ -121,8 +118,7 @@ enum Inner {{"#,
121118
write!(
122119
file,
123120
r#"
124-
E{},"#,
125-
code,
121+
E{code},"#,
126122
)
127123
.unwrap();
128124
}

codegen/src/type_gen.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,18 @@ fn parse_types() -> BTreeMap<u32, Type> {
237237
let doc_name = array_re.replace(&name, "$1[]").to_ascii_uppercase();
238238
let mut doc = doc_name.clone();
239239
if let Some(descr) = raw_type.get("descr") {
240-
write!(doc, " - {}", descr).unwrap();
240+
write!(doc, " - {descr}").unwrap();
241241
}
242242
let doc = Escape::new(doc.as_bytes().iter().cloned()).collect();
243243
let doc = String::from_utf8(doc).unwrap();
244244

245245
if let Some(array_type_oid) = raw_type.get("array_type_oid") {
246246
let array_type_oid = array_type_oid.parse::<u32>().unwrap();
247247

248-
let name = format!("_{}", name);
249-
let variant = format!("{}Array", variant);
250-
let doc = format!("{}&#91;&#93;", doc_name);
251-
let ident = format!("{}_ARRAY", ident);
248+
let name = format!("_{name}");
249+
let variant = format!("{variant}Array");
250+
let doc = format!("{doc_name}&#91;&#93;");
251+
let ident = format!("{ident}_ARRAY");
252252

253253
let type_ = Type {
254254
name,

postgres-derive-test/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
let result = conn.query_one(&stmt, &[]).unwrap().get(0);
2222
assert_eq!(val, &result);
2323

24-
let stmt = conn.prepare(&format!("SELECT $1::{}", sql_type)).unwrap();
24+
let stmt = conn.prepare(&format!("SELECT $1::{sql_type}")).unwrap();
2525
let result = conn.query_one(&stmt, &[val]).unwrap().get(0);
2626
assert_eq!(val, &result);
2727
}
@@ -45,7 +45,7 @@ pub fn test_type_asymmetric<T, F, S, C>(
4545
let result: F = conn.query_one(&stmt, &[]).unwrap().get(0);
4646
assert!(cmp(val, &result));
4747

48-
let stmt = conn.prepare(&format!("SELECT $1::{}", sql_type)).unwrap();
48+
let stmt = conn.prepare(&format!("SELECT $1::{sql_type}")).unwrap();
4949
let result: F = conn.query_one(&stmt, &[val]).unwrap().get(0);
5050
assert!(cmp(val, &result));
5151
}

postgres-derive/src/overrides.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Overrides {
6565
"invalid rename_all rule, expected one of: {}",
6666
RENAME_RULES
6767
.iter()
68-
.map(|rule| format!("\"{}\"", rule))
68+
.map(|rule| format!("\"{rule}\""))
6969
.collect::<Vec<_>>()
7070
.join(", ")
7171
),

postgres-derive/src/tosql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn composite_body(fields: &[Field]) -> TokenStream {
196196
postgres_types::IsNull::Yes => -1,
197197
postgres_types::IsNull::No => {
198198
let len = buf.len() - base - 4;
199-
if len > i32::max_value() as usize {
199+
if len > i32::MAX as usize {
200200
return std::result::Result::Err(
201201
std::convert::Into::into("value too large to transmit"));
202202
}

postgres-protocol/src/authentication/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn md5_hash(username: &[u8], password: &[u8], salt: [u8; 4]) -> String {
1414
md5.update(password);
1515
md5.update(username);
1616
let output = md5.finalize_reset();
17-
md5.update(format!("{:x}", output));
17+
md5.update(format!("{output:x}"));
1818
md5.update(salt);
1919
format!("md5{:x}", md5.finalize())
2020
}

postgres-protocol/src/authentication/sasl.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl ScramSha256 {
262262

263263
let verifier = match parsed {
264264
ServerFinalMessage::Error(e) => {
265-
return Err(io::Error::other(format!("SCRAM error: {}", e)));
265+
return Err(io::Error::other(format!("SCRAM error: {e}")));
266266
}
267267
ServerFinalMessage::Verifier(verifier) => verifier,
268268
};
@@ -302,10 +302,8 @@ impl<'a> Parser<'a> {
302302
match self.it.next() {
303303
Some((_, c)) if c == target => Ok(()),
304304
Some((i, c)) => {
305-
let m = format!(
306-
"unexpected character at byte {}: expected `{}` but got `{}",
307-
i, target, c
308-
);
305+
let m =
306+
format!("unexpected character at byte {i}: expected `{target}` but got `{c}");
309307
Err(io::Error::new(io::ErrorKind::InvalidInput, m))
310308
}
311309
None => Err(io::Error::new(
@@ -371,7 +369,7 @@ impl<'a> Parser<'a> {
371369
match self.it.peek() {
372370
Some(&(i, _)) => Err(io::Error::new(
373371
io::ErrorKind::InvalidInput,
374-
format!("unexpected trailing data at byte {}", i),
372+
format!("unexpected trailing data at byte {i}"),
375373
)),
376374
None => Ok(()),
377375
}

postgres-protocol/src/message/backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl Message {
235235
tag => {
236236
return Err(io::Error::new(
237237
io::ErrorKind::InvalidInput,
238-
format!("unknown authentication tag `{}`", tag),
238+
format!("unknown authentication tag `{tag}`"),
239239
));
240240
}
241241
},
@@ -262,7 +262,7 @@ impl Message {
262262
tag => {
263263
return Err(io::Error::new(
264264
io::ErrorKind::InvalidInput,
265-
format!("unknown message tag `{}`", tag),
265+
format!("unknown message tag `{tag}`"),
266266
));
267267
}
268268
};

postgres-protocol/src/password/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,5 @@ pub fn md5(password: &[u8], username: &str) -> String {
102102
let mut hash = Md5::new();
103103
hash.update(&salted_password);
104104
let digest = hash.finalize();
105-
format!("md5{:x}", digest)
105+
format!("md5{digest:x}")
106106
}

postgres-types/src/chrono_04.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a> FromSql<'a> for NaiveDate {
123123
impl ToSql for NaiveDate {
124124
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
125125
let jd = self.signed_duration_since(base().date()).num_days();
126-
if jd > i64::from(i32::max_value()) || jd < i64::from(i32::min_value()) {
126+
if jd > i64::from(i32::MAX) || jd < i64::from(i32::MIN) {
127127
return Err("value too large to transmit".into());
128128
}
129129

0 commit comments

Comments
 (0)