Skip to content

chore: fix new clippy warnings causing build errors #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ codegen-units = 8
incremental = false
debug = false

[profile.ephemeral-coverage]
inherits = "ephemeral-build"
debug = true
# [profile.ephemeral-coverage]
# inherits = "ephemeral-build"
# debug = true

[profile.release-with-debug]
inherits = "release"
Expand Down
2 changes: 1 addition & 1 deletion benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn script_benchmarks(criterion: &mut Criterion, filter: Option<Regex>) {
}

for (group, tests) in grouped {
println!("Running benchmarks for group: {}", group);
println!("Running benchmarks for group: {group}");
let mut benchmark_group = criterion.benchmark_group(group);

for t in tests {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_mod_scripting_core/src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ mod tests {
LoadState::NotLoaded => panic!("Asset not loaded"),
LoadState::Loaded => {}
LoadState::Failed(asset_load_error) => {
panic!("Asset load failed: {:?}", asset_load_error)
panic!("Asset load failed: {asset_load_error:?}")
}
_ => panic!("Unexpected load state"),
}
Expand Down Expand Up @@ -532,7 +532,7 @@ mod tests {
mut event_target: ResMut<EventTarget>| {
println!("Reading asset events this frame");
for event in reader.read() {
println!("{:?}", event);
println!("{event:?}");
if matches!(
(event_target.event, event),
(AssetEvent::Added { .. }, AssetEvent::Added { .. })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Namespace {
pub fn prefix(self) -> Cow<'static, str> {
match self {
Namespace::Global => Cow::Borrowed(""),
Namespace::OnType(type_id) => Cow::Owned(format!("{:?}::", type_id)),
Namespace::OnType(type_id) => Cow::Owned(format!("{type_id:?}::")),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ impl ScriptFunctionRegistry {
if i == 0 {
self.get_function(namespace, name.clone())
} else {
let name: Cow<'static, str> = format!("{}-{i}", name).into();
let name: Cow<'static, str> = format!("{name}-{i}").into();
self.get_function(namespace, name)
}
})
Expand Down
30 changes: 15 additions & 15 deletions crates/bevy_mod_scripting_core/src/bindings/pretty_print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl ReflectReferencePrinter {

if let Some(tail_type_id) = tail_type_id {
let type_path = tail_type_id.display_with_world(world);
pretty_path.push_str(&format!(" -> {}", type_path));
pretty_path.push_str(&format!(" -> {type_path}"));
}
} else {
Self::pretty_print_base(&self.reference.base, None, &mut pretty_path);
Expand All @@ -111,7 +111,7 @@ impl ReflectReferencePrinter {
self.pretty_print_value_inner(r, &mut output);
})
.unwrap_or_else(|e| {
output.push_str(&format!("<Error in printing: {}>", e));
output.push_str(&format!("<Error in printing: {e}>"));
});
}
None => {
Expand All @@ -131,12 +131,12 @@ impl ReflectReferencePrinter {
};

let base_kind = match base.base_id {
ReflectBase::Component(e, _) => format!("Component on entity {}", e),
ReflectBase::Component(e, _) => format!("Component on entity {e}"),
ReflectBase::Resource(_) => "Resource".to_owned(),
ReflectBase::Owned(ref id) => format!("Allocation({})", id),
ReflectBase::Owned(ref id) => format!("Allocation({id})"),
};

out.push_str(&format!("{}({})", base_kind, type_path));
out.push_str(&format!("{base_kind}({type_path})"));
}

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

match component_name {
Some(n) => format!("ComponentOrResource({})", n),
Some(n) => format!("ComponentOrResource({n})"),
None => "ComponentOrResource(<Unknown>)".to_owned(),
}
}
Expand Down Expand Up @@ -450,14 +450,14 @@ impl DisplayWithWorld for ReflectAccessId {
if let Some(allocation) = allocator.get(&allocation_id) {
let ptr = allocation.get_ptr();
let val = unsafe { &*ptr };
let o = format!("Allocation({:?})", val);
let o = format!("Allocation({val:?})");
unsafe { world.release_access(raid) };
o
} else {
format!("Allocation({})", allocation_id)
format!("Allocation({allocation_id})")
}
} else {
format!("Allocation({})", allocation_id)
format!("Allocation({allocation_id})")
}
}
super::access_map::ReflectAccessKind::Global => "Global".to_owned(),
Expand Down Expand Up @@ -491,7 +491,7 @@ impl DisplayWithWorld for TypeId {
}

fn display_without_world(&self) -> String {
format!("{:?}", self)
format!("{self:?}")
}
}
#[profiling::all_functions]
Expand Down Expand Up @@ -687,15 +687,15 @@ mod test {
let type_id = TypeId::of::<usize>();
assert_eq!(type_id.display_with_world(world.clone()), "usize");
assert_eq!(type_id.display_value_with_world(world.clone()), "usize");
assert_eq!(type_id.display_without_world(), format!("{:?}", type_id));
assert_eq!(type_id.display_without_world(), format!("{type_id:?}"));

let type_id = TypeId::of::<FakeType>();
assert_eq!(type_id.display_with_world(world.clone()), "Unknown Type");
assert_eq!(
type_id.display_value_with_world(world.clone()),
"Unknown Type"
);
assert_eq!(type_id.display_without_world(), format!("{:?}", type_id));
assert_eq!(type_id.display_without_world(), format!("{type_id:?}"));
}

#[test]
Expand Down Expand Up @@ -729,7 +729,7 @@ mod test {
type_id,
}
.display_without_world(),
format!("Allocation(0)({:?})", type_id)
format!("Allocation(0)({type_id:?})")
);
}

Expand Down Expand Up @@ -763,7 +763,7 @@ mod test {

assert_eq!(
reflect_reference.display_without_world(),
format!("<Reference to Allocation({id})({:?})>", type_id)
format!("<Reference to Allocation({id})({type_id:?})>")
);
}

Expand Down
7 changes: 2 additions & 5 deletions crates/bevy_mod_scripting_core/src/bindings/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ mod tests {
if let Some(system) = graph.get_system_at(node_id) {
system.name().clone().to_string()
} else if let Some(system_set) = graph.get_set_at(node_id) {
format!("{:?}", system_set).to_string()
format!("{system_set:?}").to_string()
} else {
// try schedule systems
let mut default = format!("{node_id:?}").to_string();
Expand Down Expand Up @@ -352,10 +352,7 @@ mod tests {
for &(exp_from, exp_to) in expected_edges {
assert!(
found_edges.contains(&(exp_from.to_owned(), exp_to.to_owned())),
"Expected edge ({} -> {}) not found. Found edges: {:?}",
exp_from,
exp_to,
found_edges
"Expected edge ({exp_from} -> {exp_to}) not found. Found edges: {found_edges:?}"
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl<P: IntoScriptPluginParams> System for DynamicScriptSystem<P> {
reason = "WIP, to be dealt with in validate params better, but panic will still remain"
)]
if subset.contains(&raid) {
panic!("Duplicate resource access in system: {:?}.", raid);
panic!("Duplicate resource access in system: {raid:?}.");
}
subset.insert(raid);
}
Expand Down
13 changes: 6 additions & 7 deletions crates/bevy_mod_scripting_core/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ mod test {
.init_resource::<StaticScripts>()
.insert_resource(CallbackSettings::<DummyPlugin> {
callback_handler: |_, _, _, callback, c, _, _| {
c.push_str(format!(" callback-ran-{}", callback).as_str());
c.push_str(format!(" callback-ran-{callback}").as_str());
Ok(ScriptValue::Unit)
},
})
Expand Down Expand Up @@ -479,7 +479,7 @@ mod test {
assert_eq!(id, script.id);
let found_context = script.context.lock();

assert_eq!(*context, *found_context, "{}", message);
assert_eq!(*context, *found_context, "{message}");
}

fn assert_response_events(
Expand All @@ -495,13 +495,12 @@ mod test {
assert_eq!(
responses.len(),
expected.len(),
"Incorrect amount of events received {}",
context
"Incorrect amount of events received {context}"
);
for (a, b) in responses.iter().zip(expected.iter()) {
assert_eq!(a.label, b.label, "{}", context);
assert_eq!(a.script, b.script, "{}", context);
assert_eq!(a.response, b.response, "{}", context);
assert_eq!(a.label, b.label, "{context}");
assert_eq!(a.script, b.script, "{context}");
assert_eq!(a.response, b.response, "{context}");
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_mod_scripting_core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ mod test {
'|', '\\', ':', ';', '"', '\'', '<', '>', ',', '.', '?', '/', '`', '~',
];
bad_chars.iter().for_each(|char| {
assert_eq!(super::CallbackLabel::new(&format!("bad{}", char)), None);
assert_eq!(super::CallbackLabel::new(&format!("bad{char}")), None);
});
}

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

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_system_reflection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl ReflectSystemSet {
pub fn from_set(set: &dyn SystemSet, node_id: NodeId) -> Self {
ReflectSystemSet {
node_id: ReflectNodeId(node_id),
debug: format!("{:?}", set),
debug: format!("{set:?}"),
type_id: set.system_type(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/lad_backends/mdbook_lad_preprocessor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl LADPreprocessor {
.unwrap_or_default()
.with_extension("");

log::debug!("Parent path: {:?}", parent_path);
log::debug!("Parent path: {parent_path:?}");

let new_chapter = Section::new(
parent_path,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Preprocessor for LADPreprocessor {
let mut errors = Vec::new();
let options = Options::from(context);

log::debug!("Options: {:?}", options);
log::debug!("Options: {options:?}");
OPTIONS
.set(options)
.map_err(|_| mdbook::errors::Error::msg("could not initialize options"))?;
Expand Down Expand Up @@ -169,7 +169,7 @@ impl Preprocessor for LADPreprocessor {
if !errors.is_empty() {
// return on first error
for error in errors {
log::error!("{}", error);
log::error!("{error}");
Err(error)?;
}
}
Expand Down
9 changes: 4 additions & 5 deletions crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) fn markdown_substring(markdown: &str, length: usize) -> String {

let trimmed = markdown[..end].to_string();
// append ...
format!("{}...", trimmed)
format!("{trimmed}...")
}

/// Escapes Markdown reserved characters in the given text.
Expand Down Expand Up @@ -208,7 +208,7 @@ impl IntoMarkdown for Markdown {
Markdown::CodeBlock { language, code } => {
// Do not escape code blocks
let lang = language.as_deref().unwrap_or("");
builder.append(&format!("```{}\n{}\n```", lang, code));
builder.append(&format!("```{lang}\n{code}\n```"));
}
Markdown::List { ordered, items } => {
items.iter().enumerate().for_each(|(i, item)| {
Expand All @@ -233,7 +233,7 @@ impl IntoMarkdown for Markdown {
Markdown::Quote(text) => {
let quote_output = text
.lines()
.map(|line| format!("> {}", line))
.map(|line| format!("> {line}"))
.collect::<Vec<String>>()
.join("\n");
builder.append(&quote_output);
Expand Down Expand Up @@ -783,8 +783,7 @@ mod tests {
assert_eq!(
expected,
markdown_substring(input, len),
"Failed for input: {}",
input
"Failed for input: {input}"
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ fn build_lad_function_argument_row(
.name
.as_ref()
.cloned()
.unwrap_or_else(|| Cow::Owned(format!("arg{}", idx)));
.unwrap_or_else(|| Cow::Owned(format!("arg{idx}")));

builder.row(markdown_vec![
Markdown::new_paragraph(arg_name).bold(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ fn test_on_example_ladfile() {
let book_file = book_dir.join(relative_path);
assert!(
book_files.contains(&book_file),
"File not found: {:?}",
book_file
"File not found: {book_file:?}"
);
let expected_content =
std::fs::read_to_string(&expected_file).expect("failed to read file");
Expand Down
2 changes: 1 addition & 1 deletion crates/ladfile_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ mod test {
.join("ladfile")
.join("test_assets");

println!("Blessing test file at {:?}", path_to_test_assets);
println!("Blessing test file at {path_to_test_assets:?}");
std::fs::write(path_to_test_assets.join("test.lad.json"), &serialized).unwrap();
panic!("Blessed test file, please rerun the test");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl FromLua for LuaScriptValue {
Value::String(s) => ScriptValue::String(s.to_str()?.to_owned().into()),
Value::Function(f) => ScriptValue::Function(
(move |_context: FunctionCallContext, args: VecDeque<ScriptValue>| {
println!("Lua function called with args: {:?}", args);
println!("Lua function called with args: {args:?}");
match f.call::<LuaScriptValue>(
args.into_iter()
.map(LuaScriptValue)
Expand Down
2 changes: 1 addition & 1 deletion crates/languages/bevy_mod_scripting_rhai/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl Default for RhaiScriptingPlugin {
for (key, function) in script_function_registry.iter_all() {
let name = key.name.clone();
if ReservedKeyword::is_reserved_keyword(&name) {
let new_name = format!("{}_", name);
let new_name = format!("{name}_");
let mut new_function = function.clone();
let new_info =
function.info.deref().clone().with_name(new_name.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ pub fn make_test_rhai_plugin() -> bevy_mod_scripting_rhai::RhaiScriptingPlugin {
runtime.set_max_call_levels(1000);
runtime.register_fn("assert", |a: Dynamic, b: &str| {
if !a.is::<bool>() {
panic!("Expected a boolean value, but got {:?}", a);
panic!("Expected a boolean value, but got {a:?}");
}
if !a.as_bool().unwrap() {
panic!("Assertion failed. {}", b);
panic!("Assertion failed. {b}");
}
});

runtime.register_fn("assert", |a: Dynamic| {
if !a.is::<bool>() {
panic!("Expected a boolean value, but got {:?}", a);
panic!("Expected a boolean value, but got {a:?}");
}
if !a.as_bool().unwrap() {
panic!("Assertion failed");
Expand Down
Loading
Loading