chore: Fix `clippy::uninlined_format_args` lints

This commit is contained in:
relrelb 2022-12-14 23:29:46 +02:00 committed by relrelb
parent f904f20796
commit bd9078addf
29 changed files with 40 additions and 115 deletions

View File

@ -685,10 +685,7 @@ fn load_playerglobal<'gc>(
Avm2::do_abc(&mut activation.context, do_abc, domain) Avm2::do_abc(&mut activation.context, do_abc, domain)
.expect("playerglobal.swf should be valid"); .expect("playerglobal.swf should be valid");
} else if tag_code != TagCode::End { } else if tag_code != TagCode::End {
panic!( panic!("playerglobal should only contain `DoAbc` tag - found tag {tag_code:?}")
"playerglobal should only contain `DoAbc` tag - found tag {:?}",
tag_code
)
} }
Ok(ControlFlow::Continue) Ok(ControlFlow::Continue)
}; };

View File

@ -524,8 +524,7 @@ pub fn set_name<'gc>(
if dobj.instantiated_by_timeline() { if dobj.instantiated_by_timeline() {
return Err(format!( return Err(format!(
"Display object {} was placed by the timeline and cannot have it's name changed.", "Display object {new_name} was placed by the timeline and cannot have it's name changed.",
new_name
) )
.into()); .into());
} }

View File

@ -143,10 +143,7 @@ pub fn get_child_at<'gc>(
.unwrap_or(Value::Undefined) .unwrap_or(Value::Undefined)
.coerce_to_i32(activation)?; .coerce_to_i32(activation)?;
let child = dobj.child_by_index(index as usize).ok_or_else(|| { let child = dobj.child_by_index(index as usize).ok_or_else(|| {
format!( format!("RangeError: Display object container has no child with id {index}")
"RangeError: Display object container has no child with id {}",
index
)
})?; })?;
return Ok(child.object2()); return Ok(child.object2());

View File

@ -402,18 +402,14 @@ pub fn goto_frame<'gc>(
let scene = scene.coerce_to_string(activation)?; let scene = scene.coerce_to_string(activation)?;
if !mc.frame_exists_within_scene(&frame_or_label, &scene) { if !mc.frame_exists_within_scene(&frame_or_label, &scene) {
return Err(format!( return Err(format!(
"ArgumentError: Frame label {} not found in scene {}", "ArgumentError: Frame label {frame_or_label} not found in scene {scene}",
frame_or_label, scene
) )
.into()); .into());
} }
} }
mc.frame_label_to_number(&frame_or_label).ok_or_else(|| { mc.frame_label_to_number(&frame_or_label).ok_or_else(|| {
format!( format!("ArgumentError: {frame_or_label} is not a valid frame label.")
"ArgumentError: {} is not a valid frame label.",
frame_or_label
)
})? as u32 })? as u32
} }
} }

View File

@ -110,7 +110,7 @@ pub fn set_vertex_buffer_at<'gc>(
} else if &*format == b"bytes4" { } else if &*format == b"bytes4" {
Context3DVertexBufferFormat::Bytes4 Context3DVertexBufferFormat::Bytes4
} else { } else {
panic!("Unknown vertex format {:?}", format); panic!("Unknown vertex format {format:?}");
}; };
let buffer = buffer.as_vertex_buffer().unwrap(); let buffer = buffer.as_vertex_buffer().unwrap();
@ -231,7 +231,7 @@ pub fn set_program_constants_from_matrix<'gc>(
} else if &*program_type == b"fragment" { } else if &*program_type == b"fragment" {
ProgramType::Fragment ProgramType::Fragment
} else { } else {
panic!("Unknown program type {:?}", program_type); panic!("Unknown program type {program_type:?}");
}; };
let first_register = args let first_register = args

View File

@ -108,8 +108,7 @@ impl<'gc> PropertyClass<'gc> {
} }
return Err(Error::from(format!( return Err(Error::from(format!(
"Attempted to perform (private) resolution of nonexistent type {:?}", "Attempted to perform (private) resolution of nonexistent type {name:?}",
name
))); )));
} }
}; };

View File

