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.
This commit is contained in:
张林伟 2023-01-11 09:51:22 +00:00
parent bb79903938
commit 0d2cdb450d
22 changed files with 66 additions and 140 deletions

View File

@ -872,8 +872,7 @@ impl App {
match self.add_boxed_plugin(Box::new(plugin)) { match self.add_boxed_plugin(Box::new(plugin)) {
Ok(app) => app, Ok(app) => app,
Err(AppError::DuplicatePlugin { plugin_name }) => panic!( Err(AppError::DuplicatePlugin { plugin_name }) => panic!(
"Error adding plugin {}: : plugin was already added in application", "Error adding plugin {plugin_name}: : plugin was already added in application"
plugin_name
), ),
} }
} }

View File

@ -94,13 +94,13 @@ impl ReflectAsset {
} }
/// Equivalent of [`Assets::add`] /// Equivalent of [`Assets::add`]
pub fn add<'w>(&self, world: &'w mut World, value: &dyn Reflect) -> HandleUntyped { pub fn add(&self, world: &mut World, value: &dyn Reflect) -> HandleUntyped {
(self.add)(world, value) (self.add)(world, value)
} }
/// Equivalent of [`Assets::set`] /// Equivalent of [`Assets::set`]
pub fn set<'w>( pub fn set(
&self, &self,
world: &'w mut World, world: &mut World,
handle: HandleUntyped, handle: HandleUntyped,
value: &dyn Reflect, value: &dyn Reflect,
) -> HandleUntyped { ) -> HandleUntyped {

View File

@ -86,8 +86,7 @@ fn parse_component_attr(ast: &DeriveInput) -> Result<Attrs> {
return Err(Error::new_spanned( return Err(Error::new_spanned(
m.lit, m.lit,
format!( format!(
"Invalid storage type `{}`, expected '{}' or '{}'.", "Invalid storage type `{s}`, expected '{TABLE}' or '{SPARSE_SET}'.",
s, TABLE, SPARSE_SET
), ),
)) ))
} }

View File

@ -52,8 +52,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
fetch_struct_attributes.is_mutable = true; fetch_struct_attributes.is_mutable = true;
} else { } else {
panic!( panic!(
"The `{}` attribute is expected to have no value or arguments", "The `{MUTABLE_ATTRIBUTE_NAME}` attribute is expected to have no value or arguments",
MUTABLE_ATTRIBUTE_NAME
); );
} }
} else if ident == DERIVE_ATTRIBUTE_NAME { } else if ident == DERIVE_ATTRIBUTE_NAME {
@ -63,8 +62,7 @@ pub fn derive_world_query_impl(ast: DeriveInput) -> TokenStream {
.extend(meta_list.nested.iter().cloned()); .extend(meta_list.nested.iter().cloned());
} else { } else {
panic!( panic!(
"Expected a structured list within the `{}` attribute", "Expected a structured list within the `{DERIVE_ATTRIBUTE_NAME}` attribute",
DERIVE_ATTRIBUTE_NAME
); );
} }
} else { } else {

View File

@ -731,8 +731,7 @@ unsafe fn initialize_bundle(
deduped.dedup(); deduped.dedup();
assert!( assert!(
deduped.len() == component_ids.len(), deduped.len() == component_ids.len(),
"Bundle {} has duplicate components", "Bundle {bundle_type_name} has duplicate components",
bundle_type_name
); );
BundleInfo { id, component_ids } BundleInfo { id, component_ids }

View File

@ -224,10 +224,7 @@ impl Schedule {
// of the game. Closures inherit generic parameters from their enclosing function. // of the game. Closures inherit generic parameters from their enclosing function.
#[cold] #[cold]
fn stage_not_found(stage_label: &dyn Debug) -> ! { fn stage_not_found(stage_label: &dyn Debug) -> ! {
panic!( panic!("Stage '{stage_label:?}' does not exist or is not a SystemStage",)
"Stage '{:?}' does not exist or is not a SystemStage",
stage_label
)
} }
let label = stage_label.as_label(); let label = stage_label.as_label();

View File

@ -287,10 +287,9 @@ impl SystemStage {
.then(|| descriptor.system.name()) .then(|| descriptor.system.name())
{ {
panic!( panic!(
"The system {} has a run criteria, but its `SystemSet` also has a run \ "The system {name} has a run criteria, but its `SystemSet` also has a run \
criteria. This is not supported. Consider moving the system into a \ criteria. This is not supported. Consider moving the system into a \
different `SystemSet` or calling `add_system()` instead.", different `SystemSet` or calling `add_system()` instead."
name
) )
} }
} }
@ -459,8 +458,7 @@ impl SystemStage {
writeln!(message, " - {}", nodes[*index].name()).unwrap(); writeln!(message, " - {}", nodes[*index].name()).unwrap();
writeln!( writeln!(
message, message,
" wants to be after (because of labels: {:?})", " wants to be after (because of labels: {labels:?})",
labels,
) )
.unwrap(); .unwrap();
} }
@ -565,10 +563,7 @@ impl SystemStage {
if let RunCriteriaInner::Piped { input: parent, .. } = &mut criteria.inner { if let RunCriteriaInner::Piped { input: parent, .. } = &mut criteria.inner {
let label = &criteria.after[0]; let label = &criteria.after[0];
*parent = *labels.get(label).unwrap_or_else(|| { *parent = *labels.get(label).unwrap_or_else(|| {
panic!( panic!("Couldn't find run criteria labelled {label:?} to pipe from.",)
"Couldn't find run criteria labelled {:?} to pipe from.",
label
)
}); });
} }
} }

