From 42b8793dd02c9456d8327c2b9fd413b5d6b57c9c Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 9 Sep 2023 19:44:00 +0200 Subject: [PATCH] Fix(lua): Upgrade to mlua 9.1, which introduced braking changes --- Cargo.lock | 45 +++++++++++++++---- Cargo.toml | 2 +- .../lua_wrapper/rust_wrapper_functions/mod.rs | 4 +- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84d4b0d..dfe5701 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -316,11 +316,12 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.17" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", + "serde", ] [[package]] @@ -1615,21 +1616,30 @@ dependencies = [ [[package]] name = "mlua" -version = "0.8.10" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb37b0ba91f017aa7ca2b98ef99496827770cd635b4a932a6047c5b4bbe678e" +checksum = "6c3a7a7ff4481ec91b951a733390211a8ace1caba57266ccb5f4d4966704e560" dependencies = [ "bstr", - "cc", "erased-serde", - "futures-core", - "futures-task", "futures-util", + "mlua-sys", "num-traits", "once_cell", - "pkg-config", "rustc-hash", "serde", + "serde-value", +] + +[[package]] +name = "mlua-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ec8b54eddb76093069cce9eeffb4c7b3a1a0fe66962d7bd44c4867928149ca3" +dependencies = [ + "cc", + "cfg-if", + "pkg-config", ] [[package]] @@ -1734,6 +1744,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7940cf2ca942593318d07fcf2596cdca60a85c9e7fab408a5e21a4f9dcd40d87" +dependencies = [ + "num-traits", +] + [[package]] name = "parking_lot" version = "0.11.2" @@ -2268,6 +2287,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.12" diff --git a/Cargo.toml b/Cargo.toml index 53e0199..90b68f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ tokio = { version = "1.32", features = ["macros", "rt-multi-thread"] } # lua stuff language_macros = { path = "./language_macros" } -mlua = { version = "0.8.10", features = ["lua54", "async", "send", "serialize"] } +mlua = { version = "0.9.1", features = ["lua54", "async", "send", "serialize"] } once_cell = "1.18.0" # tui feature specific parts diff --git a/language_macros/src/generate/lua_wrapper/rust_wrapper_functions/mod.rs b/language_macros/src/generate/lua_wrapper/rust_wrapper_functions/mod.rs index 2557a5f..71d204b 100644 --- a/language_macros/src/generate/lua_wrapper/rust_wrapper_functions/mod.rs +++ b/language_macros/src/generate/lua_wrapper/rust_wrapper_functions/mod.rs @@ -196,7 +196,7 @@ fn get_function_body(field: &Field, has_input: bool, output_type: &Option) let does_function_expect_output = if output_type.is_some() { quote! { // We didn't receive output but expected output. Raise an error to notify the lua code - // about it + // about it. return Err(mlua::Error::ExternalError(std::sync::Arc::new( err ))); @@ -210,7 +210,7 @@ fn get_function_body(field: &Field, has_input: bool, output_type: &Option) quote! { let (callback_tx, callback_rx) = tokio::sync::oneshot::channel::(); - let tx: core::cell::Ref> = + let tx: mlua::AppDataRef> = lua.app_data_ref().expect("This should exist, it was set before"); (*tx)