@ -576,11 +576,11 @@ impl<'gc> Value<'gc> {
Value::Object(num) => match num.value_of(mc)? { Value::Object(num) => match num.value_of(mc)? {
Value::Number(num) => Ok(num as i32), Value::Number(num) => Ok(num as i32),
Value::Integer(num) => Ok(num), Value::Integer(num) => Ok(num),
_ => Err(format!("Expected Number, int, or uint, found {:?}", self).into()), _ => Err(format!("Expected Number, int, or uint, found {self:?}").into()),
}, },
Value::Number(num) => Ok(*num as i32), Value::Number(num) => Ok(*num as i32),
Value::Integer(num) => Ok(*num), Value::Integer(num) => Ok(*num),
_ => Err(format!("Expected Number, int, or uint, found {:?}", self).into()), _ => Err(format!("Expected Number, int, or uint, found {self:?}").into()),
} }
} }

View File

@ -337,11 +337,7 @@ impl<'gc> VectorStorage<'gc> {
}; };
if position >= self.storage.len() { if position >= self.storage.len() {
Err(format!( Err(format!("RangeError: Index {position} extends beyond the end of the vector").into())
"RangeError: Index {} extends beyond the end of the vector",
position
)
.into())
} else { } else {
Ok(self.storage.remove(position)) Ok(self.storage.remove(position))
} }

View File

@ -1341,7 +1341,7 @@ pub trait TDisplayObject<'gc>:
#[cfg(feature = "avm_debug")] #[cfg(feature = "avm_debug")]
fn display_render_tree(&self, depth: usize) { fn display_render_tree(&self, depth: usize) {
let self_str = format!("{:?}", self); let self_str = format!("{self:?}");
let paren = self_str.find('(').unwrap(); let paren = self_str.find('(').unwrap();
let self_str = &self_str[..paren]; let self_str = &self_str[..paren];

View File

@ -1,5 +1,4 @@
#![allow(clippy::bool_to_int_with_if)] #![allow(clippy::bool_to_int_with_if)]
#![allow(clippy::uninlined_format_args)]
#[macro_use] #[macro_use]
mod display_object; mod display_object;

View File

@ -1,7 +1,3 @@
#![allow(clippy::uninlined_format_args)]
use std::sync::Arc;
use gc_arena::MutationContext; use gc_arena::MutationContext;
use ruffle_render::backend::null::NullBitmapSource; use ruffle_render::backend::null::NullBitmapSource;
use ruffle_render::backend::{ use ruffle_render::backend::{
@ -15,6 +11,7 @@ use ruffle_render::matrix::Matrix;
use ruffle_render::shape_utils::{DistilledShape, DrawCommand, LineScaleMode, LineScales}; use ruffle_render::shape_utils::{DistilledShape, DrawCommand, LineScaleMode, LineScales};
use ruffle_render::transform::Transform; use ruffle_render::transform::Transform;
use ruffle_web_common::{JsError, JsResult}; use ruffle_web_common::{JsError, JsResult};
use std::sync::Arc;
use swf::{BlendMode, Color}; use swf::{BlendMode, Color};
use wasm_bindgen::{Clamped, JsCast, JsValue}; use wasm_bindgen::{Clamped, JsCast, JsValue};
use web_sys::{ use web_sys::{

View File

@ -121,8 +121,7 @@ impl VertexAttributeFormat {
VertexAttributeFormat::Float4 => base_expr, VertexAttributeFormat::Float4 => base_expr,
_ => { _ => {
return Err(Error::Unimplemented(format!( return Err(Error::Unimplemented(format!(
"Unsupported conversion from {:?} to float4", "Unsupported conversion from {self:?} to float4",
self
))) )))
} }
}) })
@ -560,8 +559,7 @@ impl<'a> NagaBuilder<'a> {
RegisterType::Varying => self.get_varying_pointer(dest.reg_num as usize)?, RegisterType::Varying => self.get_varying_pointer(dest.reg_num as usize)?,
_ => { _ => {
return Err(Error::Unimplemented(format!( return Err(Error::Unimplemented(format!(
"Unimplemented dest reg type: {:?}", "Unimplemented dest reg type: {dest:?}",
dest
))) )))
} }
}; };
@ -689,8 +687,7 @@ impl<'a> NagaBuilder<'a> {
} }
_ => { _ => {
return Err(Error::Unimplemented(format!( return Err(Error::Unimplemented(format!(
"Unimplemented opcode: {:?}", "Unimplemented opcode: {opcode:?}",
opcode
))) )))
} }
} }

View File

@ -1,4 +1,3 @@
#![allow(clippy::uninlined_format_args)]
use naga::Module; use naga::Module;
mod builder; mod builder;

View File

