Skip to content

Commit 9c5e216

Browse files
authored
chore: fix new clippy warnings causing build errors (#428)
1 parent f4ec563 commit 9c5e216

File tree

22 files changed

+87
-82
lines changed

22 files changed

+87
-82
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ codegen-units = 8
147147
incremental = false
148148
debug = false
149149

150-
[profile.ephemeral-coverage]
151-
inherits = "ephemeral-build"
152-
debug = true
150+
# [profile.ephemeral-coverage]
151+
# inherits = "ephemeral-build"
152+
# debug = true
153153

154154
[profile.release-with-debug]
155155
inherits = "release"

benches/benchmarks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn script_benchmarks(criterion: &mut Criterion, filter: Option<Regex>) {
109109
}
110110

111111
for (group, tests) in grouped {
112-
println!("Running benchmarks for group: {}", group);
112+
println!("Running benchmarks for group: {group}");
113113
let mut benchmark_group = criterion.benchmark_group(group);
114114

115115
for t in tests {

crates/bevy_mod_scripting_core/src/asset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ mod tests {
431431
LoadState::NotLoaded => panic!("Asset not loaded"),
432432
LoadState::Loaded => {}
433433
LoadState::Failed(asset_load_error) => {
434-
panic!("Asset load failed: {:?}", asset_load_error)
434+
panic!("Asset load failed: {asset_load_error:?}")
435435
}
436436
_ => panic!("Unexpected load state"),
437437
}
@@ -532,7 +532,7 @@ mod tests {
532532
mut event_target: ResMut<EventTarget>| {
533533
println!("Reading asset events this frame");
534534
for event in reader.read() {
535-
println!("{:?}", event);
535+
println!("{event:?}");
536536
if matches!(
537537
(event_target.event, event),
538538
(AssetEvent::Added { .. }, AssetEvent::Added { .. })

crates/bevy_mod_scripting_core/src/bindings/function/namespace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Namespace {
5050
pub fn prefix(self) -> Cow<'static, str> {
5151
match self {
5252
Namespace::Global => Cow::Borrowed(""),
53-
Namespace::OnType(type_id) => Cow::Owned(format!("{:?}::", type_id)),
53+
Namespace::OnType(type_id) => Cow::Owned(format!("{type_id:?}::")),
5454
}
5555
}
5656

crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl ScriptFunctionRegistry {
463463
if i == 0 {
464464
self.get_function(namespace, name.clone())
465465
} else {
466-
let name: Cow<'static, str> = format!("{}-{i}", name).into();
466+
let name: Cow<'static, str> = format!("{name}-{i}").into();
467467
self.get_function(namespace, name)
468468
}
469469
})

crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl ReflectReferencePrinter {
9090

9191
if let Some(tail_type_id) = tail_type_id {
9292
let type_path = tail_type_id.display_with_world(world);
93-
pretty_path.push_str(&format!(" -> {}", type_path));
93+
pretty_path.push_str(&format!(" -> {type_path}"));
9494
}
9595
} else {
9696
Self::pretty_print_base(&self.reference.base, None, &mut pretty_path);
@@ -111,7 +111,7 @@ impl ReflectReferencePrinter {
111111
self.pretty_print_value_inner(r, &mut output);
112112
})
113113
.unwrap_or_else(|e| {
114-
output.push_str(&format!("<Error in printing: {}>", e));
114+
output.push_str(&format!("<Error in printing: {e}>"));
115115
});
116116
}
117117
None => {
@@ -131,12 +131,12 @@ impl ReflectReferencePrinter {
131131
};
132132

133133
let base_kind = match base.base_id {
134-
ReflectBase::Component(e, _) => format!("Component on entity {}", e),
134+
ReflectBase::Component(e, _) => format!("Component on entity {e}"),
135135
ReflectBase::Resource(_) => "Resource".to_owned(),
136-
ReflectBase::Owned(ref id) => format!("Allocation({})", id),
136+
ReflectBase::Owned(ref id) => format!("Allocation({id})"),
137137
};
138138

139-
out.push_str(&format!("{}({})", base_kind, type_path));
139+
out.push_str(&format!("{base_kind}({type_path})"));
140140
}
141141

142142
/// Pretty prints a value of an opaque type.
@@ -317,7 +317,7 @@ impl ReflectReferencePrinter {
317317
// for function_reflection from bevy or other feature gated things
318318
#[allow(unreachable_patterns)]
319319
_ => {
320-
output.push_str(&format!("{:?}", v));
320+
output.push_str(&format!("{v:?}"));
321321
}
322322
}
323323
}
@@ -414,7 +414,7 @@ impl DisplayWithWorld for ComponentId {
414414
.map(|info| info.name());
415415

416416
match component_name {
417-
Some(n) => format!("ComponentOrResource({})", n),
417+
Some(n) => format!("ComponentOrResource({n})"),
418418
None => "ComponentOrResource(<Unknown>)".to_owned(),
419419
}
420420
}
@@ -450,14 +450,14 @@ impl DisplayWithWorld for ReflectAccessId {
450450
if let Some(allocation) = allocator.get(&allocation_id) {
451451
let ptr = allocation.get_ptr();
452452
let val = unsafe { &*ptr };
453-
let o = format!("Allocation({:?})", val);
453+
let o = format!("Allocation({val:?})");
454454
unsafe { world.release_access(raid) };
455455
o
456456
} else {
457-
format!("Allocation({})", allocation_id)
457+
format!("Allocation({allocation_id})")
458458
}
459459
} else {
460-
format!("Allocation({})", allocation_id)
460+
format!("Allocation({allocation_id})")
461461
}
462462
}
463463
super::access_map::ReflectAccessKind::Global => "Global".to_owned(),
@@ -491,7 +491,7 @@ impl DisplayWithWorld for TypeId {
491491
}
492492

493493
fn display_without_world(&self) -> String {
494-
format!("{:?}", self)
494+
format!("{self:?}")
495495
}
496496
}
497497
#[profiling::all_functions]
@@ -687,15 +687,15 @@ mod test {
687687
let type_id = TypeId::of::<usize>();
688688
assert_eq!(type_id.display_with_world(world.clone()), "usize");
689689
assert_eq!(type_id.display_value_with_world(world.clone()), "usize");
690-
assert_eq!(type_id.display_without_world(), format!("{:?}", type_id));
690+
assert_eq!(type_id.display_without_world(), format!("{type_id:?}"));
691691

692692
let type_id = TypeId::of::<FakeType>();
693693
assert_eq!(type_id.display_with_world(world.clone()), "Unknown Type");
694694
assert_eq!(
695695
type_id.display_value_with_world(world.clone()),
696696
"Unknown Type"
697697
);
698-
assert_eq!(type_id.display_without_world(), format!("{:?}", type_id));
698+
assert_eq!(type_id.display_without_world(), format!("{type_id:?}"));
699699
}
700700

701701
#[test]
@@ -729,7 +729,7 @@ mod test {
729729
type_id,
730730
}
731731
.display_without_world(),
732-
format!("Allocation(0)({:?})", type_id)
732+
format!("Allocation(0)({type_id:?})")
733733
);
734734
}
735735

