From 398b57adbcfb645f7f048a2e27bec8a6c2688881 Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 07:05:50 +0000 Subject: [PATCH 1/8] Removed TODOs and code that didn't turn out to be necessary --- gdnative-derive/src/extend_bounds.rs | 2 -- impl/proc-macros/src/doc.rs | 36 ---------------------------- impl/proc-macros/src/lib.rs | 11 --------- 3 files changed, 49 deletions(-) diff --git a/gdnative-derive/src/extend_bounds.rs b/gdnative-derive/src/extend_bounds.rs index 3f086badf..6a0251b4c 100644 --- a/gdnative-derive/src/extend_bounds.rs +++ b/gdnative-derive/src/extend_bounds.rs @@ -24,8 +24,6 @@ impl<'ast> Visit<'ast> for BoundsVisitor<'ast> { if self.all_type_params.contains(&seg.ident) { // if the first segment of the type path is a known type variable, then this // is likely an associated type - // TODO: what about cases like as Trait>::A? Maybe too fringe to be - // useful? serde_derive can't seem to parse these either. Probably good enough. self.used.insert(type_path); } } diff --git a/impl/proc-macros/src/doc.rs b/impl/proc-macros/src/doc.rs index 9c38f4dee..e1ac3853e 100644 --- a/impl/proc-macros/src/doc.rs +++ b/impl/proc-macros/src/doc.rs @@ -1,42 +1,6 @@ use syn::visit_mut::VisitMut; use syn::{Attribute, ItemFn, ItemImpl}; -/* -Leaving code commented-out, as this might be very useful elsewhere - -use proc_macro2::TokenStream; -use quote::ToTokens; -use syn::{Item}; -pub fn variant_collection_safety( - _attr: proc_macro::TokenStream, - item: proc_macro::TokenStream, -) -> Result { - let mut item = syn::parse::(item)?; - let mut visit = IncludeDocs { - docs: &[ - "# Safety", - "", - "Generally, it's not recommended to mutate variant collections that may be shared. Prefer", - "`ThreadLocal` or `Unique` collections instead. If you're sure that the current reference", - "is unique, you may use [`assume_unique`](#method.assume_unique) to convert it to a `Unique`", - "collection. You may subsequently use [`into_thread_local`](#method.into_thread_local) to", - "convert it to a `ThreadLocal` one.", - "", - "It is only safe to perform operations that may allocate on a shared collection when no", - "other thread may access the underlying collection during the call.", - ], - deprecated: Some(concat!( - "Care should be used when mutating shared variant collections. Prefer `ThreadLocal` ", - "or `Unique` collections unless you're absolutely sure that you want this. ", - "You may use [assume_unique](#method.assume_unique) to convert this to a `Unique` ", - "collection if you are sure that this is in fact the only reference." - )), - }; - visit.visit_item_mut(&mut item); - Ok(item.to_token_stream()) -} -*/ - struct IncludeDocs<'a> { docs: &'a [&'a str], deprecated: Option<&'a str>, diff --git a/impl/proc-macros/src/lib.rs b/impl/proc-macros/src/lib.rs index 6bf9e3049..97fe50431 100644 --- a/impl/proc-macros/src/lib.rs +++ b/impl/proc-macros/src/lib.rs @@ -24,17 +24,6 @@ pub fn decl_typed_array_element(input: TokenStream) -> TokenStream { .into() } -/* -Leaving code commented-out, as this might be very useful elsewhere - -#[proc_macro_attribute] -pub fn doc_variant_collection_safety(attr: TokenStream, item: TokenStream) -> TokenStream { - self::doc::variant_collection_safety(attr, item) - .unwrap_or_else(to_compile_errors) - .into() -} -*/ - fn to_compile_errors(error: syn::Error) -> proc_macro2::TokenStream { let compile_error = error.to_compile_error(); quote!(#compile_error) From 34102db2173acd6892339dfb01aeffdb21a40308 Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 07:19:18 +0000 Subject: [PATCH 2/8] Removed TODOs for things that are already done --- bindings-generator/src/classes.rs | 3 --- gdnative-core/src/core_types/variant.rs | 2 -- 2 files changed, 5 deletions(-) diff --git a/bindings-generator/src/classes.rs b/bindings-generator/src/classes.rs index 8191d97ea..1558c14d1 100644 --- a/bindings-generator/src/classes.rs +++ b/bindings-generator/src/classes.rs @@ -96,9 +96,6 @@ pub(crate) fn generate_class_constants(class: &GodotClass) -> TokenStream { } pub(crate) fn generate_enums(class: &GodotClass) -> TokenStream { - // TODO: check whether the start of the variant name is equal to the end of the enum name and if so, don't repeat it. - // For example ImageFormat::Rgb8 instead of ImageFormat::FormatRgb8. - let mut enums: Vec<&Enum> = class.enums.iter().collect(); enums.sort(); let enums = enums.iter().map(|e| { diff --git a/gdnative-core/src/core_types/variant.rs b/gdnative-core/src/core_types/variant.rs index 0c812f0fc..561fa5bca 100644 --- a/gdnative-core/src/core_types/variant.rs +++ b/gdnative-core/src/core_types/variant.rs @@ -15,8 +15,6 @@ use crate::private::{get_api, ManuallyManagedClassPlaceholder}; #[cfg(feature = "serde")] mod serialize; -// TODO: implement Debug, PartialEq, etc. - /// A `Variant` can represent all Godot values (core types or `Object` class instances). /// /// The underlying data is either stored inline or reference-counted on the heap, From db8ad1b874838eff5b0f3fcb7999681b9d1841fb Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 07:14:39 +0000 Subject: [PATCH 3/8] Created issues for TODO comments --- gdnative-core/src/core_types/geom/plane.rs | 4 ++-- gdnative-core/src/core_types/string.rs | 4 +--- gdnative-core/src/core_types/variant_array.rs | 15 --------------- gdnative-core/src/export/class_builder.rs | 2 +- gdnative-core/src/export/property.rs | 2 +- gdnative-core/src/object/mod.rs | 2 +- test/src/test_serde.rs | 4 ++-- 7 files changed, 8 insertions(+), 25 deletions(-) diff --git a/gdnative-core/src/core_types/geom/plane.rs b/gdnative-core/src/core_types/geom/plane.rs index 0a64aedde..47a2e9e10 100644 --- a/gdnative-core/src/core_types/geom/plane.rs +++ b/gdnative-core/src/core_types/geom/plane.rs @@ -1,6 +1,6 @@ use crate::core_types::{IsEqualApprox, Vector3}; -// TODO enforce invariants via setters, make fields private +// TODO(#994) enforce invariants via setters, make fields private // Otherwise almost all methods need to panic // - normal.length() == 1 // - d > 0 @@ -322,7 +322,7 @@ mod test { assert!(!p.contains_point(Vector3::new(6.562291, -0.186564, -0.101982))); } - // TODO contains_point_eps() + // TODO(#994) contains_point_eps() #[test] fn intersect_3() { diff --git a/gdnative-core/src/core_types/string.rs b/gdnative-core/src/core_types/string.rs index d0ca76843..6af01db66 100644 --- a/gdnative-core/src/core_types/string.rs +++ b/gdnative-core/src/core_types/string.rs @@ -286,8 +286,6 @@ impl GodotString { sys_string.leak(); this } - - // TODO: many missing methods. } impl Clone for GodotString { @@ -454,7 +452,7 @@ impl Index for GodotString { } } -// TODO: Is it useful to expose this type? +// TODO(#993): Is it useful to expose this type? // Could just make it an internal detail of how to convert to a rust string. #[doc(hidden)] pub struct Utf8String(pub(crate) sys::godot_char_string); diff --git a/gdnative-core/src/core_types/variant_array.rs b/gdnative-core/src/core_types/variant_array.rs index f54b74cc4..3d4c7b2a5 100644 --- a/gdnative-core/src/core_types/variant_array.rs +++ b/gdnative-core/src/core_types/variant_array.rs @@ -181,21 +181,6 @@ impl VariantArray { self.into_iter() } - // TODO - // pub fn sort_custom(&mut self, obj: ?, s: ?) { - // unimplemented!() - // } - - // pub fn bsearch(&mut self, val: (), before: bool) -> i32 { - // unsafe { - // (get_api().godot_array_bsearch)(self.sys_mut(), val, before) - // } - // } - - // pub fn bsearch_custom(&mut self, val: ?, obj: ?, s: ?, before: bool) -> i32 { - // unimplemented!(); - // } - #[doc(hidden)] #[inline] pub fn sys(&self) -> *const sys::godot_array { diff --git a/gdnative-core/src/export/class_builder.rs b/gdnative-core/src/export/class_builder.rs index dbbd1f829..24d791046 100644 --- a/gdnative-core/src/export/class_builder.rs +++ b/gdnative-core/src/export/class_builder.rs @@ -7,7 +7,7 @@ use crate::export::*; use crate::object::NewRef; use crate::private::get_api; -// TODO unify string parameters across all buiders +// TODO(#996): unify string parameters across all buiders // Potential candidates: // * &str // * impl Into diff --git a/gdnative-core/src/export/property.rs b/gdnative-core/src/export/property.rs index d89904815..632e9c0af 100644 --- a/gdnative-core/src/export/property.rs +++ b/gdnative-core/src/export/property.rs @@ -114,7 +114,7 @@ where let default = self.default.to_variant(); let mut attr = sys::godot_property_attributes { - rset_type: sys::godot_method_rpc_mode_GODOT_METHOD_RPC_MODE_DISABLED, // TODO: + rset_type: sys::godot_method_rpc_mode_GODOT_METHOD_RPC_MODE_DISABLED, // TODO(#995) type_: variant_type as sys::godot_int, hint: hint_kind, hint_string: hint_string.to_sys(), diff --git a/gdnative-core/src/object/mod.rs b/gdnative-core/src/object/mod.rs index 9d6de0de1..e3cae7077 100644 --- a/gdnative-core/src/object/mod.rs +++ b/gdnative-core/src/object/mod.rs @@ -1000,7 +1000,7 @@ pub struct Null(PhantomData); impl Null { /// Creates an explicit null reference that can be used as a method argument. - // TODO consider something more idiomatic, like module::null::(), similar to std::ptr::null() + // TODO(#997) consider something more idiomatic, like module::null::(), similar to std::ptr::null() #[inline] #[allow(clippy::self_named_constructors)] pub fn null() -> Self { diff --git a/test/src/test_serde.rs b/test/src/test_serde.rs index ebc0a5d9a..ac61381f4 100644 --- a/test/src/test_serde.rs +++ b/test/src/test_serde.rs @@ -41,8 +41,8 @@ struct Foo { xform: Transform, color: Color, path: NodePath, - // dict: Dictionary, //TODO: PartialEq - // v_arr: VariantArray, //TODO: PartialEq + // dict: Dictionary, //TODO(#990): PartialEq + // v_arr: VariantArray, //TODO(#990): PartialEq byte_arr: ByteArray, int_arr: Int32Array, float_arr: Float32Array, From 3c09e6a9303cc25594109c5d31a26c6f795c28ef Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 06:46:12 +0000 Subject: [PATCH 4/8] Uncommented tests, fixed `Transform::interpolate_with` `Transform::interpolate_with` was erroneously implemented as its Godot 4 version. The error went through because the TODO comment wasn't checked. This reverts it to the Godot 3 behavior of performing `slerp`, which is what users of GDNative is likely expecting. --- gdnative-core/src/core_types/dictionary.rs | 25 +++--- .../src/core_types/geom/transform.rs | 77 +++++++++---------- gdnative-core/src/core_types/variant_array.rs | 25 +++--- test/src/lib.rs | 4 +- 4 files changed, 65 insertions(+), 66 deletions(-) diff --git a/gdnative-core/src/core_types/dictionary.rs b/gdnative-core/src/core_types/dictionary.rs index fc219247c..d01ce6322 100644 --- a/gdnative-core/src/core_types/dictionary.rs +++ b/gdnative-core/src/core_types/dictionary.rs @@ -585,16 +585,15 @@ godot_test!(test_dictionary { assert_eq!(expected_keys, iter_keys); }); -// TODO: clear dictionaries without affecting clones -//godot_test!(test_dictionary_clone_clear { -// let foo = Variant::from_str("foo"); -// let bar = Variant::from_str("bar"); -// let mut dict = Dictionary::new(); -// -// dict.set(&foo, &bar); -// let dict_clone = dict.clone(); -// dict.clear(); -// -// assert!(dict.is_empty()); -// assert!(!dict_clone.is_empty()); -//}); +godot_test!(test_dictionary_clone_clear { + let foo = Variant::new("foo"); + let bar = Variant::new("bar"); + let dict = Dictionary::new(); + + dict.insert(&foo, &bar); + let dict_clone = dict.duplicate(); + dict.clear(); + + assert!(dict.is_empty()); + assert!(!dict_clone.is_empty()); +}); diff --git a/gdnative-core/src/core_types/geom/transform.rs b/gdnative-core/src/core_types/geom/transform.rs index 874175595..ae1869465 100644 --- a/gdnative-core/src/core_types/geom/transform.rs +++ b/gdnative-core/src/core_types/geom/transform.rs @@ -247,11 +247,18 @@ impl Transform { self.basis.is_equal_approx(&other.basis) && self.origin.is_equal_approx(other.origin) } - /// Interpolates the transform to other Transform by - /// weight amount (on the range of 0.0 to 1.0). + /// Interpolates the transform to other Transform by weight amount (on the range of 0.0 to 1.0). /// Assuming the two transforms are located on a sphere surface. #[inline] + #[deprecated = "This is the Godot 4 rename of `interpolate_with`. It will be removed in favor of the original Godot 3 naming in a future version."] pub fn sphere_interpolate_with(&self, other: &Transform, weight: f32) -> Self { + self.interpolate_with(other, weight) + } + + /// Interpolates the transform to other Transform by weight amount (on the range of 0.0 to 1.0). + /// Assuming the two transforms are located on a sphere surface. + #[inline] + pub fn interpolate_with(&self, other: &Transform, weight: f32) -> Self { let src_scale = self.basis.scale(); let src_rot = self.basis.to_quat(); let src_loc = self.origin; @@ -268,16 +275,6 @@ impl Transform { } } - /// Interpolates the transform to other Transform by - /// weight amount (on the range of 0.0 to 1.0). - #[inline] - pub fn interpolate_with(&self, other: &Transform, weight: f32) -> Self { - Transform { - basis: self.basis.lerp(&other.basis, weight), - origin: self.origin.linear_interpolate(other.origin, weight), - } - } - #[doc(hidden)] #[inline] pub fn sys(&self) -> *const sys::godot_transform { @@ -314,6 +311,30 @@ impl MulAssign for Transform { mod tests { use super::*; + /// Equivalent GDScript, in case Godot values need to be updated: + /// + /// ```gdscript + /// func test_inputs(): + /// var basis = Basis(Vector3(37.51756, 20.39467, 49.96816)) + /// var t = Transform( + /// basis.x, + /// basis.y, + /// basis.z, + /// Vector3(0.0, 0.0, 0.0)) + /// t = t.translated(Vector3(0.5, -1.0, 0.25)) + /// t = t.scaled(Vector3(0.25, 0.5, 2.0)) + /// + /// basis = Basis(Vector3(12.23, 50.46, 93.94)) + /// var t2 = Transform( + /// basis.x, + /// basis.y, + /// basis.z, + /// Vector3(0.0, 0.0, 0.0)) + /// t2 = t2.translated(Vector3(1.5, -2.0, 1.25)) + /// t2 = t2.scaled(Vector3(0.5, 0.58, 1.0)) + /// + /// return [t, t2] + /// ``` fn test_inputs() -> (Transform, Transform) { let basis = Basis::from_euler(Vector3::new(37.51756, 20.39467, 49.96816)); let mut t = Transform::from_basis_origin( @@ -376,22 +397,19 @@ mod tests { assert!(expected.is_equal_approx(&t)) } - /* #[test] fn inverse_is_sane() { let t = test_inputs().0.inverse(); let expected = Transform::from_basis_origin( - // Fix values - Vector3::new(0.309725, -0.66022015, 3.9329607), - Vector3::new(-0.57629496, 1.8808193, 0.3611141), - Vector3::new(-0.47722515, -0.14864945, 0.012628445), - Vector3::new(-0.7398631, 0.0425314, 0.03682696), + Vector3::new(0.019358, -0.041264, 0.24581), + Vector3::new(-0.144074, 0.470205, 0.090279), + Vector3::new(-1.908901, -0.594598, 0.050514), + Vector3::new(-0.739863, 0.042531, 0.036827), ); println!("TF: {t:?}"); assert!(expected.is_equal_approx(&t)) } - */ #[test] fn orthonormalization_is_sane() { @@ -409,31 +427,12 @@ mod tests { } #[test] - fn linear_interpolation_is_sane() { + fn spherical_interpolation_is_sane() { // Godot reports: // t = 0.019358, -0.041264, 0.24581, -0.144074, 0.470205, 0.090279, -1.908901, -0.594598, 0.050514 - 0.112395, -0.519672, -0.347224 // t2 = 0.477182, 0.118214, 0.09123, -0.165859, 0.521769, 0.191437, -0.086105, -0.367178, 0.926157 - 0.593383, -1.05303, 1.762894 - // TODO: Get new godot result. https://github.com/godotengine/godot/commit/61759da5b35e44003ab3ffe3d4024dd611d17eff changed how Transform3D.linear_interpolate works - // For now assuming this is sane - examined the new implementation manually. let (t, t2) = test_inputs(); let result = t.interpolate_with(&t2, 0.5); - let expected = Transform::from_basis_origin( - Vector3::new(0.24826992, -0.15496635, -0.997503), - Vector3::new(0.038474888, 0.49598676, -0.4808879), - Vector3::new(0.16852, 0.14085774, 0.48833522), - Vector3::new(0.352889, -0.786351, 0.707835), - ); - assert!(expected.is_equal_approx(&result)) - } - - #[test] - fn sphere_linear_interpolation_is_sane() { - // Godot reports: - // t = 0.019358, -0.041264, 0.24581, -0.144074, 0.470205, 0.090279, -1.908901, -0.594598, 0.050514 - 0.112395, -0.519672, -0.347224 - // t2 = 0.477182, 0.118214, 0.09123, -0.165859, 0.521769, 0.191437, -0.086105, -0.367178, 0.926157 - 0.593383, -1.05303, 1.762894 - // result = 0.727909, -0.029075, 0.486138, -0.338385, 0.6514, 0.156468, -0.910002, -0.265481, 0.330678 - 0.352889, -0.786351, 0.707835 - let (t, t2) = test_inputs(); - let result = t.sphere_interpolate_with(&t2, 0.5); let expected = Transform::from_basis_origin( Vector3::new(0.7279087, -0.19632529, -0.45626357), Vector3::new(-0.05011323, 0.65140045, -0.22942543), diff --git a/gdnative-core/src/core_types/variant_array.rs b/gdnative-core/src/core_types/variant_array.rs index 3d4c7b2a5..11cd9891b 100644 --- a/gdnative-core/src/core_types/variant_array.rs +++ b/gdnative-core/src/core_types/variant_array.rs @@ -631,15 +631,16 @@ godot_test!( } ); -// TODO: clear arrays without affecting clones -//godot_test!(test_array_clone_clear { -// let foo = Variant::new("foo"); -// let mut array = VariantArray::new(); -// -// array.push(&foo); -// let array_clone = array.clone(); -// array.clear(); -// -// assert!(array.is_empty()); -// assert!(!array_clone.is_empty()); -//}); +godot_test!( + test_array_clone_clear { + let foo = Variant::new("foo"); + let array = VariantArray::new(); + + array.push(&foo); + let array_clone = array.duplicate(); + array.clear(); + + assert!(array.is_empty()); + assert!(!array_clone.is_empty()); + } +); diff --git a/test/src/lib.rs b/test/src/lib.rs index ecf711e9c..f0ac95d19 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -30,11 +30,11 @@ pub extern "C" fn run_tests( status &= gdnative::core_types::test_string_name_ord(); status &= gdnative::core_types::test_dictionary(); - // status &= gdnative::test_dictionary_clone_clear(); + status &= gdnative::core_types::test_dictionary_clone_clear(); status &= gdnative::core_types::test_color(); status &= gdnative::core_types::test_array(); status &= gdnative::core_types::test_array_debug(); - // status &= gdnative::test_array_clone_clear(); + status &= gdnative::core_types::test_array_clone_clear(); status &= gdnative::core_types::test_variant_nil(); status &= gdnative::core_types::test_variant_i64(); From b5b558ee98acd94ff39d8ea70f44ef05d36e97f6 Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 07:21:19 +0000 Subject: [PATCH 5/8] At long last, a logo for our docs! --- gdnative/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdnative/src/lib.rs b/gdnative/src/lib.rs index a2c29f107..6ff2a9182 100644 --- a/gdnative/src/lib.rs +++ b/gdnative/src/lib.rs @@ -85,7 +85,7 @@ //! //! -// TODO: add logo using #![doc(html_logo_url = "https://")] +#![doc(html_logo_url = "https://github.com/godot-rust/gdnative/raw/master/assets/godot-ferris.svg")] // Workaround (rustdoc 1.55): // Items, which are #[doc(hidden)] in their original crate and re-exported with a wildcard, lose From a3eaacf04c2f4a181dffffa3c9f5d04b5bc6442e Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 09:34:56 +0000 Subject: [PATCH 6/8] Appease clippy --- examples/dodge-the-creeps/src/player.rs | 4 ++-- examples/scene-create/src/lib.rs | 2 +- gdnative-core/src/core_types/geom/transform.rs | 8 +++++++- gdnative-core/src/lib.rs | 5 ++++- test/src/lib.rs | 2 +- test/src/test_async.rs | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/dodge-the-creeps/src/player.rs b/examples/dodge-the-creeps/src/player.rs index 21ac94d4e..9767c5839 100644 --- a/examples/dodge-the-creeps/src/player.rs +++ b/examples/dodge-the-creeps/src/player.rs @@ -82,8 +82,8 @@ impl Player { let change = velocity * delta; let position = owner.global_position() + change; let position = Vector2::new( - position.x.max(0.0).min(self.screen_size.x), - position.y.max(0.0).min(self.screen_size.y), + position.x.clamp(0.0, self.screen_size.x), + position.y.clamp(0.0, self.screen_size.y), ); owner.set_global_position(position); } diff --git a/examples/scene-create/src/lib.rs b/examples/scene-create/src/lib.rs index 2036a1c0a..e542926bc 100644 --- a/examples/scene-create/src/lib.rs +++ b/examples/scene-create/src/lib.rs @@ -59,7 +59,7 @@ impl SceneCreate { Ok(spatial) => { // Here is how you rename the child... let key_str = format!("child_{}", self.children_spawned); - spatial.set_name(&key_str); + spatial.set_name(key_str); let x = (self.children_spawned % 10) as f32; let z = (self.children_spawned / 10) as f32; diff --git a/gdnative-core/src/core_types/geom/transform.rs b/gdnative-core/src/core_types/geom/transform.rs index ae1869465..ec40aa633 100644 --- a/gdnative-core/src/core_types/geom/transform.rs +++ b/gdnative-core/src/core_types/geom/transform.rs @@ -103,6 +103,12 @@ impl Transform { This method will be renamed to translated_local in gdnative 0.12."] #[inline] pub fn translated(&self, translation: Vector3) -> Self { + self.translated_local(translation) + } + + /// Returns this transform, with its origin moved by a certain `translation` + #[inline] + pub fn translated_local(&self, translation: Vector3) -> Self { Self { basis: self.basis, origin: self.origin + translation, @@ -365,7 +371,7 @@ mod tests { #[test] fn translation_is_sane() { let translation = Vector3::new(1.0, 2.0, 3.0); - let t = Transform::default().translated(translation); + let t = Transform::default().translated_local(translation); assert!(t.basis.elements[0] == Vector3::new(1.0, 0.0, 0.0)); assert!(t.basis.elements[1] == Vector3::new(0.0, 1.0, 0.0)); assert!(t.basis.elements[2] == Vector3::new(0.0, 0.0, 1.0)); diff --git a/gdnative-core/src/lib.rs b/gdnative-core/src/lib.rs index 46b3cd47f..5eb83ec0a 100644 --- a/gdnative-core/src/lib.rs +++ b/gdnative-core/src/lib.rs @@ -25,7 +25,10 @@ clippy::missing_safety_doc, clippy::non_send_fields_in_send_ty )] -#![cfg_attr(feature = "gd-test", allow(clippy::blacklisted_name))] +#![cfg_attr( + any(test, feature = "gd-test"), + allow(clippy::excessive_precision, clippy::disallowed_names) +)] #[doc(hidden)] pub extern crate gdnative_sys as sys; diff --git a/test/src/lib.rs b/test/src/lib.rs index f0ac95d19..1137db5f0 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] #![allow(deprecated)] use gdnative::prelude::*; diff --git a/test/src/test_async.rs b/test/src/test_async.rs index 4f1912ce1..8a2b14e14 100644 --- a/test/src/test_async.rs +++ b/test/src/test_async.rs @@ -9,7 +9,7 @@ pub(crate) fn run_tests() -> bool { thread_local! { static EXECUTOR: &'static SharedLocalPool = { - Box::leak(Box::new(SharedLocalPool::default())) + Box::leak(Box::default()) }; } From 69659376b48b7d2f27f712c1de74dc74c44a96cb Mon Sep 17 00:00:00 2001 From: Chitose Yuuzaki Date: Wed, 7 Dec 2022 09:19:20 +0000 Subject: [PATCH 7/8] Add CI checks against todo comments without issues --- .github/workflows/minimal-ci.yml | 15 +++++++ tools/detect-todo.sh | 75 ++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 tools/detect-todo.sh diff --git a/.github/workflows/minimal-ci.yml b/.github/workflows/minimal-ci.yml index d804c6feb..68a7cc3b3 100644 --- a/.github/workflows/minimal-ci.yml +++ b/.github/workflows/minimal-ci.yml @@ -12,6 +12,8 @@ env: # Don't use more features like "gdnative_bindings_generator/debug" to keep CI truly minimal GDRUST_FEATURES: "gdnative/async,gdnative/serde" + RIPGREP_VERSION: "13.0.0" + on: pull_request: branches: @@ -52,6 +54,19 @@ jobs: - name: "Check clippy" run: cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented + check-todo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: "Install ripgrep" + run: | + cd /tmp + wget --no-verbose https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz -O ripgrep.tar.gz + tar -zxvf ripgrep.tar.gz + sudo mv ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/rg /usr/bin + - name: "Look for TODO comments without issue numbers attached to them" + run: bash tools/detect-todo.sh + unit-test: runs-on: ubuntu-latest steps: diff --git a/tools/detect-todo.sh b/tools/detect-todo.sh new file mode 100644 index 000000000..e49921fec --- /dev/null +++ b/tools/detect-todo.sh @@ -0,0 +1,75 @@ +#!/usr/bin/bash + +# Small utility to detect todo comments +# Used by godot-rust developers + +REGEX='(? Date: Wed, 7 Dec 2022 10:45:03 +0000 Subject: [PATCH 8/8] Use new format macro syntax --- bindings-generator/src/api.rs | 2 +- bindings-generator/src/class_docs.rs | 29 +++----------- bindings-generator/src/documentation.rs | 2 +- bindings-generator/src/godot_version.rs | 7 +--- bindings-generator/src/methods.rs | 2 +- bindings-generator/src/special_methods.rs | 2 +- gdnative-async/src/method.rs | 2 +- gdnative-async/src/rt.rs | 4 +- gdnative-bindings/build.rs | 7 ++-- gdnative-core/src/core_types/byte_array.rs | 2 +- gdnative-core/src/core_types/color_array.rs | 2 +- gdnative-core/src/core_types/dictionary.rs | 3 +- gdnative-core/src/core_types/error.rs | 2 +- gdnative-core/src/core_types/float32_array.rs | 2 +- .../src/core_types/geom/transform2d.rs | 4 +- gdnative-core/src/core_types/int32_array.rs | 2 +- gdnative-core/src/core_types/string_array.rs | 2 +- gdnative-core/src/core_types/variant.rs | 39 ++++++++----------- .../src/core_types/variant/serialize.rs | 12 ++---- gdnative-core/src/core_types/variant_array.rs | 2 +- gdnative-core/src/core_types/vector2_array.rs | 2 +- gdnative-core/src/core_types/vector3_array.rs | 2 +- gdnative-core/src/export/method.rs | 23 +++++------ gdnative-core/src/export/property/hint.rs | 6 +-- gdnative-core/src/export/user_data.rs | 5 +-- gdnative-core/src/init/info.rs | 2 +- gdnative-core/src/log.rs | 2 +- gdnative-core/src/private.rs | 2 +- gdnative-core/src/profiler.rs | 2 +- gdnative-derive/src/methods.rs | 20 +++------- gdnative-derive/src/native_script/mod.rs | 6 +-- .../src/native_script/property_args.rs | 7 +--- gdnative-derive/src/profiled.rs | 2 +- gdnative-derive/src/varargs.rs | 11 +++--- gdnative-derive/src/variant/attr.rs | 3 +- gdnative-derive/src/variant/attr/field.rs | 7 ++-- gdnative-derive/src/variant/attr/item.rs | 4 +- gdnative-derive/src/variant/from.rs | 6 +-- gdnative-derive/src/variant/mod.rs | 2 +- gdnative-derive/src/variant/repr.rs | 4 +- gdnative-derive/src/variant/to.rs | 4 +- gdnative-sys/build.rs | 37 +++++++----------- impl/proc-macros/src/pool_array_element.rs | 6 +-- test/src/lib.rs | 2 +- 44 files changed, 117 insertions(+), 179 deletions(-) diff --git a/bindings-generator/src/api.rs b/bindings-generator/src/api.rs index c8c8774af..169ecac05 100644 --- a/bindings-generator/src/api.rs +++ b/bindings-generator/src/api.rs @@ -785,7 +785,7 @@ mod tests { ]; tests.iter().for_each(|(class_name, expected)| { let actual = module_name_from_class_name(class_name); - assert_eq!(*expected, actual, "Input: {}", class_name); + assert_eq!(*expected, actual, "Input: {class_name}"); }); } } diff --git a/bindings-generator/src/class_docs.rs b/bindings-generator/src/class_docs.rs index 787848f1e..28c89e6f6 100644 --- a/bindings-generator/src/class_docs.rs +++ b/bindings-generator/src/class_docs.rs @@ -67,20 +67,10 @@ impl GodotXmlDocs { if let Some(property_name) = node.attribute("name") { if !property_name.contains('/') { if node.has_attribute("setter") { - self.add_fn( - class, - &format!("set_{}", property_name), - desc, - &[], - ); + self.add_fn(class, &format!("set_{property_name}"), desc, &[]); } if node.has_attribute("getter") { - self.add_fn( - class, - &format!("get_{}", property_name), - desc, - &[], - ); + self.add_fn(class, &format!("get_{property_name}"), desc, &[]); } } } @@ -187,10 +177,7 @@ impl GodotXmlDocs { // Info for GDScript blocks let godot_doc = if godot_doc.contains("[codeblock]") { - format!( - "_Sample code is GDScript unless otherwise noted._\n\n{}", - godot_doc - ) + format!("_Sample code is GDScript unless otherwise noted._\n\n{godot_doc}") } else { godot_doc }; @@ -213,9 +200,9 @@ impl GodotXmlDocs { let text = &c[2]; if text.is_empty() { - format!("<{url}>", url = url) + format!("<{url}>") } else { - format!("[{text}]({url})", text = text, url = url) + format!("[{text}]({url})") } }); @@ -247,11 +234,7 @@ impl GodotXmlDocs { let godot_ty = &c[2]; let rust_ty = Self::translate_type(godot_ty); - format!( - "[`{godot_ty}`][{rust_ty}]", - godot_ty = godot_ty, - rust_ty = rust_ty - ) + format!("[`{godot_ty}`][{rust_ty}]") }); godot_doc.to_string() diff --git a/bindings-generator/src/documentation.rs b/bindings-generator/src/documentation.rs index 8e2ae9f78..dbf66bcc6 100644 --- a/bindings-generator/src/documentation.rs +++ b/bindings-generator/src/documentation.rs @@ -149,7 +149,7 @@ fn list_base_classes(output: &mut impl Write, api: &Api, parent_name: &str) -> G if let Some(parent) = api.find_class(parent_name) { let class_link = class_doc_link(parent); - writeln!(output, " - {}", class_link)?; + writeln!(output, " - {class_link}")?; if !parent.base_class.is_empty() { list_base_classes(output, api, &parent.base_class)?; diff --git a/bindings-generator/src/godot_version.rs b/bindings-generator/src/godot_version.rs index d61deabe0..1b05d4b6c 100644 --- a/bindings-generator/src/godot_version.rs +++ b/bindings-generator/src/godot_version.rs @@ -15,12 +15,7 @@ pub fn parse_godot_version(version_str: &str) -> Result()?, diff --git a/bindings-generator/src/methods.rs b/bindings-generator/src/methods.rs index c282a650d..3312ff4dd 100644 --- a/bindings-generator/src/methods.rs +++ b/bindings-generator/src/methods.rs @@ -200,7 +200,7 @@ pub fn generate_method_table(api: &Api, class: &GodotClass) -> TokenStream { } = m.get_name(); let rust_ident = format_ident!("{}", rust_name); - let original_name = format!("{}\0", original_name); + let original_name = format!("{original_name}\0"); if !skip_method(m, rust_name) { assert!(original_name.ends_with('\0'), "original_name must be null terminated"); diff --git a/bindings-generator/src/special_methods.rs b/bindings-generator/src/special_methods.rs index f4d2fd718..a25e52cf8 100644 --- a/bindings-generator/src/special_methods.rs +++ b/bindings-generator/src/special_methods.rs @@ -113,7 +113,7 @@ pub fn generate_singleton_getter(class: &GodotClass) -> TokenStream { class.name.as_ref() }; - let singleton_name = format!("{}\0", s_name); + let singleton_name = format!("{s_name}\0"); assert!( singleton_name.ends_with('\0'), diff --git a/gdnative-async/src/method.rs b/gdnative-async/src/method.rs index 572a2ced3..0327db7ff 100644 --- a/gdnative-async/src/method.rs +++ b/gdnative-async/src/method.rs @@ -209,7 +209,7 @@ impl> Method for Async { Some(Err(err)) => { log::error( Self::site().unwrap_or_default(), - format_args!("unable to spawn future: {}", err), + format_args!("unable to spawn future: {err}"), ); Variant::nil() } diff --git a/gdnative-async/src/rt.rs b/gdnative-async/src/rt.rs index 1178142aa..da736d6ea 100644 --- a/gdnative-async/src/rt.rs +++ b/gdnative-async/src/rt.rs @@ -107,8 +107,8 @@ pub fn register_runtime_with_prefix(handle: &InitHandle, prefix: S) where S: Display, { - handle.add_class_as::(format!("{}SignalBridge", prefix)); - handle.add_class_as::(format!("{}FuncState", prefix)); + handle.add_class_as::(format!("{prefix}SignalBridge")); + handle.add_class_as::(format!("{prefix}FuncState")); } /// Releases all observers still in use. This should be called in the diff --git a/gdnative-bindings/build.rs b/gdnative-bindings/build.rs index 0efa7b6e5..9fb3d5f95 100644 --- a/gdnative-bindings/build.rs +++ b/gdnative-bindings/build.rs @@ -92,16 +92,15 @@ fn generate( for (class, code) in &binding_res.class_bindings { let mod_name = gen::module_name_from_class_name(&class.name); - let mod_path = out_path.join(format!("{}.rs", mod_name)); + let mod_path = out_path.join(format!("{mod_name}.rs")); let mut mod_output = BufWriter::new(File::create(&mod_path).unwrap()); write!( &mut mod_output, r#" - {content} + {code} use super::*; "#, - content = code, ) .unwrap(); @@ -152,7 +151,7 @@ fn format_file_if_needed(output_rs: &Path) { Ok(_) => println!("Done."), Err(err) => { println!("Failed."); - println!("Error: {}", err); + println!("Error: {err}"); } } } diff --git a/gdnative-core/src/core_types/byte_array.rs b/gdnative-core/src/core_types/byte_array.rs index 3965a7a90..c0371aad2 100644 --- a/gdnative-core/src/core_types/byte_array.rs +++ b/gdnative-core/src/core_types/byte_array.rs @@ -49,6 +49,6 @@ godot_test!( godot_test!( test_byte_array_debug { let arr = (0..8).collect::(); - assert_eq!(format!("{:?}", arr), "[0, 1, 2, 3, 4, 5, 6, 7]"); + assert_eq!(format!("{arr:?}"), "[0, 1, 2, 3, 4, 5, 6, 7]"); } ); diff --git a/gdnative-core/src/core_types/color_array.rs b/gdnative-core/src/core_types/color_array.rs index 27ee2d54d..123383671 100644 --- a/gdnative-core/src/core_types/color_array.rs +++ b/gdnative-core/src/core_types/color_array.rs @@ -57,6 +57,6 @@ godot_test!( Color::from_rgb(0.0, 0.0, 1.0), ]); - assert_eq!(format!("{:?}", arr), "[Color { r: 1.0, g: 0.0, b: 0.0, a: 1.0 }, Color { r: 0.0, g: 1.0, b: 0.0, a: 1.0 }, Color { r: 0.0, g: 0.0, b: 1.0, a: 1.0 }]"); + assert_eq!(format!("{arr:?}"), "[Color { r: 1.0, g: 0.0, b: 0.0, a: 1.0 }, Color { r: 0.0, g: 1.0, b: 0.0, a: 1.0 }, Color { r: 0.0, g: 0.0, b: 1.0, a: 1.0 }]"); } ); diff --git a/gdnative-core/src/core_types/dictionary.rs b/gdnative-core/src/core_types/dictionary.rs index d01ce6322..79521dd36 100644 --- a/gdnative-core/src/core_types/dictionary.rs +++ b/gdnative-core/src/core_types/dictionary.rs @@ -578,8 +578,7 @@ godot_test!(test_dictionary { assert_eq!(Some(value), dict.get(&key)); assert!( iter_keys.insert(key.to_string()) , - "key is already contained in set: {:?}", - key + "key is already contained in set: {key:?}" ); } assert_eq!(expected_keys, iter_keys); diff --git a/gdnative-core/src/core_types/error.rs b/gdnative-core/src/core_types/error.rs index e2e809b8c..eca4d10b2 100644 --- a/gdnative-core/src/core_types/error.rs +++ b/gdnative-core/src/core_types/error.rs @@ -77,7 +77,7 @@ impl GodotError { impl std::fmt::Display for GodotError { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "Godot API error: {:?}", self) + write!(f, "Godot API error: {self:?}") } } diff --git a/gdnative-core/src/core_types/float32_array.rs b/gdnative-core/src/core_types/float32_array.rs index 9cebcb961..332979be8 100644 --- a/gdnative-core/src/core_types/float32_array.rs +++ b/gdnative-core/src/core_types/float32_array.rs @@ -43,6 +43,6 @@ godot_test!( godot_test!( test_float32_array_debug { let arr = (0..8).map(|i| i as f32).collect::(); - assert_eq!(format!("{:?}", arr), "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]"); + assert_eq!(format!("{arr:?}"), "[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]"); } ); diff --git a/gdnative-core/src/core_types/geom/transform2d.rs b/gdnative-core/src/core_types/geom/transform2d.rs index 8d256fa4d..f11f13ceb 100644 --- a/gdnative-core/src/core_types/geom/transform2d.rs +++ b/gdnative-core/src/core_types/geom/transform2d.rs @@ -472,8 +472,6 @@ fn test_transform2d_constructor() { let expected_local_right = Vector2::RIGHT.rotated(-rotation) * scale; assert!( actual_local_right.is_equal_approx(expected_local_right), - "{:?} != {:?}", - actual_local_right, - expected_local_right + "{actual_local_right:?} != {expected_local_right:?}" ); } diff --git a/gdnative-core/src/core_types/int32_array.rs b/gdnative-core/src/core_types/int32_array.rs index 4fde65c00..68904fa52 100644 --- a/gdnative-core/src/core_types/int32_array.rs +++ b/gdnative-core/src/core_types/int32_array.rs @@ -39,6 +39,6 @@ godot_test!( godot_test!( test_int32_array_debug { let arr = (0..8).collect::(); - assert_eq!(format!("{:?}", arr), "[0, 1, 2, 3, 4, 5, 6, 7]"); + assert_eq!(format!("{arr:?}"), "[0, 1, 2, 3, 4, 5, 6, 7]"); } ); diff --git a/gdnative-core/src/core_types/string_array.rs b/gdnative-core/src/core_types/string_array.rs index afe1ed1af..8efbaaf26 100644 --- a/gdnative-core/src/core_types/string_array.rs +++ b/gdnative-core/src/core_types/string_array.rs @@ -57,6 +57,6 @@ godot_test!( GodotString::from("baz"), ]); - assert_eq!(format!("{:?}", arr), "[\"foo\", \"bar\", \"baz\"]"); + assert_eq!(format!("{arr:?}"), "[\"foo\", \"bar\", \"baz\"]"); } ); diff --git a/gdnative-core/src/core_types/variant.rs b/gdnative-core/src/core_types/variant.rs index 561fa5bca..f2c5637f8 100644 --- a/gdnative-core/src/core_types/variant.rs +++ b/gdnative-core/src/core_types/variant.rs @@ -928,7 +928,7 @@ impl FromVariantError { /// Returns a `FromVariantError` with a custom message. #[inline] pub fn custom(message: T) -> Self { - FromVariantError::Custom(format!("{}", message)) + FromVariantError::Custom(format!("{message}")) } } @@ -939,38 +939,31 @@ impl fmt::Display for FromVariantError { match self { E::Unspecified => write!(f, "unspecified error"), - E::Custom(s) => write!(f, "{}", s), + E::Custom(s) => write!(f, "{s}"), E::InvalidNil => write!(f, "expected non-nullable type, got null"), E::InvalidVariantType { variant_type, expected, } => write!( f, - "invalid variant type: expected {:?}, got {:?}", - expected, variant_type + "invalid variant type: expected {expected:?}, got {variant_type:?}" ), E::CannotCast { class, to } => { - write!(f, "cannot cast object of class {} to {}", class, to) + write!(f, "cannot cast object of class {class} to {to}") } E::InvalidLength { len, expected } => { - write!(f, "expected collection of length {}, got {}", expected, len) + write!(f, "expected collection of length {expected}, got {len}") } E::InvalidEnumRepr { expected, error } => write!( f, - "invalid enum representation: expected {:?}, {}", - expected, error + "invalid enum representation: expected {expected:?}, {error}" ), E::InvalidStructRepr { expected, error } => write!( f, - "invalid struct representation: expected {:?}, {}", - expected, error + "invalid struct representation: expected {expected:?}, {error}" ), E::UnknownEnumVariant { variant, expected } => { - write!( - f, - "unknown enum variant {}, expected variants are: ", - variant - )?; + write!(f, "unknown enum variant {variant}, expected variants are: ")?; let mut first = true; for v in *expected { if first { @@ -978,39 +971,39 @@ impl fmt::Display for FromVariantError { } else { write!(f, ", ")?; } - write!(f, "{}", v)?; + write!(f, "{v}")?; } Ok(()) } E::InvalidEnumVariant { variant, error } => { - write!(f, "invalid value for variant {}: {}", variant, error) + write!(f, "invalid value for variant {variant}: {error}") } E::InvalidInstance { expected } => { - write!(f, "object is not an instance of `NativeClass` {}", expected) + write!(f, "object is not an instance of `NativeClass` {expected}") } E::InvalidField { field_name, error } => { - write!(f, "invalid value for field {}", field_name)?; + write!(f, "invalid value for field {field_name}")?; let mut next_error = error.as_ref(); loop { match next_error { E::InvalidField { field_name, error } => { - write!(f, ".{}", field_name)?; + write!(f, ".{field_name}")?; next_error = error.as_ref(); } E::InvalidItem { index, error } => { - write!(f, "[{}]", index)?; + write!(f, "[{index}]")?; next_error = error.as_ref(); } _ => { - write!(f, ": {}", next_error)?; + write!(f, ": {next_error}")?; return Ok(()); } } } } E::InvalidItem { index, error } => { - write!(f, "invalid value for item at index {}: {}", index, error) + write!(f, "invalid value for item at index {index}: {error}") } } } diff --git a/gdnative-core/src/core_types/variant/serialize.rs b/gdnative-core/src/core_types/variant/serialize.rs index e1ebb537a..1097782bd 100644 --- a/gdnative-core/src/core_types/variant/serialize.rs +++ b/gdnative-core/src/core_types/variant/serialize.rs @@ -25,7 +25,7 @@ impl<'de> Visitor<'de> for VariantTypeVisitor { if value < VariantType::NAMES.len() as u64 { Ok(VariantType::from_sys(value as sys::godot_variant_type)) } else { - Err(E::custom(&*format!("invalid VariantType value: {}", value))) + Err(E::custom(&*format!("invalid VariantType value: {value}"))) } } @@ -39,10 +39,7 @@ impl<'de> Visitor<'de> for VariantTypeVisitor { return Ok(VariantType::from_sys(i as sys::godot_variant_type)); } } - Err(E::custom(&*format!( - "invalid VariantType value: {:?}", - value - ))) + Err(E::custom(&*format!("invalid VariantType value: {value:?}"))) } #[inline] @@ -55,10 +52,7 @@ impl<'de> Visitor<'de> for VariantTypeVisitor { return Ok(VariantType::from_sys(i as sys::godot_variant_type)); } } - Err(E::custom(&*format!( - "invalid VariantType value: {:?}", - value - ))) + Err(E::custom(&*format!("invalid VariantType value: {value:?}"))) } #[inline] diff --git a/gdnative-core/src/core_types/variant_array.rs b/gdnative-core/src/core_types/variant_array.rs index 11cd9891b..0dbadce85 100644 --- a/gdnative-core/src/core_types/variant_array.rs +++ b/gdnative-core/src/core_types/variant_array.rs @@ -617,7 +617,7 @@ godot_test!( arr.push(&Variant::new(true)); arr.push(&Variant::new(42)); - assert_eq!(format!("{:?}", arr), "[GodotString(hello world), Bool(True), I64(42)]"); + assert_eq!(format!("{arr:?}"), "[GodotString(hello world), Bool(True), I64(42)]"); let set = catch_unwind(|| { arr.set(3, 7i64); }); let get = catch_unwind(|| { arr.get(3); }); diff --git a/gdnative-core/src/core_types/vector2_array.rs b/gdnative-core/src/core_types/vector2_array.rs index f9e4a5b2b..1bd09f66c 100644 --- a/gdnative-core/src/core_types/vector2_array.rs +++ b/gdnative-core/src/core_types/vector2_array.rs @@ -57,6 +57,6 @@ godot_test!( Vector2::new(5.0, 6.0), ]); - assert_eq!(format!("{:?}", arr), format!("{:?}", &[Vector2::new(1.0, 2.0), Vector2::new(3.0, 4.0), Vector2::new(5.0, 6.0)])); + assert_eq!(format!("{arr:?}"), format!("{:?}", &[Vector2::new(1.0, 2.0), Vector2::new(3.0, 4.0), Vector2::new(5.0, 6.0)])); } ); diff --git a/gdnative-core/src/core_types/vector3_array.rs b/gdnative-core/src/core_types/vector3_array.rs index e18d6778c..14bc5f026 100644 --- a/gdnative-core/src/core_types/vector3_array.rs +++ b/gdnative-core/src/core_types/vector3_array.rs @@ -58,6 +58,6 @@ godot_test!( Vector3::new(5.0, 6.0, 7.0), ]); - assert_eq!(format!("{:?}", arr), format!("{:?}", &[Vector3::new(1.0, 2.0, 3.0), Vector3::new(3.0, 4.0, 5.0), Vector3::new(5.0, 6.0, 7.0)])); + assert_eq!(format!("{arr:?}"), format!("{:?}", &[Vector3::new(1.0, 2.0, 3.0), Vector3::new(3.0, 4.0, 5.0), Vector3::new(5.0, 6.0, 7.0)])); } ); diff --git a/gdnative-core/src/export/method.rs b/gdnative-core/src/export/method.rs index 501a8120a..1099b1715 100644 --- a/gdnative-core/src/export/method.rs +++ b/gdnative-core/src/export/method.rs @@ -489,12 +489,11 @@ impl fmt::Display for VarargsError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { VarargsError::InvalidArgumentType { index, error } => { - write!(f, "type error for argument #{}: {}", index, error)? + write!(f, "type error for argument #{index}: {error}")? } VarargsError::InvalidLength { expected, length } => write!( f, - "length mismatch: expected range {}, actual {}", - expected, length + "length mismatch: expected range {expected}, actual {length}" )?, } @@ -572,7 +571,7 @@ impl From> for IndexBounds { impl fmt::Debug for IndexBounds { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "IndexBounds({})", self) + write!(f, "IndexBounds({self})") } } @@ -580,13 +579,13 @@ impl fmt::Display for IndexBounds { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(start) = self.start { - write!(f, "{}", start)? + write!(f, "{start}")? } write!(f, "..=")?; if let Some(end) = self.end { - write!(f, "{}", end)? + write!(f, "{end}")? } Ok(()) @@ -719,7 +718,7 @@ impl<'a> fmt::Display for ArgumentError<'a> { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Some(site) = &self.site { - write!(f, "at {}: ", site)?; + write!(f, "at {site}: ")?; } write!(f, "{}", self.kind) } @@ -786,10 +785,10 @@ impl<'a> fmt::Display for ArgumentErrorKind<'a> { idx, name: Some(name), } => { - write!(f, "missing non-optional parameter `{}` (#{})", name, idx) + write!(f, "missing non-optional parameter `{name}` (#{idx})") } E::Missing { idx, name: None } => { - write!(f, "missing non-optional parameter #{}", idx) + write!(f, "missing non-optional parameter #{idx}") } E::CannotConvert { idx, @@ -799,8 +798,7 @@ impl<'a> fmt::Display for ArgumentErrorKind<'a> { err, } => { write!(f, - "cannot convert argument `{}` (#{}, {:?}) to {}: {} (non-primitive types may impose structural checks)", - name, idx, value, ty, err + "cannot convert argument `{name}` (#{idx}, {value:?}) to {ty}: {err} (non-primitive types may impose structural checks)" ) } E::CannotConvert { @@ -811,8 +809,7 @@ impl<'a> fmt::Display for ArgumentErrorKind<'a> { err, } => { write!(f, - "cannot convert argument #{} ({:?}) to {}: {} (non-primitive types may impose structural checks)", - idx, value, ty, err + "cannot convert argument #{idx} ({value:?}) to {ty}: {err} (non-primitive types may impose structural checks)" ) } E::ExcessArguments { rest } => { diff --git a/gdnative-core/src/export/property/hint.rs b/gdnative-core/src/export/property/hint.rs index 4de05f7bf..43cd4709f 100644 --- a/gdnative-core/src/export/property/hint.rs +++ b/gdnative-core/src/export/property/hint.rs @@ -77,7 +77,7 @@ where write!(s, "{},{}", self.min, self.max).unwrap(); if let Some(step) = &self.step { - write!(s, ",{}", step).unwrap(); + write!(s, ",{step}").unwrap(); } if self.or_greater { @@ -132,11 +132,11 @@ impl EnumHint { let mut iter = self.values.iter(); if let Some(first) = iter.next() { - write!(s, "{}", first).unwrap(); + write!(s, "{first}").unwrap(); } for rest in iter { - write!(s, ",{}", rest).unwrap(); + write!(s, ",{rest}").unwrap(); } s.into() diff --git a/gdnative-core/src/export/user_data.rs b/gdnative-core/src/export/user_data.rs index a282ed0a3..514f97c56 100644 --- a/gdnative-core/src/export/user_data.rs +++ b/gdnative-core/src/export/user_data.rs @@ -232,7 +232,7 @@ impl std::fmt::Display for LockFailed { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - LockFailed::Timeout(wait) => write!(f, "failed to acquire lock within {:?}", wait), + LockFailed::Timeout(wait) => write!(f, "failed to acquire lock within {wait:?}"), LockFailed::Pessimistic => write!(f, "failed to acquire lock, it was already held"), } } @@ -576,8 +576,7 @@ mod local_cell { match self { LocalCellError::DifferentThread { original, current } => write!( f, - "accessing from the wrong thread, expected {:?} found {:?}", - original, current + "accessing from the wrong thread, expected {original:?} found {current:?}" ), LocalCellError::BorrowFailed => write!( f, diff --git a/gdnative-core/src/init/info.rs b/gdnative-core/src/init/info.rs index a43dd9b8e..42e07a566 100644 --- a/gdnative-core/src/init/info.rs +++ b/gdnative-core/src/init/info.rs @@ -59,7 +59,7 @@ impl InitializeInfo { if let Some(report_loading_error_fn) = report_loading_error { // Add the trailing zero and convert Display => String - let message = format!("{}\0", message); + let message = format!("{message}\0"); // Convert to FFI compatible string let message = std::ffi::CStr::from_bytes_with_nul(message.as_bytes()) diff --git a/gdnative-core/src/log.rs b/gdnative-core/src/log.rs index 63183ee98..ea1b3d952 100644 --- a/gdnative-core/src/log.rs +++ b/gdnative-core/src/log.rs @@ -56,7 +56,7 @@ impl<'a> Display for Site<'a> { #[inline] pub fn print(msg: S) { unsafe { - let msg = GodotString::from_str(&msg.to_string()); + let msg = GodotString::from_str(msg.to_string()); (private::get_api().godot_print)(&msg.to_sys() as *const _); } } diff --git a/gdnative-core/src/private.rs b/gdnative-core/src/private.rs index 266fdb1c0..2e81754c7 100644 --- a/gdnative-core/src/private.rs +++ b/gdnative-core/src/private.rs @@ -169,7 +169,7 @@ unsafe fn report_init_error( got, } => { if let Some(f) = (*options).report_version_mismatch { - let message = CString::new(format!("{}", api_type)).unwrap(); + let message = CString::new(format!("{api_type}")).unwrap(); f((*options).gd_native_library, message.as_ptr(), want, got); } } diff --git a/gdnative-core/src/profiler.rs b/gdnative-core/src/profiler.rs index 606c098d2..0d7d0a1c1 100644 --- a/gdnative-core/src/profiler.rs +++ b/gdnative-core/src/profiler.rs @@ -103,7 +103,7 @@ impl Signature<'static> { panic!("tag should not contain `::`"); } - let sig = CString::new(format!("{}::{}::{}", file, line, tag)) + let sig = CString::new(format!("{file}::{line}::{tag}")) .expect("file and tag should not contain NUL bytes"); Self::from_raw_owned(sig) } diff --git a/gdnative-derive/src/methods.rs b/gdnative-derive/src/methods.rs index 821f736c8..eec95a1aa 100644 --- a/gdnative-derive/src/methods.rs +++ b/gdnative-derive/src/methods.rs @@ -157,8 +157,7 @@ impl ArgKind { errors.push(syn::Error::new( optional, format_args!( - "the {} cannot be optional (instead, remove the argument entirely)", - special_kind + "the {special_kind} cannot be optional (instead, remove the argument entirely)" ), )); } @@ -251,8 +250,7 @@ impl ExportMethod { errors.push(syn::Error::new( arg.span(), format_args!( - "required parameters must precede all optional ones (an optional parameter is defined at #{})", - idx, + "required parameters must precede all optional ones (an optional parameter is defined at #{idx})", ) )); } @@ -261,8 +259,7 @@ impl ExportMethod { errors.push(syn::Error::new( arg.span(), format_args!( - "special parameters must precede all regular ones (a regular parameter is defined at #{})", - idx, + "special parameters must precede all regular ones (a regular parameter is defined at #{idx})", ) )); } else { @@ -279,9 +276,7 @@ impl ExportMethod { errors.push(syn::Error::new( arg.span(), format_args!( - "the special parameter {} must only be declared once (the same parameter is already defined at #{})", - kind, - idx, + "the special parameter {kind} must only be declared once (the same parameter is already defined at #{idx})", ) )); } @@ -534,10 +529,7 @@ fn impl_gdnative_expose(ast: ItemImpl) -> (ItemImpl, ClassMethodExport) { } else { errors.push(syn::Error::new( nested_meta.span(), - format!( - "unexpected value for `rpc`: {}", - value - ), + format!("unexpected value for `rpc`: {value}"), )); } } @@ -683,7 +675,7 @@ fn impl_gdnative_expose(ast: ItemImpl) -> (ItemImpl, ClassMethodExport) { .for_each(|(i, arg)| match arg { FnArg::Typed(cap) => match *cap.pat.clone() { Pat::Wild(_) => { - let name = format!("___unused_arg_{}", i); + let name = format!("___unused_arg_{i}"); cap.pat = Box::new(Pat::Ident(PatIdent { attrs: vec![], diff --git a/gdnative-derive/src/native_script/mod.rs b/gdnative-derive/src/native_script/mod.rs index dfa433a8c..9e7af3c12 100644 --- a/gdnative-derive/src/native_script/mod.rs +++ b/gdnative-derive/src/native_script/mod.rs @@ -167,7 +167,7 @@ pub(crate) fn derive_native_class(derive_input: &DeriveInput) -> Result Result { } else if let NestedMeta::Meta(Meta::Path(ref path)) = arg { attr_args_builder.add_path(path)?; } else { - let msg = format!("Unexpected argument: {:?}", arg); + let msg = format!("Unexpected argument: {arg:?}"); return Err(syn::Error::new(arg.span(), msg)); } } @@ -311,7 +311,7 @@ fn parse_derive_input(input: &DeriveInput) -> Result { .get_or_insert_with(|| PropertyAttrArgsBuilder::new(&field.ty)); } m => { - let msg = format!("Unexpected meta variant: {:?}", m); + let msg = format!("Unexpected meta variant: {m:?}"); return Err(syn::Error::new(m.span(), msg)); } } diff --git a/gdnative-derive/src/native_script/property_args.rs b/gdnative-derive/src/native_script/property_args.rs index 0c6e57c87..2903d2a08 100644 --- a/gdnative-derive/src/native_script/property_args.rs +++ b/gdnative-derive/src/native_script/property_args.rs @@ -53,16 +53,13 @@ impl PropertyAttrArgsBuilder { fn err_prop_already_set(span: Span, prop: &str, old: &T) -> syn::Error { syn::Error::new( span, - format!( - "there is already a '{}' attribute with value: {:?}", - prop, old, - ), + format!("there is already a '{prop}' attribute with value: {old:?}",), ) } // Error returned when the attr value is not a string literal (i.e. not `LitStr`) fn err_attr_not_a_string_literal(span: Span, attr: &str) -> syn::Error { - syn::Error::new(span, format!("'{}' value is not a string literal", attr)) + syn::Error::new(span, format!("'{attr}' value is not a string literal")) } /// Convert `Lit` to `LitStr` diff --git a/gdnative-derive/src/profiled.rs b/gdnative-derive/src/profiled.rs index ea2f7a8a0..32b7ce57c 100644 --- a/gdnative-derive/src/profiled.rs +++ b/gdnative-derive/src/profiled.rs @@ -47,7 +47,7 @@ impl<'a> Extend<&'a syn::NestedMeta> for ProfiledAttrArgsBuilder { if let Some(old) = self.tag.replace(string) { self.errors.push(syn::Error::new( pair.lit.span(), - format!("there is already a tag set: {:?}", old), + format!("there is already a tag set: {old:?}"), )); } } diff --git a/gdnative-derive/src/varargs.rs b/gdnative-derive/src/varargs.rs index cc095c03c..f2bfa58e8 100644 --- a/gdnative-derive/src/varargs.rs +++ b/gdnative-derive/src/varargs.rs @@ -77,7 +77,7 @@ pub(crate) fn derive_from_varargs(input: DeriveInput) -> Result>(); let req_var_names = required @@ -101,7 +101,7 @@ pub(crate) fn derive_from_varargs(input: DeriveInput) -> Result>(); let opt_var_names = optional @@ -122,9 +122,10 @@ pub(crate) fn derive_from_varargs(input: DeriveInput) -> Result>(); diff --git a/gdnative-derive/src/variant/attr.rs b/gdnative-derive/src/variant/attr.rs index 4120a5b3f..c7e9dc294 100644 --- a/gdnative-derive/src/variant/attr.rs +++ b/gdnative-derive/src/variant/attr.rs @@ -73,8 +73,7 @@ fn generate_error_with_docs(span: proc_macro2::Span, message: &str) -> syn::Erro syn::Error::new( span, format!( - "{}\n\texpecting #[variant(...)]. See documentation:\n\thttps://docs.rs/gdnative/0.9.0/gdnative/core_types/trait.ToVariant.html#field-attributes", - message + "{message}\n\texpecting #[variant(...)]. See documentation:\n\thttps://docs.rs/gdnative/0.9.0/gdnative/core_types/trait.ToVariant.html#field-attributes" ), ) } diff --git a/gdnative-derive/src/variant/attr/field.rs b/gdnative-derive/src/variant/attr/field.rs index aad491fb8..b1686021c 100644 --- a/gdnative-derive/src/variant/attr/field.rs +++ b/gdnative-derive/src/variant/attr/field.rs @@ -37,8 +37,7 @@ fn generate_error_with_docs(span: Span, message: &str) -> syn::Error { syn::Error::new( span, format!( - "{}\n\texpecting #[variant(...)]. See documentation:\n\thttps://docs.rs/gdnative/0.9.0/gdnative/core_types/trait.ToVariant.html#field-attributes", - message + "{message}\n\texpecting #[variant(...)]. See documentation:\n\thttps://docs.rs/gdnative/0.9.0/gdnative/core_types/trait.ToVariant.html#field-attributes" ), ) } @@ -124,7 +123,7 @@ impl FieldAttrBuilder { ); syn::Error::new( path.span(), - &format!("Found {}, expected one of:\n\t{}", path_token, VALID_KEYS), + format!("Found {path_token}, expected one of:\n\t{VALID_KEYS}"), ) })? .to_string(); @@ -178,7 +177,7 @@ impl FieldAttrBuilder { Err(syn::Error::new( path.span(), - format!("unknown argument, expected one of:\n\t{}", VALID_KEYS), + format!("unknown argument, expected one of:\n\t{VALID_KEYS}"), )) } } diff --git a/gdnative-derive/src/variant/attr/item.rs b/gdnative-derive/src/variant/attr/item.rs index 070d2b254..d63e791be 100644 --- a/gdnative-derive/src/variant/attr/item.rs +++ b/gdnative-derive/src/variant/attr/item.rs @@ -76,7 +76,7 @@ impl ItemAttrBuilder { ); syn::Error::new( path.span(), - &format!("Found {}, expected one of:\n\t{}", path_token, VALID_KEYS), + format!("Found {path_token}, expected one of:\n\t{VALID_KEYS}"), ) })? .to_string(); @@ -90,7 +90,7 @@ impl ItemAttrBuilder { Err(syn::Error::new( path.span(), - format!("unknown argument, expected one of:\n\t{}", VALID_KEYS), + format!("unknown argument, expected one of:\n\t{VALID_KEYS}"), )) } } diff --git a/gdnative-derive/src/variant/from.rs b/gdnative-derive/src/variant/from.rs index 3cd369409..5ecc65078 100644 --- a/gdnative-derive/src/variant/from.rs +++ b/gdnative-derive/src/variant/from.rs @@ -50,7 +50,7 @@ pub(crate) fn expand_from_variant(derive_data: DeriveData) -> Result = variants .iter() - .map(|(var_ident, _)| format!("{}", var_ident)) + .map(|(var_ident, _)| format!("{var_ident}")) .collect(); let var_ident_string_literals = var_ident_strings @@ -118,7 +118,7 @@ pub(crate) fn expand_from_variant(derive_data: DeriveData) -> Result = variants .iter() - .map(|(var_ident, _)| format!("{}", var_ident)) + .map(|(var_ident, _)| format!("{var_ident}")) .collect(); let var_ident_string_literals = var_ident_strings diff --git a/gdnative-derive/src/variant/mod.rs b/gdnative-derive/src/variant/mod.rs index 2dc9d7202..d69312349 100644 --- a/gdnative-derive/src/variant/mod.rs +++ b/gdnative-derive/src/variant/mod.rs @@ -64,7 +64,7 @@ fn improve_meta_error(err: syn::Error) -> syn::Error { } other => syn::Error::new( err.span(), - format!("{}, ie: #[variant(with = \"...\")]", other), + format!("{other}, ie: #[variant(with = \"...\")]"), ), } } diff --git a/gdnative-derive/src/variant/repr.rs b/gdnative-derive/src/variant/repr.rs index 32c1d41b0..007eb0996 100644 --- a/gdnative-derive/src/variant/repr.rs +++ b/gdnative-derive/src/variant/repr.rs @@ -113,7 +113,7 @@ impl VariantRepr { .iter() .enumerate() .map(|(n, f)| { - let ident = Ident::new(&format!("__field_{}", n), Span::call_site()); + let ident = Ident::new(&format!("__field_{n}"), Span::call_site()); let ty = f.ty.clone(); let attr = parse_attrs::(&f.attrs)?; Ok(Field { ident, ty, attr }) @@ -317,7 +317,7 @@ impl VariantRepr { let name_strings: Vec = non_skipped_idents .iter() - .map(|ident| format!("{}", ident)) + .map(|ident| format!("{ident}")) .collect(); let name_string_literals = diff --git a/gdnative-derive/src/variant/to.rs b/gdnative-derive/src/variant/to.rs index 3f656052d..0faa7abbd 100644 --- a/gdnative-derive/src/variant/to.rs +++ b/gdnative-derive/src/variant/to.rs @@ -53,7 +53,7 @@ pub(crate) fn expand_to_variant( .map(|(var_ident, var_repr)| { let destructure_pattern = var_repr.destructure_pattern(); let to_variant = var_repr.make_to_variant_expr(trait_kind)?; - let var_ident_string = format!("{}", var_ident); + let var_ident_string = format!("{var_ident}"); let var_ident_string_literal = Literal::string(&var_ident_string); let tokens = quote! { #ident::#var_ident #destructure_pattern => { @@ -84,7 +84,7 @@ pub(crate) fn expand_to_variant( return Err(syn::Error::new(var_ident.span(), "`str` representation can only be used for fieldless enums")); } - let var_ident_string = format!("{}", var_ident); + let var_ident_string = format!("{var_ident}"); let var_ident_string_literal = Literal::string(&var_ident_string); let tokens = quote! { #ident::#var_ident => { diff --git a/gdnative-sys/build.rs b/gdnative-sys/build.rs index 93bb51ca2..8072e03ee 100644 --- a/gdnative-sys/build.rs +++ b/gdnative-sys/build.rs @@ -2,7 +2,7 @@ use std::env; fn main() { let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - let api_json_file = format!("{}/godot_headers/gdnative_api.json", manifest_dir); + let api_json_file = format!("{manifest_dir}/godot_headers/gdnative_api.json"); let out_dir = env::var("OUT_DIR").unwrap(); header_binding::generate(&manifest_dir, &out_dir); @@ -11,7 +11,7 @@ fn main() { // Only re-run build.rs if the gdnative_api.json file has been updated. // Manually rebuilding the crate will ignore this. - println!("cargo:rerun-if-changed={}", api_json_file); + println!("cargo:rerun-if-changed={api_json_file}"); } mod header_binding { @@ -41,7 +41,7 @@ mod header_binding { .trim_end(); let suffix = "usr/include"; - let directory = format!("{}/{}", prefix, suffix); + let directory = format!("{prefix}/{suffix}"); Ok(directory) } @@ -93,18 +93,14 @@ mod header_binding { android_ndk_root = Some(Path::join(&android_ndk_folder, ndk_version)) } else { panic!( - "no available android ndk versions matches {}. Available versions: {:?}", - ndk_version, available_ndk_versions + "no available android ndk versions matches {ndk_version}. Available versions: {available_ndk_versions:?}" ) } } else { // No NDK version chosen, chose the most recent one and issue a warning println!("cargo:warning=Multiple android ndk versions have been detected."); println!("cargo:warning=You should chose one using ANDROID_NDK_VERSION environment variable to have reproducible builds."); - println!( - "cargo:warning=Available versions: {:?}", - available_ndk_versions - ); + println!("cargo:warning=Available versions: {available_ndk_versions:?}"); let ndk_version = available_ndk_versions .iter() @@ -113,10 +109,7 @@ mod header_binding { .max() .unwrap(); - println!( - "cargo:warning=Automatically chosen version: {} (latest)", - ndk_version - ); + println!("cargo:warning=Automatically chosen version: {ndk_version} (latest)"); android_ndk_root = Some(Path::join(&android_ndk_folder, ndk_version.to_string())); @@ -196,7 +189,7 @@ mod header_binding { .ignore_functions() .size_t_is_usize(true) .ctypes_prefix("libc") - .clang_arg(format!("-I{}/godot_headers", manifest_dir)); + .clang_arg(format!("-I{manifest_dir}/godot_headers")); let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); @@ -234,13 +227,13 @@ mod header_binding { "x86_64" => "_M_X64", "arm" => "_M_ARM", "aarch64" => "_M_ARM64", - _ => panic!("architecture {} not supported on Windows", target_arch), + _ => panic!("architecture {target_arch} not supported on Windows"), }; builder = builder .clang_arg("-fms-extensions") .clang_arg("-fmsc-version=1300") - .clang_arg(format!("-D{}=100", arch_macro)); + .clang_arg(format!("-D{arch_macro}=100")); } if target_os == "android" { @@ -457,7 +450,7 @@ mod api_wrapper { ("VIDEODECODER", 0, 1) => format_ident!("godot_gdnative_ext_videodecoder_api_struct"), ("NET", 3, 1) => format_ident!("godot_gdnative_ext_net_api_struct"), ("NET", maj, min) => format_ident!("godot_gdnative_ext_net_{}_{}_api_struct", maj, min), - api => panic!("Unknown API type and version: {:?}", api), + api => panic!("Unknown API type and version: {api:?}"), } } @@ -470,7 +463,7 @@ mod api_wrapper { "ARVR" => format_ident!("GDNATIVE_API_TYPES_GDNATIVE_EXT_ARVR"), "VIDEODECODER" => format_ident!("GDNATIVE_API_TYPES_GDNATIVE_EXT_VIDEODECODER"), "NET" => format_ident!("GDNATIVE_API_TYPES_GDNATIVE_EXT_NET"), - other => panic!("Unknown API type: {:?}", other), + other => panic!("Unknown API type: {other:?}"), } } @@ -482,10 +475,10 @@ mod api_wrapper { let from_json = from_json.as_ref(); let to = to.as_ref(); let api_json_file = std::fs::read_to_string(from_json) - .unwrap_or_else(|_| panic!("No such file: {:?}", from_json)); + .unwrap_or_else(|_| panic!("No such file: {from_json:?}")); eprintln!("{}", &api_json_file); let api_root: ApiRoot = miniserde::json::from_str(&api_json_file) - .unwrap_or_else(|_| panic!("Could not parse ({:?}) into ApiRoot", from_json)); + .unwrap_or_else(|_| panic!("Could not parse ({from_json:?}) into ApiRoot")); // Note: this code ensured that Godot 4 (which was back then GDNative 1.3) wasn't actually used. // Godot uses now GDExtension, so this no longer applies. In fact, different module APIs all have different versions. @@ -515,7 +508,7 @@ mod api_wrapper { }; let mut wrapper_file = File::create(to.join(file_name)) .unwrap_or_else(|_| panic!("Couldn't create output file: {:?}", to.join(file_name))); - write!(wrapper_file, "{}", wrapper).unwrap(); + write!(wrapper_file, "{wrapper}").unwrap(); } fn godot_api_functions(api: &ApiRoot) -> TokenStream { @@ -594,7 +587,7 @@ mod api_wrapper { (1, true) => quote!(*const ), (1, false) => quote!(*mut ), (2, true) => quote!(*mut *const ), - _ => panic!("Unknown C type (Too many pointers?): {:?}", c_type), + _ => panic!("Unknown C type (Too many pointers?): {c_type:?}"), }; let rust_type = match base_c_type { "void" => { diff --git a/impl/proc-macros/src/pool_array_element.rs b/impl/proc-macros/src/pool_array_element.rs index 772e9d5b5..f7a972f89 100644 --- a/impl/proc-macros/src/pool_array_element.rs +++ b/impl/proc-macros/src/pool_array_element.rs @@ -89,12 +89,12 @@ static METHODS: &[&str] = &[ ]; fn impl_fn_symbol(method: &str) -> Ident { - Ident::new(&format!("{}_fn", method), Span::call_site()) + Ident::new(&format!("{method}_fn"), Span::call_site()) } fn fn_symbol(godot_type: &str, method: &str) -> Ident { Ident::new( - &format!("godot_pool_{}_array_{}", godot_type, method), + &format!("godot_pool_{godot_type}_array_{method}"), Span::call_site(), ) } @@ -157,7 +157,7 @@ fn fn_ty(method: &str) -> Type { parse_quote!(unsafe extern "C" fn(*mut Self::SysWriteAccess, *mut Self::SysWriteAccess)) } "write_access_destroy" => parse_quote!(unsafe extern "C" fn(*mut Self::SysWriteAccess)), - _ => panic!("unknown method: {}", method), + _ => panic!("unknown method: {method}"), } } diff --git a/test/src/lib.rs b/test/src/lib.rs index 1137db5f0..9d13c6309 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -139,7 +139,7 @@ impl Foo { match what.as_str() { "int" => a.to_variant(), "float" => b.to_variant(), - _ => panic!("should be int or float, got {:?}", what), + _ => panic!("should be int or float, got {what:?}"), } } }