Skip to content

Commit e9a7785

Browse files
committed
Inline format args
Ran this to auto-inline all format args: ``` cargo clippy --workspace --fix --all-targets -- -A clippy::all -W clippy::uninlined_format_args ```
1 parent 72e85ef commit e9a7785

34 files changed

+162
-201
lines changed

bindgen-cli/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn main() {
3737
if verbose {
3838
print_verbose_err()
3939
}
40-
eprintln!("{}", info);
40+
eprintln!("{info}");
4141
}));
4242

4343
let bindings =
@@ -48,7 +48,7 @@ pub fn main() {
4848
bindings.write(output).expect("Unable to write output");
4949
}
5050
Err(error) => {
51-
eprintln!("{}", error);
51+
eprintln!("{error}");
5252
std::process::exit(1);
5353
}
5454
};

bindgen-integration/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl ParseCallbacks for MacroCallback {
9898
_ => {
9999
// The system might provide lots of functional macros.
100100
// Ensure we did not miss handling one that we meant to handle.
101-
assert!(!name.starts_with("TESTMACRO_"), "name = {}", name);
101+
assert!(!name.starts_with("TESTMACRO_"), "name = {name}");
102102
}
103103
}
104104
}
@@ -258,7 +258,7 @@ fn setup_wrap_static_fns_test() {
258258
.expect("Unable to generate bindings");
259259

260260
println!("cargo:rustc-link-lib=static=wrap_static_fns"); // tell cargo to link libextern
261-
println!("bindings generated: {}", bindings);
261+
println!("bindings generated: {bindings}");
262262

263263
let obj_path = out_path.join("wrap_static_fns.o");
264264
let lib_path = out_path.join("libwrap_static_fns.a");

bindgen-tests/tests/parse_callbacks/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl ParseCallbacks for EnumVariantRename {
6666
original_variant_name: &str,
6767
_variant_value: EnumVariantValue,
6868
) -> Option<String> {
69-
Some(format!("RENAMED_{}", original_variant_name))
69+
Some(format!("RENAMED_{original_variant_name}"))
7070
}
7171
}
7272

@@ -172,7 +172,7 @@ pub fn lookup(cb: &str) -> Box<dyn ParseCallbacks> {
172172
),
173173
})
174174
} else {
175-
panic!("Couldn't find name ParseCallbacks: {}", cb)
175+
panic!("Couldn't find name ParseCallbacks: {cb}")
176176
}
177177
}
178178
}

bindgen-tests/tests/quickchecking/src/fuzzers.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ impl Arbitrary for DeclarationC {
201201
impl fmt::Display for DeclarationC {
202202
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
203203
match *self {
204-
DeclarationC::FunctionPtrDecl(ref d) => write!(f, "{}", d),
205-
DeclarationC::StructDecl(ref d) => write!(f, "{}", d),
206-
DeclarationC::UnionDecl(ref d) => write!(f, "{}", d),
207-
DeclarationC::VariableDecl(ref d) => write!(f, "{}", d),
208-
DeclarationC::FunctionDecl(ref d) => write!(f, "{}", d),
204+
DeclarationC::FunctionPtrDecl(ref d) => write!(f, "{d}"),
205+
DeclarationC::StructDecl(ref d) => write!(f, "{d}"),
206+
DeclarationC::UnionDecl(ref d) => write!(f, "{d}"),
207+
DeclarationC::VariableDecl(ref d) => write!(f, "{d}"),
208+
DeclarationC::FunctionDecl(ref d) => write!(f, "{d}"),
209209
}
210210
}
211211
}
@@ -225,9 +225,9 @@ impl fmt::Display for DeclarationListC {
225225
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
226226
let mut display = String::new();
227227
for decl in &self.decls {
228-
display += &format!("{}", decl);
228+
display += &format!("{decl}");
229229
}
230-
write!(f, "{}", display)
230+
write!(f, "{display}")
231231
}
232232
}
233233

