From 4082b354fe7855b7738e21f9903a5665e9362bbd Mon Sep 17 00:00:00 2001 From: Alex Orlenko Date: Wed, 31 Jul 2024 23:51:20 +0100 Subject: [PATCH] clippy --- benches/benchmark.rs | 10 ++-------- src/error.rs | 4 ++-- src/luau/package.rs | 2 +- src/state/extra.rs | 1 + src/string.rs | 2 +- src/table.rs | 4 ++-- src/userdata/registry.rs | 3 +-- tests/tests.rs | 11 ++--------- 8 files changed, 12 insertions(+), 25 deletions(-) diff --git a/benches/benchmark.rs b/benches/benchmark.rs index 4a0f44bc..5c86bcb5 100644 --- a/benches/benchmark.rs +++ b/benches/benchmark.rs @@ -194,10 +194,7 @@ fn function_call_concat(c: &mut Criterion) { i.fetch_add(1, Ordering::Relaxed) }, |i| { - assert_eq!( - concat.call::(("num:", i)).unwrap(), - format!("num:{i}") - ); + assert_eq!(concat.call::(("num:", i)).unwrap(), format!("num:{i}")); }, BatchSize::SmallInput, ); @@ -220,10 +217,7 @@ fn function_call_lua_concat(c: &mut Criterion) { i.fetch_add(1, Ordering::Relaxed) }, |i| { - assert_eq!( - concat.call::(("num:", i)).unwrap(), - format!("num:{i}") - ); + assert_eq!(concat.call::(("num:", i)).unwrap(), format!("num:{i}")); }, BatchSize::SmallInput, ); diff --git a/src/error.rs b/src/error.rs index 2f4d7305..7c25f036 100644 --- a/src/error.rs +++ b/src/error.rs @@ -100,8 +100,8 @@ pub enum Error { }, /// [`Thread::resume`] was called on an unresumable coroutine. /// - /// A coroutine is unresumable if its main function has returned or if an error has occurred inside - /// the coroutine. Already running coroutines are also marked as unresumable. + /// A coroutine is unresumable if its main function has returned or if an error has occurred + /// inside the coroutine. Already running coroutines are also marked as unresumable. /// /// [`Thread::status`] can be used to check if the coroutine can be resumed without causing this /// error. diff --git a/src/luau/package.rs b/src/luau/package.rs index 94f1e12b..62252f9e 100644 --- a/src/luau/package.rs +++ b/src/luau/package.rs @@ -201,7 +201,7 @@ fn lua_loader(lua: &Lua, modname: StdString) -> Result { Ok(buf) => { return lua .load(&buf) - .set_name(&format!("={}", file_path.display())) + .set_name(format!("={}", file_path.display())) .set_mode(ChunkMode::Text) .into_function() .map(Value::Function); diff --git a/src/state/extra.rs b/src/state/extra.rs index 4b4fe4df..d3724e67 100644 --- a/src/state/extra.rs +++ b/src/state/extra.rs @@ -143,6 +143,7 @@ impl ExtraData { assert_eq!(ffi::lua_gettop(ref_thread), Self::ERROR_TRACEBACK_IDX); } + #[allow(clippy::arc_with_non_send_sync)] let extra = XRc::new(UnsafeCell::new(ExtraData { lua: MaybeUninit::uninit(), weak: MaybeUninit::uninit(), diff --git a/src/string.rs b/src/string.rs index 58f7dc08..1bdd4071 100644 --- a/src/string.rs +++ b/src/string.rs @@ -321,7 +321,7 @@ impl<'a> IntoIterator for BorrowedBytes<'a> { type IntoIter = slice::Iter<'a, u8>; fn into_iter(self) -> Self::IntoIter { - self.0.into_iter() + self.0.iter() } } diff --git a/src/table.rs b/src/table.rs index 8dfdf5f2..e74ffbe5 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1134,7 +1134,7 @@ where Ok(Some(( key.clone(), K::from_lua(key, lua.lua())?, - V::from_stack(-1, &lua)?, + V::from_stack(-1, lua)?, ))) } else { Ok(None) @@ -1187,7 +1187,7 @@ where ffi::LUA_TNIL => None, _ => { self.index += 1; - Some(V::from_stack(-1, &lua)) + Some(V::from_stack(-1, lua)) } } } diff --git a/src/userdata/registry.rs b/src/userdata/registry.rs index 9c7bf033..45d301af 100644 --- a/src/userdata/registry.rs +++ b/src/userdata/registry.rs @@ -267,8 +267,7 @@ impl<'a, T: 'static> UserDataRegistry<'a, T> { }) } - pub(crate) fn check_meta_field(lua: &Lua, name: &str, value: impl IntoLua) -> Result - { + pub(crate) fn check_meta_field(lua: &Lua, name: &str, value: impl IntoLua) -> Result { let value = value.into_lua(lua)?; if name == MetaMethod::Index || name == MetaMethod::NewIndex { match value { diff --git a/tests/tests.rs b/tests/tests.rs index e49f9367..36cc35fa 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -596,10 +596,7 @@ fn test_pcall_xpcall() -> Result<()> { assert_eq!(globals.get::("xpcall_statusr")?, false); #[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52", feature = "luajit"))] - assert_eq!( - globals.get::("xpcall_error")?, - "testerror" - ); + assert_eq!(globals.get::("xpcall_error")?, "testerror"); #[cfg(feature = "lua51")] assert!(globals .get::("xpcall_error")? @@ -910,11 +907,7 @@ fn test_too_many_arguments() -> Result<()> { let lua = Lua::new(); lua.load("function test(...) end").exec()?; let args = Variadic::from_iter(1..1000000); - assert!(lua - .globals() - .get::("test")? - .call::<()>(args) - .is_err()); + assert!(lua.globals().get::("test")?.call::<()>(args).is_err()); Ok(()) }