Skip to content

Commit

Permalink
Suppress Rust 1.77 dead_code false warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
khvzak committed Mar 23, 2024
1 parent 39afe4c commit a79840a
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ fn registry_value_create(c: &mut Criterion) {
}

fn userdata_create(c: &mut Criterion) {
struct UserData(i64);
struct UserData(#[allow(unused)] i64);
impl LuaUserData for UserData {}

let lua = Lua::new();
Expand All @@ -286,7 +286,7 @@ fn userdata_create(c: &mut Criterion) {
}

fn userdata_call_index(c: &mut Criterion) {
struct UserData(i64);
struct UserData(#[allow(unused)] i64);
impl LuaUserData for UserData {
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_meta_method(LuaMetaMethod::Index, move |_, _, key: LuaString| Ok(key));
Expand Down
4 changes: 2 additions & 2 deletions src/userdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ impl<'lua> Serialize for AnyUserData<'lua> {
/// A wrapper type for an immutably borrowed value from a `AnyUserData`.
///
/// It implements [`FromLua`] and can be used to receive a typed userdata from Lua.
pub struct UserDataRef<'lua, T: 'static>(AnyUserData<'lua>, Ref<'lua, T>);
pub struct UserDataRef<'lua, T: 'static>(#[allow(unused)] AnyUserData<'lua>, Ref<'lua, T>);

impl<'lua, T: 'static> Deref for UserDataRef<'lua, T> {
type Target = T;
Expand All @@ -1380,7 +1380,7 @@ impl<'lua, T: 'static> UserDataRef<'lua, T> {
/// A wrapper type for a mutably borrowed value from a `AnyUserData`.
///
/// It implements [`FromLua`] and can be used to receive a typed userdata from Lua.
pub struct UserDataRefMut<'lua, T: 'static>(AnyUserData<'lua>, RefMut<'lua, T>);
pub struct UserDataRefMut<'lua, T: 'static>(#[allow(unused)] AnyUserData<'lua>, RefMut<'lua, T>);

impl<'lua, T: 'static> Deref for UserDataRefMut<'lua, T> {
type Target = T;
Expand Down
2 changes: 1 addition & 1 deletion tests/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn test_gc_control() -> Result<()> {

assert_eq!(lua.gc_inc(200, 100, 13), GCMode::Incremental);

struct MyUserdata(Arc<()>);
struct MyUserdata(#[allow(unused)] Arc<()>);
impl UserData for MyUserdata {}

let rc = Arc::new(());
Expand Down
20 changes: 10 additions & 10 deletions tests/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,30 +155,30 @@ fn test_scope_userdata_functions() -> Result<()> {

impl<'a> UserData for MyUserData<'a> {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_meta_function(MetaMethod::Add, |lua, ()| {
methods.add_meta_method(MetaMethod::Add, |lua, this, ()| {
let globals = lua.globals();
globals.set("i", globals.get::<_, i64>("i")? + 1)?;
globals.set("i", globals.get::<_, i64>("i")? + this.0)?;
Ok(())
});
methods.add_meta_function(MetaMethod::Sub, |lua, ()| {
methods.add_meta_method(MetaMethod::Sub, |lua, this, ()| {
let globals = lua.globals();
globals.set("i", globals.get::<_, i64>("i")? + 1)?;
globals.set("i", globals.get::<_, i64>("i")? + this.0)?;
Ok(())
});
}
}

let lua = Lua::new();

let dummy = 0;
let dummy = 1;
let f = lua
.load(
r#"
i = 0
return function(u)
_ = u + u
_ = u - 1
_ = 1 + u
_ = u + 1
end
"#,
)
Expand Down Expand Up @@ -257,15 +257,15 @@ fn test_scope_userdata_mismatch() -> Result<()> {
fn test_scope_userdata_drop() -> Result<()> {
let lua = Lua::new();

struct MyUserData(Rc<()>);
struct MyUserData(#[allow(unused)] Rc<()>);

impl UserData for MyUserData {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_method("method", |_, _, ()| Ok(()));
}
}

struct MyUserDataArc(Arc<()>);
struct MyUserDataArc(#[allow(unused)] Arc<()>);

impl UserData for MyUserDataArc {}

Expand Down Expand Up @@ -315,7 +315,7 @@ fn test_scope_userdata_drop() -> Result<()> {
fn test_scope_nonstatic_userdata_drop() -> Result<()> {
let lua = Lua::new();

struct MyUserData<'a>(&'a Cell<i64>, Arc<()>);
struct MyUserData<'a>(&'a Cell<i64>, #[allow(unused)] Arc<()>);

impl<'a> UserData for MyUserData<'a> {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
Expand All @@ -326,7 +326,7 @@ fn test_scope_nonstatic_userdata_drop() -> Result<()> {
}
}

struct MyUserDataArc(Arc<()>);
struct MyUserDataArc(#[allow(unused)] Arc<()>);

impl UserData for MyUserDataArc {}

Expand Down
2 changes: 1 addition & 1 deletion tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn test_serialize_in_scope() -> LuaResult<()> {
Err(e) => panic!("expected destructed error, got {}", e),
}

struct MyUserDataRef<'a>(&'a ());
struct MyUserDataRef<'a>(#[allow(unused)] &'a ());

impl<'a> UserData for MyUserDataRef<'a> {}

Expand Down
2 changes: 1 addition & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ fn test_registry_value() -> Result<()> {

#[test]
fn test_drop_registry_value() -> Result<()> {
struct MyUserdata(Arc<()>);
struct MyUserdata(#[allow(unused)] Arc<()>);

impl UserData for MyUserdata {}

Expand Down
2 changes: 1 addition & 1 deletion tests/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn test_thread_reset() -> Result<()> {

let lua = Lua::new();

struct MyUserData(Arc<()>);
struct MyUserData(#[allow(unused)] Arc<()>);
impl UserData for MyUserData {}

let arc = Arc::new(());
Expand Down
2 changes: 1 addition & 1 deletion tests/userdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ fn test_userdata_take() -> Result<()> {

#[test]
fn test_userdata_destroy() -> Result<()> {
struct MyUserdata(Arc<()>);
struct MyUserdata(#[allow(unused)] Arc<()>);

impl UserData for MyUserdata {}

Expand Down

0 comments on commit a79840a

Please sign in to comment.