@ -1,5 +1,4 @@
#![allow(clippy::bool_to_int_with_if)] #![allow(clippy::bool_to_int_with_if)]
#![allow(clippy::uninlined_format_args)]
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};

View File

@ -1,7 +1,3 @@
#![allow(clippy::uninlined_format_args)]
use std::sync::Arc;
use crate::bitmaps::BitmapSamplers; use crate::bitmaps::BitmapSamplers;
use crate::descriptors::Quad; use crate::descriptors::Quad;
use crate::globals::Globals; use crate::globals::Globals;
@ -18,6 +14,7 @@ use once_cell::sync::OnceCell;
use ruffle_render::bitmap::{BitmapHandle, BitmapHandleImpl}; use ruffle_render::bitmap::{BitmapHandle, BitmapHandleImpl};
use ruffle_render::color_transform::ColorTransform; use ruffle_render::color_transform::ColorTransform;
use ruffle_render::tessellator::{Gradient as TessGradient, GradientType, Vertex as TessVertex}; use ruffle_render::tessellator::{Gradient as TessGradient, GradientType, Vertex as TessVertex};
use std::sync::Arc;
pub use wgpu; pub use wgpu;
type Error = Box<dyn std::error::Error>; type Error = Box<dyn std::error::Error>;

View File

@ -42,7 +42,7 @@ fn create_shader(
) -> wgpu::ShaderModule { ) -> wgpu::ShaderModule {
const COMMON_SRC: &str = include_str!("../shaders/common.wgsl"); const COMMON_SRC: &str = include_str!("../shaders/common.wgsl");
let src = [COMMON_SRC, src].concat(); let src = [COMMON_SRC, src].concat();
let label = create_debug_label!("Shader {}", name,); let label = create_debug_label!("Shader {}", name);
let desc = wgpu::ShaderModuleDescriptor { let desc = wgpu::ShaderModuleDescriptor {
label: label.as_deref(), label: label.as_deref(),
source: wgpu::ShaderSource::Wgsl(src.into()), source: wgpu::ShaderSource::Wgsl(src.into()),

View File

@ -50,34 +50,14 @@ pub fn analyze(results: impl Iterator<Item = FileResults>) {
println!(); println!();
if start > 0 { if start > 0 {
println!( println!("{start:>digits$} movies panicked or crashed the scanner");
"{:>digits$} movies panicked or crashed the scanner",
start,
digits = digits
);
} }
println!( println!("{read:>digits$} movies failed when reading");
"{:>digits$} movies failed when reading", println!("{decompress:>digits$} movies failed to decompress");
read,
digits = digits
);
println!(
"{:>digits$} movies failed to decompress",
decompress,
digits = digits
);
println!("{parse:>digits$} movies failed to parse"); println!("{parse:>digits$} movies failed to parse");
println!( println!("{execute:>digits$} movies failed to execute");
"{:>digits$} movies failed to execute", println!("{complete:>digits$} movies completed without errors");
execute,
digits = digits
);
println!(
"{:>digits$} movies completed without errors",
complete,
digits = digits
);
println!(); println!();
} }

View File

@ -1,5 +1,3 @@
#![allow(clippy::uninlined_format_args)]
use crate::analyze::analyze_main; use crate::analyze::analyze_main;
use crate::cli_options::{Mode, Opt}; use crate::cli_options::{Mode, Opt};
use crate::execute::execute_report_main; use crate::execute::execute_report_main;

View File

@ -420,8 +420,7 @@ pub mod tests {
let parsed_action = reader.read_action().unwrap(); let parsed_action = reader.read_action().unwrap();
assert_eq!( assert_eq!(
parsed_action, expected_action, parsed_action, expected_action,
"Incorrectly parsed action.\nRead:\n{:?}\n\nExpected:\n{:?}", "Incorrectly parsed action.\nRead:\n{parsed_action:?}\n\nExpected:\n{expected_action:?}",
parsed_action, expected_action
); );
} }
} }

View File

@ -478,8 +478,7 @@ mod tests {
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
written_bytes, expected_bytes, written_bytes, expected_bytes,
"Error writing action.\nTag:\n{:?}\n\nWrote:\n{:?}\n\nExpected:\n{:?}", "Error writing action.\nTag:\n{action:?}\n\nWrote:\n{written_bytes:?}\n\nExpected:\n{expected_bytes:?}",
action, written_bytes, expected_bytes
); );
} }
} }

