Skip to content

Commit 0d2cdb4

Browse files
committed
Fix beta clippy lints (#7154)
# Objective - When I run `cargo run -p ci` for my pr locally using latest beta toolchain, the ci failed due to [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) and [needless_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes) lints ## Solution - Fix lints according to clippy suggestions.
1 parent bb79903 commit 0d2cdb4

File tree

22 files changed

+66
-140
lines changed

22 files changed

+66
-140
lines changed

crates/bevy_app/src/app.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,7 @@ impl App {
872872
match self.add_boxed_plugin(Box::new(plugin)) {
873873
Ok(app) => app,
874874
Err(AppError::DuplicatePlugin { plugin_name }) => panic!(
875-
"Error adding plugin {}: : plugin was already added in application",
876-
plugin_name
875+
"Error adding plugin {plugin_name}: : plugin was already added in application"
877876
),
878877
}
879878
}

crates/bevy_asset/src/reflect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ impl ReflectAsset {
9494
}
9595

9696
/// Equivalent of [`Assets::add`]
97-
pub fn add<'w>(&self, world: &'w mut World, value: &dyn Reflect) -> HandleUntyped {
97+
pub fn add(&self, world: &mut World, value: &dyn Reflect) -> HandleUntyped {
9898
(self.add)(world, value)
9999
}
100100
/// Equivalent of [`Assets::set`]
101-
pub fn set<'w>(
101+
pub fn set(
102102
&self,
103-
world: &'w mut World,
103+
world: &mut World,
104104
handle: HandleUntyped,
105105
value: &dyn Reflect,
106106
) -> HandleUntyped {

crates/bevy_ecs/macros/src/component.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ fn parse_component_attr(ast: &DeriveInput) -> Result<Attrs> {
8686
return Err(Error::new_spanned(
8787
m.lit,
8888
format!(
89-
"Invalid storage type `{}`, expected '{}' or '{}'.",
90-
s, TABLE, SPARSE_SET
89+
"Invalid storage type `{s}`, expected '{TABLE}' or '{SPARSE_SET}'.",
9190
),
9291
))
9392
}

crates/bevy_ecs/macros/src/fetch.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
5252
fetch_struct_attributes.is_mutable = true;
5353
} else {
5454
panic!(
55-
"The `{}` attribute is expected to have no value or arguments",
56-
MUTABLE_ATTRIBUTE_NAME
55+
"The `{MUTABLE_ATTRIBUTE_NAME}` attribute is expected to have no value or arguments",
5756
);
5857
}
5958
} else if ident == DERIVE_ATTRIBUTE_NAME {
@@ -63,8 +62,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
6362
.extend(meta_list.nested.iter().cloned());
6463
} else {
6564
panic!(
66-
"Expected a structured list within the `{}` attribute",
67-
DERIVE_ATTRIBUTE_NAME
65+
"Expected a structured list within the `{DERIVE_ATTRIBUTE_NAME}` attribute",
6866
);
6967
}
7068
} else {

crates/bevy_ecs/src/bundle.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,7 @@ unsafe fn initialize_bundle(
731731
deduped.dedup();
732732
assert!(
733733
deduped.len() == component_ids.len(),
734-
"Bundle {} has duplicate components",
735-
bundle_type_name
734+
"Bundle {bundle_type_name} has duplicate components",
736735
);
737736

738737
BundleInfo { id, component_ids }

crates/bevy_ecs/src/schedule/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ impl Schedule {
224224
// of the game. Closures inherit generic parameters from their enclosing function.
225225
#[cold]
226226
fn stage_not_found(stage_label: &dyn Debug) -> ! {
227-
panic!(
228-
"Stage '{:?}' does not exist or is not a SystemStage",
229-
stage_label
230-
)
227+
panic!("Stage '{stage_label:?}' does not exist or is not a SystemStage",)
231228
}
232229

233230
let label = stage_label.as_label();

crates/bevy_ecs/src/schedule/stage.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,9 @@ impl SystemStage {
287287
.then(|| descriptor.system.name())
288288
{
289289
panic!(
290-
"The system {} has a run criteria, but its `SystemSet` also has a run \
290+
"The system {name} has a run criteria, but its `SystemSet` also has a run \
291291
criteria. This is not supported. Consider moving the system into a \
292-
different `SystemSet` or calling `add_system()` instead.",
293-
name
292+
different `SystemSet` or calling `add_system()` instead."
294293
)
295294
}
296295
}
@@ -459,8 +458,7 @@ impl SystemStage {
459458
writeln!(message, " - {}", nodes[*index].name()).unwrap();
460459
writeln!(
461460
message,
462-
" wants to be after (because of labels: {:?})",
463-
labels,
461+
" wants to be after (because of labels: {labels:?})",
464462
)
465463
.unwrap();
466464
}
@@ -565,10 +563,7 @@ impl SystemStage {
565563
if let RunCriteriaInner::Piped { input: parent, .. } = &mut criteria.inner {
566564
let label = &criteria.after[0];
567565
*parent = *labels.get(label).unwrap_or_else(|| {
568-
panic!(
569-
"Couldn't find run criteria labelled {:?} to pipe from.",
570-
label
571-
)
566+
panic!("Couldn't find run criteria labelled {label:?} to pipe from.",)
572567
});
573568
}
574569
}

crates/bevy_ecs/src/system/commands/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ impl<'w, 's> Commands<'w, 's> {
282282
pub fn entity<'a>(&'a mut self, entity: Entity) -> EntityCommands<'w, 's, 'a> {
283283
self.get_entity(entity).unwrap_or_else(|| {
284284
panic!(
285-
"Attempting to create an EntityCommands for entity {:?}, which doesn't exist.",
286-
entity
285+
"Attempting to create an EntityCommands for entity {entity:?}, which doesn't exist.",
287286
)
288287
})
289288
}

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,7 @@ fn assert_component_access_compatibility(
250250
.map(|component_id| world.components.get_info(component_id).unwrap().name())
251251
.collect::<Vec<&str>>();
252252
let accesses = conflicting_components.join(", ");
253-
panic!("error[B0001]: Query<{}, {}> in system {} accesses component(s) {} in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`.",
254-
query_type, filter_type, system_name, accesses);
253+
panic!("error[B0001]: Query<{query_type}, {filter_type}> in system {system_name} accesses component(s) {accesses} in a way that conflicts with a previous system parameter. Consider using `Without<T>` to create disjoint Queries or merging conflicting Queries into a `ParamSet`.");
255254
}
256255

257256
/// A collection of potentially conflicting [`SystemParam`]s allowed by disjoint access.

crates/bevy_input/src/gamepad.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,7 @@ mod tests {
12561256
let actual = settings.filter(new_value, old_value);
12571257
assert_eq!(
12581258
expected, actual,
1259-
"Testing filtering for {:?} with new_value = {:?}, old_value = {:?}",
1260-
settings, new_value, old_value
1259+
"Testing filtering for {settings:?} with new_value = {new_value:?}, old_value = {old_value:?}",
12611260
);
12621261
}
12631262

@@ -1312,8 +1311,7 @@ mod tests {
13121311
let actual = settings.filter(new_value, old_value);
13131312
assert_eq!(
13141313
expected, actual,
1315-
"Testing filtering for {:?} with new_value = {:?}, old_value = {:?}",
1316-
settings, new_value, old_value
1314+
"Testing filtering for {settings:?} with new_value = {new_value:?}, old_value = {old_value:?}",
13171315
);
13181316
}
13191317

@@ -1398,8 +1396,7 @@ mod tests {
13981396

13991397
assert_eq!(
14001398
expected, actual,
1401-
"testing ButtonSettings::is_pressed() for value: {}",
1402-
value
1399+
"testing ButtonSettings::is_pressed() for value: {value}",
14031400
);
14041401
}
14051402
}
@@ -1424,8 +1421,7 @@ mod tests {
14241421

14251422
assert_eq!(
14261423
expected, actual,
1427-
"testing ButtonSettings::is_released() for value: {}",
1428-
value
1424+
"testing ButtonSettings::is_released() for value: {value}",
14291425
);
14301426
}
14311427
}
@@ -1450,8 +1446,7 @@ mod tests {
14501446
}
14511447
Err(_) => {
14521448
panic!(
1453-
"ButtonSettings::new({}, {}) should be valid ",
1454-
press_threshold, release_threshold
1449+
"ButtonSettings::new({press_threshold}, {release_threshold}) should be valid"
14551450
);
14561451
}
14571452
}
@@ -1476,8 +1471,7 @@ mod tests {
14761471
match bs {
14771472
Ok(_) => {
14781473
panic!(
1479-
"ButtonSettings::new({}, {}) should be invalid",
1480-
press_threshold, release_threshold
1474+
"ButtonSettings::new({press_threshold}, {release_threshold}) should be invalid"
14811475
);
14821476
}
14831477
Err(err_code) => match err_code {

crates/bevy_macro_utils/src/attrs.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ pub fn get_lit_str(attr_name: Symbol, lit: &syn::Lit) -> syn::Result<&syn::LitSt
2424
} else {
2525
Err(syn::Error::new_spanned(
2626
lit,
27-
format!(
28-
"expected {} attribute to be a string: `{} = \"...\"`",
29-
attr_name, attr_name
30-
),
27+
format!("expected {attr_name} attribute to be a string: `{attr_name} = \"...\"`"),
3128
))
3229
}
3330
}
@@ -38,10 +35,7 @@ pub fn get_lit_bool(attr_name: Symbol, lit: &syn::Lit) -> syn::Result<bool> {
3835
} else {
3936
Err(syn::Error::new_spanned(
4037
lit,
41-
format!(
42-
"expected {} attribute to be a bool value, `true` or `false`: `{} = ...`",
43-
attr_name, attr_name
44-
),
38+
format!("expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`"),
4539
))
4640
}
4741
}