View File

@ -282,8 +282,7 @@ impl<'w, 's> Commands<'w, 's> {
pub fn entity<'a>(&'a mut self, entity: Entity) -> EntityCommands<'w, 's, 'a> { pub fn entity<'a>(&'a mut self, entity: Entity) -> EntityCommands<'w, 's, 'a> {
self.get_entity(entity).unwrap_or_else(|| { self.get_entity(entity).unwrap_or_else(|| {
panic!( panic!(
"Attempting to create an EntityCommands for entity {:?}, which doesn't exist.", "Attempting to create an EntityCommands for entity {entity:?}, which doesn't exist.",
entity
) )
}) })
} }

View File

@ -250,8 +250,7 @@ fn assert_component_access_compatibility(
.map(|component_id| world.components.get_info(component_id).unwrap().name()) .map(|component_id| world.components.get_info(component_id).unwrap().name())
.collect::<Vec<&str>>(); .collect::<Vec<&str>>();
let accesses = conflicting_components.join(", "); let accesses = conflicting_components.join(", ");
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`.", 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`.");
query_type, filter_type, system_name, accesses);
} }
/// A collection of potentially conflicting [`SystemParam`]s allowed by disjoint access. /// A collection of potentially conflicting [`SystemParam`]s allowed by disjoint access.

View File