View File

@ -508,12 +508,7 @@ impl<'a> Reader<'a> {
let byte = self.read_u8()?; let byte = self.read_u8()?;
let opcode = match OpCode::from_u8(byte) { let opcode = match OpCode::from_u8(byte) {
Some(o) => o, Some(o) => o,
None => { None => return Err(Error::invalid_data(format!("Unknown ABC opcode {byte:#x}"))),
return Err(Error::invalid_data(format!(
"Unknown ABC opcode {:#x}",
byte
)))
}
}; };
let op = match opcode { let op = match opcode {
@ -898,8 +893,7 @@ pub mod tests {
let parsed = reader.read().unwrap(); let parsed = reader.read().unwrap();
assert_eq!( assert_eq!(
parsed, abc_file, parsed, abc_file,
"Incorrectly parsed ABC.\nRead:\n{:?}\n\nExpected:\n{:?}", "Incorrectly parsed ABC.\nRead:\n{parsed:?}\n\nExpected:\n{abc_file:?}",
parsed, abc_file
); );
} }
} }

View File

@ -1061,8 +1061,7 @@ pub mod tests {
} }
assert_eq!( assert_eq!(
out, bytes, out, bytes,
"Incorrectly written ABC.\nWritten:\n{:?}\n\nExpected:\n{:?}", "Incorrectly written ABC.\nWritten:\n{out:?}\n\nExpected:\n{bytes:?}",
out, bytes
); );
} }
} }

View File

@ -8,7 +8,6 @@
//! writing SWF data. //! writing SWF data.
#![allow(clippy::bool_to_int_with_if)] #![allow(clippy::bool_to_int_with_if)]
#![allow(clippy::uninlined_format_args)]
#[cfg(feature = "flate2")] #[cfg(feature = "flate2")]
extern crate flate2; extern crate flate2;

View File

@ -3012,8 +3012,7 @@ pub mod tests {
}; };
assert_eq!( assert_eq!(
parsed_tag, expected_tag, parsed_tag, expected_tag,
"Incorrectly parsed tag.\nRead:\n{:#?}\n\nExpected:\n{:#?}", "Incorrectly parsed tag.\nRead:\n{parsed_tag:#?}\n\nExpected:\n{expected_tag:#?}",
parsed_tag, expected_tag
); );
} }
} }

View File

@ -2691,8 +2691,7 @@ mod tests {
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
written_tag_bytes, expected_tag_bytes, written_tag_bytes, expected_tag_bytes,
"Error reading tag.\nTag:\n{:?}\n\nWrote:\n{:?}\n\nExpected:\n{:?}", "Error reading tag.\nTag:\n{tag:?}\n\nWrote:\n{written_tag_bytes:?}\n\nExpected:\n{expected_tag_bytes:?}",
tag, written_tag_bytes, expected_tag_bytes
); );
} }
} }

View File

