Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Jul 31, 2024
1 parent 3641c98 commit 4082b35
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 25 deletions.
10 changes: 2 additions & 8 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ fn function_call_concat(c: &mut Criterion) {
i.fetch_add(1, Ordering::Relaxed)
},
|i| {
assert_eq!(
concat.call::<LuaString>(("num:", i)).unwrap(),
format!("num:{i}")
);
assert_eq!(concat.call::<LuaString>(("num:", i)).unwrap(), format!("num:{i}"));
},
BatchSize::SmallInput,
);
Expand All @@ -220,10 +217,7 @@ fn function_call_lua_concat(c: &mut Criterion) {
i.fetch_add(1, Ordering::Relaxed)
},
|i| {
assert_eq!(
concat.call::<LuaString>(("num:", i)).unwrap(),
format!("num:{i}")
);
assert_eq!(concat.call::<LuaString>(("num:", i)).unwrap(), format!("num:{i}"));
},
BatchSize::SmallInput,
);
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/luau/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn lua_loader(lua: &Lua, modname: StdString) -> Result<Value> {
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);
Expand Down
1 change: 1 addition & 0 deletions src/state/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1187,7 +1187,7 @@ where
ffi::LUA_TNIL => None,
_ => {
self.index += 1;
Some(V::from_stack(-1, &lua))
Some(V::from_stack(-1, lua))
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/userdata/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Value>
{
pub(crate) fn check_meta_field(lua: &Lua, name: &str, value: impl IntoLua) -> Result<Value> {
let value = value.into_lua(lua)?;
if name == MetaMethod::Index || name == MetaMethod::NewIndex {
match value {
Expand Down
11 changes: 2 additions & 9 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,7 @@ fn test_pcall_xpcall() -> Result<()> {

assert_eq!(globals.get::<bool>("xpcall_statusr")?, false);
#[cfg(any(feature = "lua54", feature = "lua53", feature = "lua52", feature = "luajit"))]
assert_eq!(
globals.get::<std::string::String>("xpcall_error")?,
"testerror"
);
assert_eq!(globals.get::<std::string::String>("xpcall_error")?, "testerror");
#[cfg(feature = "lua51")]
assert!(globals
.get::<String>("xpcall_error")?
Expand Down Expand Up @@ -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::<Function>("test")?
.call::<()>(args)
.is_err());
assert!(lua.globals().get::<Function>("test")?.call::<()>(args).is_err());
Ok(())
}

Expand Down

0 comments on commit 4082b35

Please sign in to comment.