@ -1256,8 +1256,7 @@ mod tests {
let actual = settings.filter(new_value, old_value); let actual = settings.filter(new_value, old_value);
assert_eq!( assert_eq!(
expected, actual, expected, actual,
"Testing filtering for {:?} with new_value = {:?}, old_value = {:?}", "Testing filtering for {settings:?} with new_value = {new_value:?}, old_value = {old_value:?}",
settings, new_value, old_value
); );
} }
@ -1312,8 +1311,7 @@ mod tests {
let actual = settings.filter(new_value, old_value); let actual = settings.filter(new_value, old_value);
assert_eq!( assert_eq!(
expected, actual, expected, actual,
"Testing filtering for {:?} with new_value = {:?}, old_value = {:?}", "Testing filtering for {settings:?} with new_value = {new_value:?}, old_value = {old_value:?}",
settings, new_value, old_value
); );
} }
@ -1398,8 +1396,7 @@ mod tests {
assert_eq!( assert_eq!(
expected, actual, expected, actual,
"testing ButtonSettings::is_pressed() for value: {}", "testing ButtonSettings::is_pressed() for value: {value}",
value
); );
} }
} }
@ -1424,8 +1421,7 @@ mod tests {
assert_eq!( assert_eq!(
expected, actual, expected, actual,
"testing ButtonSettings::is_released() for value: {}", "testing ButtonSettings::is_released() for value: {value}",
value
); );
} }
} }
@ -1450,8 +1446,7 @@ mod tests {
} }
Err(_) => { Err(_) => {
panic!( panic!(
"ButtonSettings::new({}, {}) should be valid ", "ButtonSettings::new({press_threshold}, {release_threshold}) should be valid"
press_threshold, release_threshold
); );
} }
} }
@ -1476,8 +1471,7 @@ mod tests {
match bs { match bs {
Ok(_) => { Ok(_) => {
panic!( panic!(
"ButtonSettings::new({}, {}) should be invalid", "ButtonSettings::new({press_threshold}, {release_threshold}) should be invalid"
press_threshold, release_threshold
); );
} }
Err(err_code) => match err_code { Err(err_code) => match err_code {

View File

@ -24,10 +24,7 @@ pub fn get_lit_str(attr_name: Symbol, lit: &syn::Lit) -> syn::Result<&syn::LitSt
} else { } else {
Err(syn::Error::new_spanned( Err(syn::Error::new_spanned(
lit, lit,
format!( format!("expected {attr_name} attribute to be a string: `{attr_name} = \"...\"`"),
"expected {} attribute to be a string: `{} = \"...\"`",
attr_name, attr_name
),
)) ))
} }
} }
@ -38,10 +35,7 @@ pub fn get_lit_bool(attr_name: Symbol, lit: &syn::Lit) -> syn::Result<bool> {
} else { } else {
Err(syn::Error::new_spanned( Err(syn::Error::new_spanned(
lit, lit,
format!( format!("expected {attr_name} attribute to be a bool value, `true` or `false`: `{attr_name} = ...`"),
"expected {} attribute to be a bool value, `true` or `false`: `{} = ...`",
attr_name, attr_name
),
)) ))
} }
} }

View File