@ -1,5 +1,3 @@
#![allow(clippy::uninlined_format_args)]
//! Tests running SWFs in a headless Ruffle instance. //! Tests running SWFs in a headless Ruffle instance.
//! //!
//! Trace output can be compared with correct output from the official Flash Player. //! Trace output can be compared with correct output from the official Flash Player.
@ -944,8 +942,7 @@ fn external_interface_avm1() -> Result<(), Error> {
let parroted = let parroted =
player_locked.call_internal_interface("parrot", vec!["Hello World!".into()]); player_locked.call_internal_interface("parrot", vec!["Hello World!".into()]);
player_locked.log_backend().avm_trace(&format!( player_locked.log_backend().avm_trace(&format!(
"After calling `parrot` with a string: {:?}", "After calling `parrot` with a string: {parroted:?}",
parroted
)); ));
let mut nested = BTreeMap::new(); let mut nested = BTreeMap::new();
@ -970,8 +967,7 @@ fn external_interface_avm1() -> Result<(), Error> {
let result = player_locked let result = player_locked
.call_internal_interface("callWith", vec!["trace".into(), root.into()]); .call_internal_interface("callWith", vec!["trace".into(), root.into()]);
player_locked.log_backend().avm_trace(&format!( player_locked.log_backend().avm_trace(&format!(
"After calling `callWith` with a complex payload: {:?}", "After calling `callWith` with a complex payload: {result:?}",
result
)); ));
Ok(()) Ok(())
}, },
@ -1001,8 +997,7 @@ fn external_interface_avm2() -> Result<(), Error> {
let parroted = let parroted =
player_locked.call_internal_interface("parrot", vec!["Hello World!".into()]); player_locked.call_internal_interface("parrot", vec!["Hello World!".into()]);
player_locked.log_backend().avm_trace(&format!( player_locked.log_backend().avm_trace(&format!(
"After calling `parrot` with a string: {:?}", "After calling `parrot` with a string: {parroted:?}",
parroted
)); ));
player_locked.call_internal_interface("freestanding", vec!["Hello World!".into()]); player_locked.call_internal_interface("freestanding", vec!["Hello World!".into()]);
@ -1018,8 +1013,7 @@ fn external_interface_avm2() -> Result<(), Error> {
let result = let result =
player_locked.call_internal_interface("callWith", vec!["trace".into(), root]); player_locked.call_internal_interface("callWith", vec!["trace".into(), root]);
player_locked.log_backend().avm_trace(&format!( player_locked.log_backend().avm_trace(&format!(
"After calling `callWith` with a complex payload: {:?}", "After calling `callWith` with a complex payload: {result:?}",
result
)); ));
Ok(()) Ok(())
}, },
@ -1534,10 +1528,7 @@ fn run_swf(
if !matches { if !matches {
let actual_image_path = base_path.join(format!("actual-{suffix}.png")); let actual_image_path = base_path.join(format!("actual-{suffix}.png"));
actual_image.save_with_format(&actual_image_path, image::ImageFormat::Png)?; actual_image.save_with_format(&actual_image_path, image::ImageFormat::Png)?;
panic!( panic!("Test output does not match expected image - saved actual image to {actual_image_path:?}");
"Test output does not match expected image - saved actual image to {:?}",
actual_image_path
);
} }
} }

View File

@ -1,5 +1,3 @@
#![no_std]
#![allow(clippy::uninlined_format_args)]
//! Provides UCS2 string types for usage in AVM1 and AVM2. //! Provides UCS2 string types for usage in AVM1 and AVM2.
//! //!
//! Internally, these types are represeted by a sequence of 1-byte or 2-bytes (wide) code units, //! Internally, these types are represeted by a sequence of 1-byte or 2-bytes (wide) code units,
@ -8,6 +6,8 @@
//! To match Flash behavior, the string length is limited to 2³¹-1 code units; //! To match Flash behavior, the string length is limited to 2³¹-1 code units;
//! any attempt to create a longer string will panic. //! any attempt to create a longer string will panic.
#![no_std]
#[cfg_attr(test, macro_use)] #[cfg_attr(test, macro_use)]
extern crate alloc; extern crate alloc;

View File

@ -96,8 +96,7 @@ mod int_parse {
pub fn from_wstr_radix<T: IntParse>(s: &WStr, radix: u32) -> Option<T> { pub fn from_wstr_radix<T: IntParse>(s: &WStr, radix: u32) -> Option<T> {
assert!( assert!(
radix >= 2 && radix <= 36, radix >= 2 && radix <= 36,
"from_str_radix: radix must be between 2 and 36, got {}", "from_str_radix: radix must be between 2 and 36, got {radix}",
radix
); );
let (is_neg, digits) = match s.get(0).map(u8::try_from) { let (is_neg, digits) = match s.get(0).map(u8::try_from) {

View File

@ -150,8 +150,7 @@ fn test_pattern<'a, P: Pattern<'a> + Clone + Debug>(
let mut actual: Vec<_> = core::iter::from_fn(|| searcher.next_match()).collect(); let mut actual: Vec<_> = core::iter::from_fn(|| searcher.next_match()).collect();
assert_eq!( assert_eq!(
actual, forwards, actual, forwards,
"incorrect forwards matching: haystack={:?}; pattern={:?}", "incorrect forwards matching: haystack={haystack:?}; pattern={pattern:?}",
haystack, pattern
); );
searcher = pattern.clone().into_searcher(haystack); searcher = pattern.clone().into_searcher(haystack);
@ -160,9 +159,7 @@ fn test_pattern<'a, P: Pattern<'a> + Clone + Debug>(
assert_eq!( assert_eq!(
actual, actual,
backwards.unwrap_or(forwards), backwards.unwrap_or(forwards),
"incorrect backwards matching: haystack={:?}; pattern={:?}", "incorrect backwards matching: haystack={haystack:?}; pattern={pattern:?}",
haystack,
pattern
); );
} }