@@ -347,7 +347,7 @@ impl fmt::Display for ArrayDimensionC {
347347
/// identifiers unique.
348348
impl MakeUnique for BasicTypeDeclarationC {
349349
fn make_unique(&mut self, stamp: usize) {
350-
self.ident_id += &format!("_{}", stamp);
350+
self.ident_id += &format!("_{stamp}");
351351
}
352352
}
353353

@@ -384,7 +384,7 @@ impl fmt::Display for BasicTypeDeclarationC {
384384
/// identifiers unique.
385385
impl MakeUnique for StructDeclarationC {
386386
fn make_unique(&mut self, stamp: usize) {
387-
self.ident_id += &format!("_{}", stamp);
387+
self.ident_id += &format!("_{stamp}");
388388
}
389389
}
390390

@@ -432,7 +432,7 @@ impl fmt::Display for StructDeclarationC {
432432
/// identifiers unique.
433433
impl MakeUnique for UnionDeclarationC {
434434
fn make_unique(&mut self, stamp: usize) {
435-
self.ident_id += &format!("_{}", stamp);
435+
self.ident_id += &format!("_{stamp}");
436436
}
437437
}
438438

@@ -480,7 +480,7 @@ impl fmt::Display for UnionDeclarationC {
480480
/// FunctionPointerDeclarationC identifiers unique.
481481
impl MakeUnique for FunctionPointerDeclarationC {
482482
fn make_unique(&mut self, stamp: usize) {
483-
self.ident_id += &format!("_{}", stamp);
483+
self.ident_id += &format!("_{stamp}");
484484
}
485485
}
486486

@@ -517,7 +517,7 @@ impl fmt::Display for FunctionPointerDeclarationC {
517517
/// identifiers unique.
518518
impl MakeUnique for FunctionPrototypeC {
519519
fn make_unique(&mut self, stamp: usize) {
520-
self.ident_id += &format!("_{}", stamp);
520+
self.ident_id += &format!("_{stamp}");
521521
}
522522
}
523523

@@ -589,11 +589,11 @@ impl fmt::Display for ParameterListC {
589589
let mut display = String::new();
590590
for (i, p) in self.params.iter().enumerate() {
591591
match i {
592-
0 => display += &format!("{}", p),
593-
_ => display += &format!(",{}", p),
592+
0 => display += &format!("{p}"),
593+
_ => display += &format!(",{p}"),
594594
}
595595
}
596-
write!(f, "{}", display)
596+
write!(f, "{display}")
597597
}
598598
}
599599

@@ -614,17 +614,17 @@ impl fmt::Display for HeaderC {
614614
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
615615
let mut display = String::new();
616616
for decl in &self.def.decls {
617-
display += &format!("{}", decl);
617+
display += &format!("{decl}");
618618
}
619-
write!(f, "{}", display)
619+
write!(f, "{display}")
620620
}
621621
}
622622

623623
/// Use Display trait for Debug so that any failing property tests report
624624
/// generated C code rather than the data structures that contain it.
625625
impl fmt::Debug for HeaderC {
626626
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
627-
write!(f, "{}", self)
627+
write!(f, "{self}")
628628
}
629629
}
630630

bindgen-tests/tests/quickchecking/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn bindgen_prop(header: fuzzers::HeaderC) -> TestResult {
8181
match run_predicate_script(header) {
8282
Ok(o) => TestResult::from_bool(o.status.success()),
8383
Err(e) => {
84-
println!("{:?}", e);
84+
println!("{e:?}");
8585
TestResult::from_bool(false)
8686
}
8787
}

bindgen-tests/tests/tests.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ fn error_diff_mismatch(
4040
filename: &Path,
4141
) -> Result<(), Error> {
4242
println!("diff expected generated");
43-
println!("--- expected: {:?}", filename);
43+
println!("--- expected: {filename:?}");
4444
if let Some(header) = header {
45-
println!("+++ generated from: {:?}", header);
45+
println!("+++ generated from: {header:?}");
4646
}
4747

4848
show_diff(expected, actual);
@@ -153,9 +153,9 @@ fn compare_generated_header(
153153
} else if maj >= 9 {
154154
"9".to_owned()
155155
} else {
156-
format!("{}.{}", maj, min)
156+
format!("{maj}.{min}")
157157
};
158-
expectation.push(format!("libclang-{}", version_str));
158+
expectation.push(format!("libclang-{version_str}"));
159159
}
160160
}
161161
}
@@ -194,7 +194,7 @@ fn compare_generated_header(
194194
Ok(bindings) => format_code(bindings.to_string()).map_err(|err| {
195195
Error::new(
196196
ErrorKind::Other,
197-
format!("Cannot parse the generated bindings: {}", err),
197+
format!("Cannot parse the generated bindings: {err}"),
198198
)
199199
})?,
200200
Err(_) => "/* error generating bindings */\n".into(),
@@ -219,7 +219,7 @@ fn compare_generated_header(
219219
if let Err(e) =
220220
compare_generated_header(header, roundtrip_builder, false)
221221
{
222-
return Err(Error::new(ErrorKind::Other, format!("Checking CLI flags roundtrip errored! You probably need to fix Builder::command_line_flags. {}", e)));
222+
return Err(Error::new(ErrorKind::Other, format!("Checking CLI flags roundtrip errored! You probably need to fix Builder::command_line_flags. {e}")));
223223
}
224224
}
225225

@@ -703,7 +703,7 @@ fn build_flags_output_helper(builder: &bindgen::Builder) {
703703
.map(|x| format!("{}", shlex::try_quote(x).unwrap()))
704704
.collect();
705705
let flags_str = flags_quoted.join(" ");
706-
println!("{}", flags_str);
706+
println!("{flags_str}");
707707

708708
let (builder, _output, _verbose) =
709709
builder_from_flags(command_line_flags.into_iter()).unwrap();

bindgen/clang.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ impl fmt::Display for SourceLocation {
16361636
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16371637
let (file, line, col, _) = self.location();
16381638
if let Some(name) = file.name() {
1639-
write!(f, "{}:{}:{}", name, line, col)
1639+
write!(f, "{name}:{line}:{col}")
16401640
} else {
16411641
"builtin definitions".fmt(f)
16421642
}
@@ -1645,7 +1645,7 @@ impl fmt::Display for SourceLocation {
16451645

16461646
impl fmt::Debug for SourceLocation {
16471647
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1648-
write!(f, "{}", self)
1648+
write!(f, "{self}")
16491649
}
16501650
}
16511651

@@ -2126,15 +2126,15 @@ pub(crate) fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
21262126
);
21272127
}
21282128
if let Some(usr) = c.usr() {
2129-
print_indent(depth, format!(" {}usr = \"{}\"", prefix, usr));
2129+
print_indent(depth, format!(" {prefix}usr = \"{usr}\""));
21302130
}
21312131
if let Ok(num) = c.num_args() {
2132-
print_indent(depth, format!(" {}number-of-args = {}", prefix, num));
2132+
print_indent(depth, format!(" {prefix}number-of-args = {num}"));
21332133
}
21342134
if let Some(num) = c.num_template_args() {
21352135
print_indent(
21362136
depth,
2137-
format!(" {}number-of-template-args = {}", prefix, num),
2137+
format!(" {prefix}number-of-template-args = {num}"),
21382138
);
21392139
}
21402140

@@ -2143,7 +2143,7 @@ pub(crate) fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
21432143
Some(w) => w.to_string(),
21442144
None => "<unevaluable>".to_string(),
21452145
};
2146-
print_indent(depth, format!(" {}bit-width = {}", prefix, width));
2146+
print_indent(depth, format!(" {prefix}bit-width = {width}"));
21472147
}
21482148