@ -1190,7 +1190,7 @@ pub fn prepare_lights(
.spawn(( .spawn((
ShadowView { ShadowView {
depth_texture_view, depth_texture_view,
pass_name: format!("shadow pass directional light {}", light_index), pass_name: format!("shadow pass directional light {light_index}"),
}, },
ExtractedView { ExtractedView {
viewport: UVec4::new( viewport: UVec4::new(

View File

@ -35,21 +35,16 @@ pub(crate) fn reflect_trait(_args: &TokenStream, input: TokenStream) -> TokenStr
let bevy_reflect_path = BevyManifest::default().get_path("bevy_reflect"); let bevy_reflect_path = BevyManifest::default().get_path("bevy_reflect");
let struct_doc = format!( let struct_doc = format!(
" A type generated by the #[reflect_trait] macro for the `{}` trait.\n\n This allows casting from `dyn Reflect` to `dyn {}`.", " 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}`.",
trait_ident,
trait_ident
); );
let get_doc = format!( let get_doc = format!(
" Downcast a `&dyn Reflect` type to `&dyn {}`.\n\n If the type cannot be downcast, `None` is returned.", " Downcast a `&dyn Reflect` type to `&dyn {trait_ident}`.\n\n If the type cannot be downcast, `None` is returned.",
trait_ident,
); );
let get_mut_doc = format!( let get_mut_doc = format!(
" Downcast a `&mut dyn Reflect` type to `&mut dyn {}`.\n\n If the type cannot be downcast, `None` is returned.", " Downcast a `&mut dyn Reflect` type to `&mut dyn {trait_ident}`.\n\n If the type cannot be downcast, `None` is returned.",
trait_ident,
); );
let get_box_doc = format!( let get_box_doc = format!(
" Downcast a `Box<dyn Reflect>` type to `Box<dyn {}>`.\n\n If the type cannot be downcast, this will return `Err(Box<dyn Reflect>)`.", " 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>)`.",
trait_ident,
); );
TokenStream::from(quote! { TokenStream::from(quote! {

View File

@ -467,16 +467,14 @@ impl<'a, 'de> DeserializeSeed<'de> for TypedReflectDeserializer<'a> {
TypeInfo::Value(_) => { TypeInfo::Value(_) => {
// This case should already be handled // This case should already be handled
Err(de::Error::custom(format_args!( Err(de::Error::custom(format_args!(
"the TypeRegistration for {} doesn't have ReflectDeserialize", "the TypeRegistration for {type_name} doesn't have ReflectDeserialize",
type_name
))) )))
} }
TypeInfo::Dynamic(_) => { TypeInfo::Dynamic(_) => {
// We could potentially allow this but we'd have no idea what the actual types of the // We could potentially allow this but we'd have no idea what the actual types of the
// fields are and would rely on the deserializer to determine them (e.g. `i32` vs `i64`) // fields are and would rely on the deserializer to determine them (e.g. `i32` vs `i64`)
Err(de::Error::custom(format_args!( Err(de::Error::custom(format_args!(
"cannot deserialize arbitrary dynamic type {}", "cannot deserialize arbitrary dynamic type {type_name}",
type_name
))) )))
} }
} }
@ -1080,10 +1078,7 @@ fn get_registration<'a, E: Error>(
registry: &'a TypeRegistry, registry: &'a TypeRegistry,
) -> Result<&'a TypeRegistration, E> { ) -> Result<&'a TypeRegistration, E> {
let registration = registry.get(type_id).ok_or_else(|| { let registration = registry.get(type_id).ok_or_else(|| {
Error::custom(format_args!( Error::custom(format_args!("no registration found for type `{type_name}`",))
"no registration found for type `{}`",
type_name
))
})?; })?;
Ok(registration) Ok(registration)
} }

View File

@ -56,8 +56,7 @@ fn get_type_info<E: Error>(
TypeInfo::Dynamic(..) => match registry.get_with_name(type_name) { TypeInfo::Dynamic(..) => match registry.get_with_name(type_name) {
Some(registration) => Ok(registration.type_info()), Some(registration) => Ok(registration.type_info()),
None => Err(Error::custom(format_args!( None => Err(Error::custom(format_args!(
"no registration found for dynamic type with name {}", "no registration found for dynamic type with name {type_name}",
type_name
))), ))),
}, },
info => Ok(info), info => Ok(info),
@ -197,8 +196,7 @@ impl<'a> Serialize for StructSerializer<'a> {
TypeInfo::Struct(struct_info) => struct_info, TypeInfo::Struct(struct_info) => struct_info,
info => { info => {
return Err(Error::custom(format_args!( return Err(Error::custom(format_args!(
"expected struct type but received {:?}", "expected struct type but received {info:?}"
info
))); )));
} }
}; };
@ -247,8 +245,7 @@ impl<'a> Serialize for TupleStructSerializer<'a> {
TypeInfo::TupleStruct(tuple_struct_info) => tuple_struct_info, TypeInfo::TupleStruct(tuple_struct_info) => tuple_struct_info,
info => { info => {
return Err(Error::custom(format_args!( return Err(Error::custom(format_args!(
"expected tuple struct type but received {:?}", "expected tuple struct type but received {info:?}"
info
))); )));
} }
}; };
@ -296,8 +293,7 @@ impl<'a> Serialize for EnumSerializer<'a> {
TypeInfo::Enum(enum_info) => enum_info, TypeInfo::Enum(enum_info) => enum_info,
info => { info => {
return Err(Error::custom(format_args!( return Err(Error::custom(format_args!(
"expected enum type but received {:?}", "expected enum type but received {info:?}"
info
))); )));
} }
}; };
@ -308,8 +304,7 @@ impl<'a> Serialize for EnumSerializer<'a> {
.variant_at(variant_index as usize) .variant_at(variant_index as usize)
.ok_or_else(|| { .ok_or_else(|| {
Error::custom(format_args!( Error::custom(format_args!(
"variant at index `{}` does not exist", "variant at index `{variant_index}` does not exist",
variant_index
)) ))
})?; })?;
let variant_name = variant_info.name(); let variant_name = variant_info.name();
@ -333,8 +328,7 @@ impl<'a> Serialize for EnumSerializer<'a> {
VariantInfo::Struct(struct_info) => struct_info, VariantInfo::Struct(struct_info) => struct_info,
info => { info => {
return Err(Error::custom(format_args!( return Err(Error::custom(format_args!(
"expected struct variant type but received {:?}", "expected struct variant type but received {info:?}",
info
))); )));
} }
}; };

View File

@ -33,14 +33,12 @@ pub fn basis_buffer_to_image(
let basis_texture_format = transcoder.basis_texture_format(buffer); let basis_texture_format = transcoder.basis_texture_format(buffer);
if !basis_texture_format.can_transcode_to_format(transcode_format) { if !basis_texture_format.can_transcode_to_format(transcode_format) {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?} cannot be transcoded to {:?}", "{basis_texture_format:?} cannot be transcoded to {transcode_format:?}",
basis_texture_format, transcode_format
))); )));
} }
transcoder.prepare_transcoding(buffer).map_err(|_| { transcoder.prepare_transcoding(buffer).map_err(|_| {
TextureError::TranscodeError(format!( TextureError::TranscodeError(format!(
"Failed to prepare for transcoding from {:?}", "Failed to prepare for transcoding from {basis_texture_format:?}",
basis_texture_format
)) ))
})?; })?;
let mut transcoded = Vec::new(); let mut transcoded = Vec::new();
@ -49,8 +47,7 @@ pub fn basis_buffer_to_image(
let texture_type = transcoder.basis_texture_type(buffer); let texture_type = transcoder.basis_texture_type(buffer);
if texture_type == BasisTextureType::TextureTypeCubemapArray && image_count % 6 != 0 { if texture_type == BasisTextureType::TextureTypeCubemapArray && image_count % 6 != 0 {
return Err(TextureError::InvalidData(format!( return Err(TextureError::InvalidData(format!(
"Basis file with cube map array texture with non-modulo 6 number of images: {}", "Basis file with cube map array texture with non-modulo 6 number of images: {image_count}",
image_count,
))); )));
} }
@ -74,10 +71,7 @@ pub fn basis_buffer_to_image(
let mip_level_count = transcoder.image_level_count(buffer, image_index); let mip_level_count = transcoder.image_level_count(buffer, image_index);
if mip_level_count != image0_mip_level_count { if mip_level_count != image0_mip_level_count {
return Err(TextureError::InvalidData(format!( return Err(TextureError::InvalidData(format!(
"Array or volume texture has inconsistent number of mip levels. Image {} has {} but image 0 has {}", "Array or volume texture has inconsistent number of mip levels. Image {image_index} has {mip_level_count} but image 0 has {image0_mip_level_count}",
image_index,
mip_level_count,
image0_mip_level_count,
))); )));
} }
for level_index in 0..mip_level_count { for level_index in 0..mip_level_count {
@ -94,8 +88,7 @@ pub fn basis_buffer_to_image(
) )
.map_err(|error| { .map_err(|error| {
TextureError::TranscodeError(format!( TextureError::TranscodeError(format!(
"Failed to transcode mip level {} from {:?} to {:?}: {:?}", "Failed to transcode mip level {level_index} from {basis_texture_format:?} to {transcode_format:?}: {error:?}",
level_index, basis_texture_format, transcode_format, error
)) ))
})?; })?;
transcoded.append(&mut data); transcoded.append(&mut data);
@ -118,8 +111,7 @@ pub fn basis_buffer_to_image(
BasisTextureType::TextureTypeVolume => TextureDimension::D3, BasisTextureType::TextureTypeVolume => TextureDimension::D3,
basis_texture_type => { basis_texture_type => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?}", "{basis_texture_type:?}",
basis_texture_type
))) )))
} }
}; };

