Skip to content

Commit 62cd271

Browse files
committed
Clippy fixes related to inline strings in println!, write!, format! etc.
1 parent aeac343 commit 62cd271

File tree

8 files changed

+14
-21
lines changed

8 files changed

+14
-21
lines changed

godot-core/src/builtin/arrays.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,7 @@ impl Array {
288288
let len = self.len();
289289
assert!(
290290
index <= len,
291-
"Array insertion index {} is out of bounds: length is {}",
292-
index,
293-
len
291+
"Array insertion index {index} is out of bounds: length is {len}",
294292
);
295293
self.as_inner().insert(to_i64(index), value);
296294
}
@@ -358,9 +356,7 @@ impl Array {
358356
let len = self.len();
359357
assert!(
360358
index < len,
361-
"Array index {} is out of bounds: length is {}",
362-
index,
363-
len
359+
"Array index {index} is out of bounds: length is {len}",
364360
);
365361
}
366362

godot-core/src/builtin/variant/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,14 @@ impl PartialEq for Variant {
200200
impl fmt::Display for Variant {
201201
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
202202
let s = self.stringify();
203-
write!(f, "{}", s)
203+
write!(f, "{s}")
204204
}
205205
}
206206

207207
impl fmt::Debug for Variant {
208208
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209209
// TODO include variant type name
210210
let s = self.stringify();
211-
write!(f, "Variant({})", s)
211+
write!(f, "Variant({s})")
212212
}
213213
}

godot-core/src/init/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl InitLevel {
201201
sys::GDEXTENSION_INITIALIZATION_SCENE => Self::Scene,
202202
sys::GDEXTENSION_INITIALIZATION_EDITOR => Self::Editor,
203203
_ => {
204-
eprintln!("WARNING: unknown initialization level {}", level);
204+
eprintln!("WARNING: unknown initialization level {level}");
205205
Self::Scene
206206
}
207207
}

godot-core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ pub mod private {
7878

7979
pub fn print_panic(err: Box<dyn std::any::Any + Send>) {
8080
if let Some(s) = err.downcast_ref::<&'static str>() {
81-
log::godot_error!("rust-panic: {}", s);
81+
log::godot_error!("rust-panic: {s}");
8282
} else if let Some(s) = err.downcast_ref::<String>() {
83-
log::godot_error!("rust-panic: {}", s);
83+
log::godot_error!("rust-panic: {s}");
8484
} else {
8585
log::godot_error!("rust-panic of type ID {:?}", err.type_id());
8686
}

godot-ffi/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323

2424
fn run_bindgen(out_file: &Path) {
2525
let header_path = "../godot-codegen/input/gdextension_interface.h";
26-
println!("cargo:rerun-if-changed={}", header_path);
26+
println!("cargo:rerun-if-changed={header_path}");
2727

2828
let builder = bindgen::Builder::default()
2929
.header(header_path)
@@ -92,7 +92,7 @@ fn apple_include_path() -> Result<String, std::io::Error> {
9292
.trim_end();
9393

9494
let suffix = "usr/include";
95-
let directory = format!("{}/{}", prefix, suffix);
95+
let directory = format!("{prefix}/{suffix}");
9696

9797
Ok(directory)
9898
}

godot-macros/src/derive_godot_class.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,12 @@ impl ExportedField {
255255
Ok(value)
256256
} else {
257257
bail(
258-
format!(
259-
"#[export] attribute {} with a non-literal variant_type",
260-
key
261-
),
258+
format!("#[export] attribute {key} with a non-literal variant_type",),
262259
attr,
263260
)?
264261
}
265262
} else {
266-
bail(format!("#[export] attribute without a {}", key), attr)
263+
bail(format!("#[export] attribute without a {key}"), attr)
267264
}
268265
}
269266
}

godot-macros/src/godot_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn transform_trait_impl(original_impl: Impl) -> Result<TokenStream, Error> {
270270
// Unknown methods which are declared inside trait impl are not supported (possibly compiler catches those first anyway)
271271
other_name => {
272272
return bail(
273-
format!("Unsupported GodotExt method: {}", other_name),
273+
format!("Unsupported GodotExt method: {other_name}"),
274274
&method.name,
275275
)
276276
}

godot-macros/src/itest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub fn transform(input: TokenStream) -> Result<TokenStream, Error> {
3030
}
3131

3232
let test_name = &func.name;
33-
let init_msg = format!(" -- {}", test_name);
34-
let error_msg = format!(" !! Test {} failed", test_name);
33+
let init_msg = format!(" -- {test_name}");
34+
let error_msg = format!(" !! Test {test_name} failed");
3535
let body = &func.body;
3636

3737
Ok(quote! {

0 commit comments

Comments
 (0)