Skip to content

Commit 4f982d8

Browse files
style: fix latest clippy warnings
1 parent e1cd6be commit 4f982d8

File tree

18 files changed

+39
-49
lines changed

18 files changed

+39
-49
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/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-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

postgres-types/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl fmt::Display for Type {
319319
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
320320
match self.schema() {
321321
"public" | "pg_catalog" => {}
322-
schema => write!(fmt, "{}.", schema)?,
322+
schema => write!(fmt, "{schema}.")?,
323323
}
324324
fmt.write_str(self.name())
325325
}
@@ -631,16 +631,14 @@ impl<'a, T: FromSql<'a>, const N: usize> FromSql<'a> for [T; N] {
631631
let v = values
632632
.next()?
633633
.ok_or_else(|| -> Box<dyn Error + Sync + Send> {
634-
format!("too few elements in array (expected {}, got {})", N, i).into()
634+
format!("too few elements in array (expected {N}, got {i})").into()
635635
})?;
636636
T::from_sql_nullable(member_type, v)
637637
})?;
638638
if values.next()?.is_some() {
639-
return Err(format!(
640-
"excess elements in array (expected {}, got more than that)",
641-
N,
642-
)
643-
.into());
639+
return Err(
640+
format!("excess elements in array (expected {N}, got more than that)",).into(),
641+
);
644642
}
645643

646644
Ok(out)

postgres-types/src/pg_lsn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl fmt::Display for PgLsn {
5252

5353
impl fmt::Debug for PgLsn {
5454
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
55-
f.write_fmt(format_args!("{}", self))
55+
f.write_fmt(format_args!("{self}"))
5656
}
5757
}
5858

0 commit comments

Comments
 (0)