View File

@ -14,8 +14,7 @@ pub fn dds_buffer_to_image(
let texture_format = dds_format_to_texture_format(&dds, is_srgb)?; let texture_format = dds_format_to_texture_format(&dds, is_srgb)?;
if !supported_compressed_formats.supports(texture_format) { if !supported_compressed_formats.supports(texture_format) {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Format not supported by this GPU: {:?}", "Format not supported by this GPU: {texture_format:?}",
texture_format
))); )));
} }
let mut image = Image::default(); let mut image = Image::default();
@ -116,8 +115,7 @@ pub fn dds_format_to_texture_format(
| D3DFormat::YUY2 | D3DFormat::YUY2
| D3DFormat::CXV8U8 => { | D3DFormat::CXV8U8 => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?}", "{d3d_format:?}",
d3d_format
))) )))
} }
} }
@ -227,8 +225,7 @@ pub fn dds_format_to_texture_format(
} }
_ => { _ => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?}", "{dxgi_format:?}",
dxgi_format
))) )))
} }
} }

View File

@ -51,8 +51,7 @@ pub fn ktx2_buffer_to_image(
let mut decompressed = Vec::new(); let mut decompressed = Vec::new();
decoder.read_to_end(&mut decompressed).map_err(|err| { decoder.read_to_end(&mut decompressed).map_err(|err| {
TextureError::SuperDecompressionError(format!( TextureError::SuperDecompressionError(format!(
"Failed to decompress {:?} for mip {}: {:?}", "Failed to decompress {supercompression_scheme:?} for mip {_level}: {err:?}",
supercompression_scheme, _level, err
)) ))
})?; })?;
levels.push(decompressed); levels.push(decompressed);
@ -65,16 +64,14 @@ pub fn ktx2_buffer_to_image(
let mut decompressed = Vec::new(); let mut decompressed = Vec::new();
decoder.read_to_end(&mut decompressed).map_err(|err| { decoder.read_to_end(&mut decompressed).map_err(|err| {
TextureError::SuperDecompressionError(format!( TextureError::SuperDecompressionError(format!(
"Failed to decompress {:?} for mip {}: {:?}", "Failed to decompress {supercompression_scheme:?} for mip {_level}: {err:?}",
supercompression_scheme, _level, err
)) ))
})?; })?;
levels.push(decompressed); levels.push(decompressed);
} }
_ => { _ => {
return Err(TextureError::SuperDecompressionError(format!( return Err(TextureError::SuperDecompressionError(format!(
"Unsupported supercompression scheme: {:?}", "Unsupported supercompression scheme: {supercompression_scheme:?}",
supercompression_scheme
))); )));
} }
} }
@ -159,8 +156,7 @@ pub fn ktx2_buffer_to_image(
.map(|mut transcoded_level| transcoded[level].append(&mut transcoded_level)) .map(|mut transcoded_level| transcoded[level].append(&mut transcoded_level))
.map_err(|error| { .map_err(|error| {
TextureError::SuperDecompressionError(format!( TextureError::SuperDecompressionError(format!(
"Failed to transcode mip level {} from UASTC to {:?}: {:?}", "Failed to transcode mip level {level} from UASTC to {transcode_block_format:?}: {error:?}",
level, transcode_block_format, error
)) ))
})?; })?;
offset += level_bytes; offset += level_bytes;
@ -193,8 +189,7 @@ pub fn ktx2_buffer_to_image(
})?; })?;
if !supported_compressed_formats.supports(texture_format) { if !supported_compressed_formats.supports(texture_format) {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Format not supported by this GPU: {:?}", "Format not supported by this GPU: {texture_format:?}",
texture_format
))); )));
} }
@ -510,8 +505,7 @@ pub fn ktx2_dfd_to_texture_format(
}, },
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported sample bit length for RGBSDA 1-channel format: {}", "Unsupported sample bit length for RGBSDA 1-channel format: {v}",
v
))); )));
} }
} }
@ -593,8 +587,7 @@ pub fn ktx2_dfd_to_texture_format(
}, },
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported sample bit length for RGBSDA 2-channel format: {}", "Unsupported sample bit length for RGBSDA 2-channel format: {v}",
v
))); )));
} }
} }
@ -829,16 +822,14 @@ pub fn ktx2_dfd_to_texture_format(
}, },
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported sample bit length for RGBSDA 4-channel format: {}", "Unsupported sample bit length for RGBSDA 4-channel format: {v}",
v
))); )));
} }
} }
} }
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported channel count for RGBSDA format: {}", "Unsupported channel count for RGBSDA format: {v}",
v
))); )));
} }
} }
@ -954,16 +945,14 @@ pub fn ktx2_dfd_to_texture_format(
}, },
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported sample bit length for XYZW 4-channel format: {}", "Unsupported sample bit length for XYZW 4-channel format: {v}",
v
))); )));
} }
} }
} }
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported channel count for XYZW format: {}", "Unsupported channel count for XYZW format: {v}",
v
))); )));
} }
} }
@ -1088,8 +1077,7 @@ pub fn ktx2_dfd_to_texture_format(
} }
v => { v => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Unsupported channel count for ETC2 format: {}", "Unsupported channel count for ETC2 format: {v}",
v
))); )));
} }
}, },
@ -1148,8 +1136,7 @@ pub fn ktx2_dfd_to_texture_format(
6 => DataFormat::Rg, 6 => DataFormat::Rg,
channel_type => { channel_type => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"Invalid KTX2 UASTC channel type: {}", "Invalid KTX2 UASTC channel type: {channel_type}",
channel_type
))) )))
} }
}), }),
@ -1177,8 +1164,7 @@ pub fn ktx2_format_to_texture_format(
ktx2::Format::R8_UNORM | ktx2::Format::R8_SRGB => { ktx2::Format::R8_UNORM | ktx2::Format::R8_SRGB => {
if is_srgb { if is_srgb {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?}", "{ktx2_format:?}"
ktx2_format
))); )));
} }
TextureFormat::R8Unorm TextureFormat::R8Unorm
@ -1189,8 +1175,7 @@ pub fn ktx2_format_to_texture_format(
ktx2::Format::R8G8_UNORM | ktx2::Format::R8G8_SRGB => { ktx2::Format::R8G8_UNORM | ktx2::Format::R8G8_SRGB => {
if is_srgb { if is_srgb {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?}", "{ktx2_format:?}"
ktx2_format
))); )));
} }
TextureFormat::Rg8Unorm TextureFormat::Rg8Unorm
@ -1456,8 +1441,7 @@ pub fn ktx2_format_to_texture_format(
} }
_ => { _ => {
return Err(TextureError::UnsupportedTextureFormat(format!( return Err(TextureError::UnsupportedTextureFormat(format!(
"{:?}", "{ktx2_format:?}"
ktx2_format
))) )))
} }
}) })