crates/bevy_pbr/src/render/light.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ pub fn prepare_lights(
11901190
.spawn((
11911191
ShadowView {
11921192
depth_texture_view,
1193-
pass_name: format!("shadow pass directional light {}", light_index),
1193+
pass_name: format!("shadow pass directional light {light_index}"),
11941194
},
11951195
ExtractedView {
11961196
viewport: UVec4::new(

crates/bevy_reflect/bevy_reflect_derive/src/trait_reflection.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,16 @@ pub(crate) fn reflect_trait(_args: &TokenStream, input: TokenStream) -> TokenStr
3535
let bevy_reflect_path = BevyManifest::default().get_path("bevy_reflect");
3636

3737
let struct_doc = format!(
38-
" A type generated by the #[reflect_trait] macro for the `{}` trait.\n\n This allows casting from `dyn Reflect` to `dyn {}`.",
39-
trait_ident,
40-
trait_ident
38+
" A type generated by the #[reflect_trait] macro for the `{trait_ident}` trait.\n\n This allows casting from `dyn Reflect` to `dyn {trait_ident}`.",
4139
);
4240
let get_doc = format!(
43-
" Downcast a `&dyn Reflect` type to `&dyn {}`.\n\n If the type cannot be downcast, `None` is returned.",
44-
trait_ident,
41+
" Downcast a `&dyn Reflect` type to `&dyn {trait_ident}`.\n\n If the type cannot be downcast, `None` is returned.",
4542
);
4643
let get_mut_doc = format!(
47-
" Downcast a `&mut dyn Reflect` type to `&mut dyn {}`.\n\n If the type cannot be downcast, `None` is returned.",
48-
trait_ident,
44+
" Downcast a `&mut dyn Reflect` type to `&mut dyn {trait_ident}`.\n\n If the type cannot be downcast, `None` is returned.",
4945
);
5046
let get_box_doc = format!(
51-
" Downcast a `Box<dyn Reflect>` type to `Box<dyn {}>`.\n\n If the type cannot be downcast, this will return `Err(Box<dyn Reflect>)`.",
52-
trait_ident,
47+
" Downcast a `Box<dyn Reflect>` type to `Box<dyn {trait_ident}>`.\n\n If the type cannot be downcast, this will return `Err(Box<dyn Reflect>)`.",
5348
);
5449

5550
TokenStream::from(quote! {

crates/bevy_reflect/src/serde/de.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,14 @@ impl<'a, 'de> DeserializeSeed<'de> for TypedReflectDeserializer<'a> {
467467
TypeInfo::Value(_) => {
468468
// This case should already be handled
469469
Err(de::Error::custom(format_args!(
470-
"the TypeRegistration for {} doesn't have ReflectDeserialize",
471-
type_name
470+
"the TypeRegistration for {type_name} doesn't have ReflectDeserialize",
472471
)))
473472
}
474473
TypeInfo::Dynamic(_) => {
475474
// We could potentially allow this but we'd have no idea what the actual types of the
476475
// fields are and would rely on the deserializer to determine them (e.g. `i32` vs `i64`)
477476
Err(de::Error::custom(format_args!(
478-
"cannot deserialize arbitrary dynamic type {}",
479-
type_name
477+
"cannot deserialize arbitrary dynamic type {type_name}",
480478
)))
481479
}
482480
}
@@ -1080,10 +1078,7 @@ fn get_registration<'a, E: Error>(
10801078
registry: &'a TypeRegistry,
10811079
) -> Result<&'a TypeRegistration, E> {
10821080
let registration = registry.get(type_id).ok_or_else(|| {
1083-
Error::custom(format_args!(
1084-
"no registration found for type `{}`",
1085-
type_name
1086-
))
1081+
Error::custom(format_args!("no registration found for type `{type_name}`",))
10871082
})?;
10881083
Ok(registration)
10891084
}

crates/bevy_reflect/src/serde/ser.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ fn get_type_info<E: Error>(
5656
TypeInfo::Dynamic(..) => match registry.get_with_name(type_name) {
5757
Some(registration) => Ok(registration.type_info()),
5858
None => Err(Error::custom(format_args!(
59-
"no registration found for dynamic type with name {}",
60-
type_name
59+
"no registration found for dynamic type with name {type_name}",
6160
))),
6261
},
6362
info => Ok(info),
@@ -197,8 +196,7 @@ impl<'a> Serialize for StructSerializer<'a> {
197196
TypeInfo::Struct(struct_info) => struct_info,
198197
info => {
199198
return Err(Error::custom(format_args!(
200-
"expected struct type but received {:?}",
201-
info
199+
"expected struct type but received {info:?}"
202200
)));
203201
}
204202
};
@@ -247,8 +245,7 @@ impl<'a> Serialize for TupleStructSerializer<'a> {
247245
TypeInfo::TupleStruct(tuple_struct_info) => tuple_struct_info,
248246
info => {
249247
return Err(Error::custom(format_args!(
250-
"expected tuple struct type but received {:?}",
251-
info
248+
"expected tuple struct type but received {info:?}"
252249
)));
253250
}
254251
};
@@ -296,8 +293,7 @@ impl<'a> Serialize for EnumSerializer<'a> {
296293
TypeInfo::Enum(enum_info) => enum_info,
297294
info => {
298295
return Err(Error::custom(format_args!(
299-
"expected enum type but received {:?}",
300-
info
296+
"expected enum type but received {info:?}"
301297
)));
302298
}
303299
};
@@ -308,8 +304,7 @@ impl<'a> Serialize for EnumSerializer<'a> {
308304
.variant_at(variant_index as usize)
309305
.ok_or_else(|| {
310306
Error::custom(format_args!(
311-
"variant at index `{}` does not exist",
312-
variant_index
307+
"variant at index `{variant_index}` does not exist",
313308
))
314309
})?;
315310
let variant_name = variant_info.name();
@@ -333,8 +328,7 @@ impl<'a> Serialize for EnumSerializer<'a> {
333328
VariantInfo::Struct(struct_info) => struct_info,
334329
info => {
335330
return Err(Error::custom(format_args!(
336-
"expected struct variant type but received {:?}",
337-
info
331+
"expected struct variant type but received {info:?}",
338332
)));
339333
}
340334
};

0 commit comments

Comments
 (0)