summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiyu Lin <linyiyu1992@gmail.com>2024-03-25 21:26:06 +0800
committerGitHub <noreply@github.com>2024-03-25 13:26:06 +0000
commitb62f2ee0f70dfa91f3a8f6ec5ae5be6c58b2f77f (patch)
treef717edeed55dd32b75246cb433638f023d881e6a
parent6e6c73e4c7312d4d5803c4d86e97850955ca51cb (diff)
downloadmlua-b62f2ee0f70dfa91f3a8f6ec5ae5be6c58b2f77f.zip
chore: make clippy happy (#388)
Co-authored-by: hzlinyiyu <hzlinyiyu@corp.netease.com>
-rw-r--r--mlua-sys/src/lua51/compat.rs1
-rw-r--r--mlua-sys/src/lua52/compat.rs1
-rw-r--r--mlua_derive/src/token.rs1
-rw-r--r--src/conversion.rs16
-rw-r--r--src/luau/package.rs1
-rw-r--r--src/multi.rs1
-rw-r--r--src/serde/de.rs5
-rw-r--r--src/serde/ser.rs4
-rw-r--r--src/value.rs10
9 files changed, 18 insertions, 22 deletions
diff --git a/mlua-sys/src/lua51/compat.rs b/mlua-sys/src/lua51/compat.rs
index 5216d33..890ba3b 100644
--- a/mlua-sys/src/lua51/compat.rs
+++ b/mlua-sys/src/lua51/compat.rs
@@ -2,7 +2,6 @@
//!
//! Based on github.com/keplerproject/lua-compat-5.3
-use std::convert::TryInto;
use std::mem;
use std::os::raw::{c_char, c_int, c_void};
use std::ptr;
diff --git a/mlua-sys/src/lua52/compat.rs b/mlua-sys/src/lua52/compat.rs
index 9a75a01..49dcc7b 100644
--- a/mlua-sys/src/lua52/compat.rs
+++ b/mlua-sys/src/lua52/compat.rs
@@ -2,7 +2,6 @@
//!
//! Based on github.com/keplerproject/lua-compat-5.3
-use std::convert::TryInto;
use std::os::raw::{c_char, c_int, c_void};
use std::ptr;
diff --git a/mlua_derive/src/token.rs b/mlua_derive/src/token.rs
index 1bfa6b1..9ef10d7 100644
--- a/mlua_derive/src/token.rs
+++ b/mlua_derive/src/token.rs
@@ -1,7 +1,6 @@
use std::{
cmp::{Eq, PartialEq},
fmt::{self, Display, Formatter},
- iter::IntoIterator,
vec::IntoIter,
};
diff --git a/src/conversion.rs b/src/conversion.rs
index dc076f9..2c57269 100644
--- a/src/conversion.rs
+++ b/src/conversion.rs
@@ -1,6 +1,5 @@
use std::borrow::Cow;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
-use std::convert::TryInto;
use std::ffi::{CStr, CString};
use std::hash::{BuildHasher, Hash};
use std::os::raw::c_int;
@@ -67,7 +66,8 @@ impl<'lua> IntoLua<'lua> for &String<'lua> {
#[inline]
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
- Ok(lua.push_ref(&self.0))
+ lua.push_ref(&self.0);
+ Ok(())
}
}
@@ -131,7 +131,8 @@ impl<'lua> IntoLua<'lua> for &Table<'lua> {
#[inline]
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
- Ok(lua.push_ref(&self.0))
+ lua.push_ref(&self.0);
+ Ok(())
}
}
@@ -196,7 +197,8 @@ impl<'lua> IntoLua<'lua> for &Function<'lua> {
#[inline]
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
- Ok(lua.push_ref(&self.0))
+ lua.push_ref(&self.0);
+ Ok(())
}
}
@@ -261,7 +263,8 @@ impl<'lua> IntoLua<'lua> for &Thread<'lua> {
#[inline]
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
- Ok(lua.push_ref(&self.0))
+ lua.push_ref(&self.0);
+ Ok(())
}
}
@@ -326,7 +329,8 @@ impl<'lua> IntoLua<'lua> for &AnyUserData<'lua> {
#[inline]
unsafe fn push_into_stack(self, lua: &'lua Lua) -> Result<()> {
- Ok(lua.push_ref(&self.0))
+ lua.push_ref(&self.0);
+ Ok(())
}
}
diff --git a/src/luau/package.rs b/src/luau/package.rs
index ed69b5d..6a3e0c1 100644
--- a/src/luau/package.rs
+++ b/src/luau/package.rs
@@ -103,6 +103,7 @@ pub(crate) fn register_package_module(lua: &Lua) -> Result<()> {
Ok(())
}
+#[allow(unused_variables)]
pub(crate) fn disable_dylibs(lua: &Lua) {
// Presence of `LoadedDylibs` in app data is used as a flag
// to check whether binary modules are enabled
diff --git a/src/multi.rs b/src/multi.rs
index eaa1107..f9b9a93 100644
--- a/src/multi.rs
+++ b/src/multi.rs
@@ -1,4 +1,3 @@
-use std::iter::FromIterator;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_int;
use std::result::Result as StdResult;
diff --git a/src/serde/de.rs b/src/serde/de.rs
index 12f329b..5d3512c 100644
--- a/src/serde/de.rs
+++ b/src/serde/de.rs
@@ -1,5 +1,4 @@
use std::cell::RefCell;
-use std::convert::TryInto;
use std::os::raw::c_void;
use std::rc::Rc;
use std::result::Result as StdResult;
@@ -134,9 +133,7 @@ impl<'lua, 'de> serde::Deserializer<'de> for Deserializer<'lua> {
Value::Nil => visitor.visit_unit(),
Value::Boolean(b) => visitor.visit_bool(b),
#[allow(clippy::useless_conversion)]
- Value::Integer(i) => {
- visitor.visit_i64(i.try_into().expect("cannot convert lua_Integer to i64"))
- }
+ Value::Integer(i) => visitor.visit_i64(i.into()),
#[allow(clippy::useless_conversion)]
Value::Number(n) => visitor.visit_f64(n.into()),
#[cfg(feature = "luau")]
diff --git a/src/serde/ser.rs b/src/serde/ser.rs
index 9449ccb..3401693 100644
--- a/src/serde/ser.rs
+++ b/src/serde/ser.rs
@@ -535,7 +535,7 @@ impl<'lua> ser::SerializeStruct for SerializeStruct<'lua> {
Some(table @ Value::Table(_)) => Ok(table),
Some(value) if self.options.detect_serde_json_arbitrary_precision => {
let number_s = value.as_str().expect("not an arbitrary precision number");
- if number_s.contains(&['.', 'e', 'E']) {
+ if number_s.contains(['.', 'e', 'E']) {
if let Ok(number) = number_s.parse().map(Value::Number) {
return Ok(number);
}
@@ -544,7 +544,7 @@ impl<'lua> ser::SerializeStruct for SerializeStruct<'lua> {
.parse()
.map(Value::Integer)
.or_else(|_| number_s.parse().map(Value::Number))
- .unwrap_or_else(|_| value))
+ .unwrap_or(value))
}
_ => unreachable!(),
}
diff --git a/src/value.rs b/src/value.rs
index 9ec4e04..ed80f27 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -1,7 +1,7 @@
use std::borrow::Cow;
use std::cmp::Ordering;
use std::collections::HashSet;
-use std::iter::{self, FromIterator};
+use std::iter;
use std::ops::Index;
use std::os::raw::{c_int, c_void};
use std::string::String as StdString;
@@ -15,7 +15,7 @@ use {
crate::table::SerializableTable,
rustc_hash::FxHashSet,
serde::ser::{self, Serialize, Serializer},
- std::{cell::RefCell, convert::TryInto, rc::Rc, result::Result as StdResult},
+ std::{cell::RefCell, rc::Rc, result::Result as StdResult},
};
use crate::error::{Error, Result};
@@ -252,8 +252,7 @@ impl<'lua> Value<'lua> {
/// If the value is a Lua [`Integer`], try to convert it to `i64` or return `None` otherwise.
#[inline]
pub fn as_i64(&self) -> Option<i64> {
- #[allow(clippy::useless_conversion)]
- self.as_integer().and_then(|i| i64::try_from(i).ok())
+ self.as_integer().map(i64::from)
}
/// Cast the value to `u64`.
@@ -659,8 +658,7 @@ impl<'a, 'lua> Serialize for SerializableValue<'a, 'lua> {
Value::Nil => serializer.serialize_unit(),
Value::Boolean(b) => serializer.serialize_bool(*b),
#[allow(clippy::useless_conversion)]
- Value::Integer(i) => serializer
- .serialize_i64((*i).try_into().expect("cannot convert Lua Integer to i64")),
+ Value::Integer(i) => serializer.serialize_i64((*i).into()),
Value::Number(n) => serializer.serialize_f64(*n),
#[cfg(feature = "luau")]
Value::Vector(v) => v.serialize(serializer),