View File

@ -192,8 +192,7 @@ pub fn prepare_windows(
.get(0) .get(0)
.unwrap_or_else(|| { .unwrap_or_else(|| {
panic!( panic!(
"No supported formats found for surface {:?} on adapter {:?}", "No supported formats found for surface {surface:?} on adapter {render_adapter:?}"
surface, render_adapter
) )
}); });
SurfaceData { surface, format } SurfaceData { surface, format }

View File

@ -688,9 +688,7 @@ mod tests {
expected expected
.reflect_partial_eq(received.as_ref()) .reflect_partial_eq(received.as_ref())
.unwrap_or_default(), .unwrap_or_default(),
"components did not match: (expected: `{:?}`, received: `{:?}`)", "components did not match: (expected: `{expected:?}`, received: `{received:?}`)",
expected,
received
); );
} }
} }

View File

@ -92,7 +92,7 @@ unsafe fn propagate_recursive(
mut changed: bool, mut changed: bool,
) { ) {
let Ok(actual_parent) = parent_query.get(entity) else { let Ok(actual_parent) = parent_query.get(entity) else {
panic!("Propagated child for {:?} has no Parent component!", entity); panic!("Propagated child for {entity:?} has no Parent component!");
}; };
assert_eq!( assert_eq!(
actual_parent.get(), expected_parent, actual_parent.get(), expected_parent,

View File

@ -173,8 +173,7 @@ fn change_text_system(
} }
text.sections[0].value = format!( text.sections[0].value = format!(
"This text changes in the bottom right - {:.1} fps, {:.3} ms/frame", "This text changes in the bottom right - {fps:.1} fps, {frame_time:.3} ms/frame",
fps, frame_time,
); );
text.sections[2].value = format!("{fps:.1}"); text.sections[2].value = format!("{fps:.1}");