21492149
if let Some(ty) = c.enum_type() {
@@ -2153,7 +2153,7 @@ pub(crate) fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
21532153
);
21542154
}
21552155
if let Some(val) = c.enum_val_signed() {
2156-
print_indent(depth, format!(" {}enum-val = {}", prefix, val));
2156+
print_indent(depth, format!(" {prefix}enum-val = {val}"));
21572157
}
21582158
if let Some(ty) = c.typedef_type() {
21592159
print_indent(
@@ -2231,16 +2231,12 @@ pub(crate) fn ast_dump(c: &Cursor, depth: isize) -> CXChildVisitResult {
22312231
print_indent(
22322232
depth,
22332233
format!(
2234-
" {}number-of-template-args = {}",
2235-
prefix, num_template_args
2234+
" {prefix}number-of-template-args = {num_template_args}"
22362235
),
22372236
);
22382237
}
22392238
if let Some(num) = ty.num_elements() {
2240-
print_indent(
2241-
depth,
2242-
format!(" {}number-of-elements = {}", prefix, num),
2243-
);
2239+
print_indent(depth, format!(" {prefix}number-of-elements = {num}"));
22442240
}
22452241
print_indent(
22462242
depth,

bindgen/codegen/bitfield_unit_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fn bitfield_unit_get_bit() {
3333
}
3434

3535
println!();
36-
println!("bits = {:?}", bits);
36+
println!("bits = {bits:?}");
3737
assert_eq!(
3838
bits,
3939
&[

bindgen/codegen/error.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ impl fmt::Display for Error {
3636
Error::UnsupportedAbi(abi) => {
3737
write!(
3838
f,
39-
"{} ABI is not supported by the configured Rust target.",
40-
abi
39+
"{abi} ABI is not supported by the configured Rust target."
4140
)
4241
}
4342
Error::InvalidPointerSize { ty_name, ty_size, ptr_size } => {
44-
write!(f, "The {} pointer type has size {} but the current target's pointer size is {}.", ty_name, ty_size, ptr_size)
43+
write!(f, "The {ty_name} pointer type has size {ty_size} but the current target's pointer size is {ptr_size}.")
4544
}
4645
}
4746
}

bindgen/codegen/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub(crate) mod attributes {
6868
let name: Cow<'_, str> = if MANGLE {
6969
name.into()
7070
} else {
71-
format!("\u{1}{}", name).into()
71+
format!("\u{1}{name}").into()
7272
};
7373

7474
quote! {
@@ -375,7 +375,7 @@ pub(crate) mod ast_ty {
375375
None => {
376376
unnamed_arguments += 1;
377377
let name =
378-
ctx.rust_ident(format!("arg{}", unnamed_arguments));
378+
ctx.rust_ident(format!("arg{unnamed_arguments}"));
379379
quote! { #name }
380380
}
381381
})

0 commit comments

Comments
 (0)