@@ -763,7 +763,7 @@ mod test {
763763

764764
assert_eq!(
765765
reflect_reference.display_without_world(),
766-
format!("<Reference to Allocation({id})({:?})>", type_id)
766+
format!("<Reference to Allocation({id})({type_id:?})>")
767767
);
768768
}
769769

crates/bevy_mod_scripting_core/src/bindings/schedule.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ mod tests {
307307
if let Some(system) = graph.get_system_at(node_id) {
308308
system.name().clone().to_string()
309309
} else if let Some(system_set) = graph.get_set_at(node_id) {
310-
format!("{:?}", system_set).to_string()
310+
format!("{system_set:?}").to_string()
311311
} else {
312312
// try schedule systems
313313
let mut default = format!("{node_id:?}").to_string();
@@ -352,10 +352,7 @@ mod tests {
352352
for &(exp_from, exp_to) in expected_edges {
353353
assert!(
354354
found_edges.contains(&(exp_from.to_owned(), exp_to.to_owned())),
355-
"Expected edge ({} -> {}) not found. Found edges: {:?}",
356-
exp_from,
357-
exp_to,
358-
found_edges
355+
"Expected edge ({exp_from} -> {exp_to}) not found. Found edges: {found_edges:?}"
359356
);
360357
}
361358

crates/bevy_mod_scripting_core/src/bindings/script_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl<P: IntoScriptPluginParams> System for DynamicScriptSystem<P> {
538538
reason = "WIP, to be dealt with in validate params better, but panic will still remain"
539539
)]
540540
if subset.contains(&raid) {
541-
panic!("Duplicate resource access in system: {:?}.", raid);
541+
panic!("Duplicate resource access in system: {raid:?}.");
542542
}
543543
subset.insert(raid);
544544
}

crates/bevy_mod_scripting_core/src/commands.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ mod test {
445445
.init_resource::<StaticScripts>()
446446
.insert_resource(CallbackSettings::<DummyPlugin> {
447447
callback_handler: |_, _, _, callback, c, _, _| {
448-
c.push_str(format!(" callback-ran-{}", callback).as_str());
448+
c.push_str(format!(" callback-ran-{callback}").as_str());
449449
Ok(ScriptValue::Unit)
450450
},
451451
})
@@ -479,7 +479,7 @@ mod test {
479479
assert_eq!(id, script.id);
480480
let found_context = script.context.lock();
481481

482-
assert_eq!(*context, *found_context, "{}", message);
482+
assert_eq!(*context, *found_context, "{message}");
483483
}
484484

485485
fn assert_response_events(
@@ -495,13 +495,12 @@ mod test {
495495
assert_eq!(
496496
responses.len(),
497497
expected.len(),
498-
"Incorrect amount of events received {}",
499-
context
498+
"Incorrect amount of events received {context}"
500499
);
501500
for (a, b) in responses.iter().zip(expected.iter()) {
502-
assert_eq!(a.label, b.label, "{}", context);
503-
assert_eq!(a.script, b.script, "{}", context);
504-
assert_eq!(a.response, b.response, "{}", context);
501+
assert_eq!(a.label, b.label, "{context}");
502+
assert_eq!(a.script, b.script, "{context}");
503+
assert_eq!(a.response, b.response, "{context}");
505504
}
506505
}
507506

crates/bevy_mod_scripting_core/src/event.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ mod test {
301301
'|', '\\', ':', ';', '"', '\'', '<', '>', ',', '.', '?', '/', '`', '~',
302302
];
303303
bad_chars.iter().for_each(|char| {
304-
assert_eq!(super::CallbackLabel::new(&format!("bad{}", char)), None);
304+
assert_eq!(super::CallbackLabel::new(&format!("bad{char}")), None);
305305
});
306306
}
307307

@@ -313,7 +313,7 @@ mod test {
313313
',', '.', '?', '/', '`', '~',
314314
];
315315
bad_chars.iter().for_each(|char| {
316-
assert_eq!(super::CallbackLabel::new(&format!("{}bad", char)), None);
316+
assert_eq!(super::CallbackLabel::new(&format!("{char}bad")), None);
317317
});
318318
}
319319

crates/bevy_system_reflection/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl ReflectSystemSet {
148148
pub fn from_set(set: &dyn SystemSet, node_id: NodeId) -> Self {
149149
ReflectSystemSet {
150150
node_id: ReflectNodeId(node_id),
151-
debug: format!("{:?}", set),
151+
debug: format!("{set:?}"),
152152
type_id: set.system_type(),
153153
}
154154
}

crates/lad_backends/mdbook_lad_preprocessor/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl LADPreprocessor {
6060
.unwrap_or_default()
6161
.with_extension("");
6262

63-
log::debug!("Parent path: {:?}", parent_path);
63+
log::debug!("Parent path: {parent_path:?}");
6464

6565
let new_chapter = Section::new(
6666
parent_path,
@@ -91,7 +91,7 @@ impl Preprocessor for LADPreprocessor {
9191
let mut errors = Vec::new();
9292
let options = Options::from(context);
9393

94-
log::debug!("Options: {:?}", options);
94+
log::debug!("Options: {options:?}");
9595
OPTIONS
9696
.set(options)
9797
.map_err(|_| mdbook::errors::Error::msg("could not initialize options"))?;
@@ -169,7 +169,7 @@ impl Preprocessor for LADPreprocessor {
169169
if !errors.is_empty() {
170170
// return on first error
171171
for error in errors {
172-
log::error!("{}", error);
172+
log::error!("{error}");
173173
Err(error)?;
174174
}
175175
}

crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) fn markdown_substring(markdown: &str, length: usize) -> String {
3434

3535
let trimmed = markdown[..end].to_string();
3636
// append ...
37-
format!("{}...", trimmed)
37+
format!("{trimmed}...")
3838
}
3939

4040
/// Escapes Markdown reserved characters in the given text.
@@ -208,7 +208,7 @@ impl IntoMarkdown for Markdown {
208208
Markdown::CodeBlock { language, code } => {
209209
// Do not escape code blocks
210210
let lang = language.as_deref().unwrap_or("");
211-
builder.append(&format!("```{}\n{}\n```", lang, code));
211+
builder.append(&format!("```{lang}\n{code}\n```"));
212212
}
213213
Markdown::List { ordered, items } => {
214214
items.iter().enumerate().for_each(|(i, item)| {
@@ -233,7 +233,7 @@ impl IntoMarkdown for Markdown {
233233
Markdown::Quote(text) => {
234234
let quote_output = text
235235
.lines()
236-
.map(|line| format!("> {}", line))
236+
.map(|line| format!("> {line}"))
237237
.collect::<Vec<String>>()
238238
.join("\n");
239239
builder.append(&quote_output);
@@ -783,8 +783,7 @@ mod tests {
783783
assert_eq!(
784784
expected,
785785
markdown_substring(input, len),
786-
"Failed for input: {}",
787-
input
786+
"Failed for input: {input}"
788787
);
789788
}
790789
}

crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ fn build_lad_function_argument_row(
702702
.name
703703
.as_ref()
704704
.cloned()
705-
.unwrap_or_else(|| Cow::Owned(format!("arg{}", idx)));
705+
.unwrap_or_else(|| Cow::Owned(format!("arg{idx}")));
706706

707707
builder.row(markdown_vec![
708708
Markdown::new_paragraph(arg_name).bold(),

crates/lad_backends/mdbook_lad_preprocessor/tests/book_integration_tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ fn test_on_example_ladfile() {
8383
let book_file = book_dir.join(relative_path);
8484
assert!(
8585
book_files.contains(&book_file),
86-
"File not found: {:?}",
87-
book_file
86+
"File not found: {book_file:?}"
8887
);
8988
let expected_content =
9089
std::fs::read_to_string(&expected_file).expect("failed to read file");

crates/ladfile_builder/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ mod test {
11071107
.join("ladfile")
11081108
.join("test_assets");
11091109

1110-
println!("Blessing test file at {:?}", path_to_test_assets);
1110+
println!("Blessing test file at {path_to_test_assets:?}");
11111111
std::fs::write(path_to_test_assets.join("test.lad.json"), &serialized).unwrap();
11121112
panic!("Blessed test file, please rerun the test");
11131113
}

crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl FromLua for LuaScriptValue {
5454
Value::String(s) => ScriptValue::String(s.to_str()?.to_owned().into()),
5555
Value::Function(f) => ScriptValue::Function(
5656
(move |_context: FunctionCallContext, args: VecDeque<ScriptValue>| {
57-
println!("Lua function called with args: {:?}", args);
57+
println!("Lua function called with args: {args:?}");
5858
match f.call::<LuaScriptValue>(
5959
args.into_iter()
6060
.map(LuaScriptValue)

crates/languages/bevy_mod_scripting_rhai/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Default for RhaiScriptingPlugin {
123123
for (key, function) in script_function_registry.iter_all() {
124124
let name = key.name.clone();
125125
if ReservedKeyword::is_reserved_keyword(&name) {
126-
let new_name = format!("{}_", name);
126+
let new_name = format!("{name}_");
127127
let mut new_function = function.clone();
128128
let new_info =
129129
function.info.deref().clone().with_name(new_name.clone());

crates/testing_crates/script_integration_test_harness/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ pub fn make_test_rhai_plugin() -> bevy_mod_scripting_rhai::RhaiScriptingPlugin {
143143
runtime.set_max_call_levels(1000);
144144
runtime.register_fn("assert", |a: Dynamic, b: &str| {
145145
if !a.is::<bool>() {
146-
panic!("Expected a boolean value, but got {:?}", a);
146+
panic!("Expected a boolean value, but got {a:?}");
147147
}
148148
if !a.as_bool().unwrap() {
149-
panic!("Assertion failed. {}", b);
149+
panic!("Assertion failed. {b}");
150150
}
151151
});
152152

153153
runtime.register_fn("assert", |a: Dynamic| {
154154
if !a.is::<bool>() {
155-
panic!("Expected a boolean value, but got {:?}", a);
155+
panic!("Expected a boolean value, but got {a:?}");
156156
}
157157
if !a.as_bool().unwrap() {
158158
panic!("Assertion failed");

0 commit comments

Comments
 (0)