Compare commits

...

8 Commits

Author SHA1 Message Date
Alex Orlenko 386eb7a2b7 v0.7.1 2021-12-23 19:42:52 +00:00
Alex Orlenko 66c9c633b2 Generate traceback from level 0 (instead of 1)
Fixes #112
2021-12-23 17:53:20 +00:00
Alex Orlenko f1e357ce52 Hide (doc) into_static/from_static methods 2021-12-01 00:28:08 +00:00
Alex Orlenko be09a1fabf Update lifetimes for few functions in Lua 2021-11-30 23:14:08 +00:00
Alex Orlenko 30af045c6f Lift minimum Rust requirement to 1.53+ 2021-11-29 10:46:09 +00:00
Alex Orlenko e809640b7e Update CI (switch to ubuntu-20.04 and add luajit52) 2021-11-27 13:44:30 +00:00
Alex Orlenko cb3ef20ffc Update README (remove ref to benchmarks) 2021-11-27 13:44:09 +00:00
Alex Orlenko 3b6564c02a Update compile tests (messages) 2021-11-27 13:42:22 +00:00
12 changed files with 66 additions and 63 deletions
+16 -16
View File
@@ -7,11 +7,11 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
rust: [stable]
lua: [lua54, lua53, lua52, lua51, luajit]
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
@@ -31,7 +31,7 @@ jobs:
cargo build --features "${{ matrix.lua }},vendored,async,send,serialize,macros"
shell: bash
- name: Build ${{ matrix.lua }} pkg-config
if: ${{ matrix.os == 'ubuntu-18.04' && matrix.lua != 'lua54' }}
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.lua != 'lua54' }}
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends liblua5.3-dev liblua5.2-dev liblua5.1-0-dev libluajit-5.1-dev
@@ -56,7 +56,7 @@ jobs:
build_aarch64_cross_ubuntu:
name: Cross-compile to aarch64-unknown-linux-gnu
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: build
strategy:
matrix:
@@ -79,7 +79,7 @@ jobs:
build_armv7_cross_ubuntu:
name: Cross-compile to armv7-unknown-linux-gnueabihf
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
needs: build
strategy:
matrix:
@@ -106,11 +106,11 @@ jobs:
needs: build
strategy:
matrix:
os: [ubuntu-18.04, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
rust: [stable, nightly]
lua: [lua54, lua53, lua52, lua51, luajit]
lua: [lua54, lua53, lua52, lua51, luajit, luajit52]
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
@@ -129,8 +129,8 @@ jobs:
cargo test --features "${{ matrix.lua }},vendored"
cargo test --features "${{ matrix.lua }},vendored,async,send,serialize,macros"
shell: bash
- name: Run compile tests (macos lua53)
if: ${{ matrix.os == 'macos-latest' && matrix.lua == 'lua53' }}
- name: Run compile tests (macos lua54)
if: ${{ matrix.os == 'macos-latest' && matrix.lua == 'lua54' }}
run: |
TRYBUILD=overwrite cargo test --features "${{ matrix.lua }},vendored" -- --ignored
TRYBUILD=overwrite cargo test --features "${{ matrix.lua }},vendored,async,send,serialize,macros" -- --ignored
@@ -142,11 +142,11 @@ jobs:
needs: build
strategy:
matrix:
os: [ubuntu-18.04]
os: [ubuntu-20.04]
rust: [nightly]
lua: [lua54, lua53, lua52, lua51, luajit]
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
@@ -168,11 +168,11 @@ jobs:
needs: build
strategy:
matrix:
os: [ubuntu-18.04, macos-latest]
os: [ubuntu-20.04, macos-latest]
rust: [stable]
lua: [lua54, lua53, lua52, lua51, luajit]
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
@@ -213,7 +213,7 @@ jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
@@ -225,7 +225,7 @@ jobs:
clippy:
name: Clippy check
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
matrix:
lua: [lua54, lua53, lua52, lua51, luajit]
+5
View File
@@ -1,3 +1,8 @@
## v0.7.1
- Fixed traceback generation for errors (#112)
- `Lua::into_static/from_static` methods have been removed from the docs and are discouraged for use
## v0.7.0
- New "application data" api to store arbitrary objects inside Lua
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "mlua"
version = "0.7.0" # remember to update html_root_url and mlua_derive
version = "0.7.1" # remember to update html_root_url and mlua_derive
authors = ["Aleksandr Orlenko <zxteam@pm.me>", "kyren <catherine@chucklefish.org>"]
edition = "2018"
repository = "https://github.com/khvzak/mlua"
+3 -7
View File
@@ -9,7 +9,7 @@
[docs.rs]: https://docs.rs/mlua
[Coverage Status]: https://codecov.io/gh/khvzak/mlua/branch/master/graph/badge.svg?token=99339FS1CG
[codecov.io]: https://codecov.io/gh/khvzak/mlua
[MSRV]: https://img.shields.io/badge/rust-1.51+-brightgreen.svg?&logo=rust
[MSRV]: https://img.shields.io/badge/rust-1.53+-brightgreen.svg?&logo=rust
[Guided Tour](examples/guided_tour.rs)
@@ -20,11 +20,7 @@ Started as [rlua] fork, `mlua` supports Lua 5.4, 5.3, 5.2 and 5.1 including LuaJ
`mlua` tested on Windows/macOS/Linux including module mode in [GitHub Actions] on `x86_64` platform and cross-compilation to `aarch64` (other targets are also supported).
Check our [benchmark results](https://github.com/khvzak/script-bench-rs) for `mlua`, [rlua] and [hlua].
[GitHub Actions]: https://github.com/khvzak/mlua/actions
[rlua]: https://github.com/amethyst/rlua
[hlua]: https://github.com/tomaka/hlua
## Usage
@@ -103,7 +99,7 @@ Add to `Cargo.toml` :
``` toml
[dependencies]
mlua = { version = "0.6", features = ["lua54", "vendored"] }
mlua = { version = "0.7", features = ["lua54", "vendored"] }
```
`main.rs`
@@ -138,7 +134,7 @@ Add to `Cargo.toml` :
crate-type = ["cdylib"]
[dependencies]
mlua = { version = "0.6", features = ["lua54", "vendored", "module"] }
mlua = { version = "0.7", features = ["lua54", "vendored", "module"] }
```
`lib.rs` :
+1 -1
View File
@@ -72,7 +72,7 @@
//! [`serde::Deserialize`]: https://docs.serde.rs/serde/de/trait.Deserialize.html
// mlua types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/mlua/0.7.0")]
#![doc(html_root_url = "https://docs.rs/mlua/0.7.1")]
// Deny warnings inside doc tests / examples. When this isn't present, rustdoc doesn't show *any*
// warnings at all.
#![doc(test(attr(deny(warnings))))]
+5 -3
View File
@@ -689,6 +689,7 @@ impl Lua {
/// This `Lua` object can then be dropped which will properly release the allocated memory.
///
/// [`Lua::from_static`]: #method.from_static
#[doc(hidden)]
pub fn into_static(self) -> &'static Self {
Box::leak(Box::new(self))
}
@@ -697,6 +698,7 @@ impl Lua {
///
/// # Safety
/// This function is unsafe because improper use may lead to memory problems or undefined behavior.
#[doc(hidden)]
pub unsafe fn from_static(lua: &'static Lua) -> Self {
*Box::from_raw(lua as *const Lua as *mut Lua)
}
@@ -1441,7 +1443,7 @@ impl Lua {
/// Resets thread (coroutine) and returns to the cache for later use.
#[cfg(feature = "async")]
#[cfg(any(feature = "lua54", all(feature = "luajit", feature = "vendored")))]
pub(crate) fn recycle_thread<'lua>(&'lua self, thread: &mut Thread<'lua>) {
pub(crate) fn recycle_thread(&self, thread: &mut Thread) {
unsafe {
let extra = &mut *self.extra.get();
let thread_state = ffi::lua_tothread(extra.ref_thread, thread.0.index);
@@ -1986,7 +1988,7 @@ impl Lua {
}
// Pushes a LuaRef value onto the stack, uses 1 stack space, does not call checkstack
pub(crate) unsafe fn push_ref<'lua>(&'lua self, lref: &LuaRef<'lua>) {
pub(crate) unsafe fn push_ref(&self, lref: &LuaRef) {
assert!(
Arc::ptr_eq(&lref.lua.extra, &self.extra),
"Lua instance passed Value created from a different main Lua state"
@@ -2021,7 +2023,7 @@ impl Lua {
}
}
pub(crate) fn drop_ref<'lua>(&'lua self, lref: &mut LuaRef<'lua>) {
pub(crate) fn drop_ref(&self, lref: &LuaRef) {
unsafe {
let extra = &mut *self.extra.get();
ffi::lua_pushnil(extra.ref_thread);
+1 -1
View File
@@ -585,7 +585,7 @@ pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int {
if get_gc_userdata::<WrappedFailure>(state, -1).is_null() {
let s = ffi::luaL_tolstring(state, -1, ptr::null_mut());
if ffi::lua_checkstack(state, ffi::LUA_TRACEBACK_STACK) != 0 {
ffi::luaL_traceback(state, state, s, 1);
ffi::luaL_traceback(state, state, s, 0);
ffi::lua_remove(state, -2);
}
}
+3 -3
View File
@@ -1,5 +1,5 @@
error[E0373]: closure may outlive the current function, but it borrows `test`, which is owned by the current function
--> $DIR/function_borrow.rs:9:33
--> tests/compile/function_borrow.rs:9:33
|
9 | let _ = lua.create_function(|_, ()| -> Result<i32> {
| ^^^^^^^^^^^^^^^^^^^^^^ may outlive borrowed value `test`
@@ -7,7 +7,7 @@ error[E0373]: closure may outlive the current function, but it borrows `test`, w
| ------ `test` is borrowed here
|
note: function requires argument type to outlive `'static`
--> $DIR/function_borrow.rs:9:13
--> tests/compile/function_borrow.rs:9:13
|
9 | let _ = lua.create_function(|_, ()| -> Result<i32> {
| _____________^
@@ -17,4 +17,4 @@ note: function requires argument type to outlive `'static`
help: to force the closure to take ownership of `test` (and any other referenced variables), use the `move` keyword
|
9 | let _ = lua.create_function(move |_, ()| -> Result<i32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ++++
+12 -12
View File
@@ -1,31 +1,26 @@
error[E0277]: the type `UnsafeCell<()>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> $DIR/lua_norefunwindsafe.rs:7:5
--> tests/compile/lua_norefunwindsafe.rs:7:5
|
7 | catch_unwind(|| lua.create_table().unwrap());
| ^^^^^^^^^^^^ `UnsafeCell<()>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
|
::: $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ---------- required by this bound in `catch_unwind`
|
= help: within `Lua`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<()>`
= note: required because it appears within the type `PhantomData<UnsafeCell<()>>`
= note: required because it appears within the type `Lua`
= note: required because of the requirements on the impl of `UnwindSafe` for `&Lua`
= note: required because it appears within the type `[closure@$DIR/tests/compile/lua_norefunwindsafe.rs:7:18: 7:48]`
note: required by a bound in `catch_unwind`
--> $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ^^^^^^^^^^ required by this bound in `catch_unwind`
error[E0277]: the type `UnsafeCell<mlua::lua::ExtraData>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> $DIR/lua_norefunwindsafe.rs:7:5
--> tests/compile/lua_norefunwindsafe.rs:7:5
|
7 | catch_unwind(|| lua.create_table().unwrap());
| ^^^^^^^^^^^^ `UnsafeCell<mlua::lua::ExtraData>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
|
::: $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ---------- required by this bound in `catch_unwind`
|
= help: within `Lua`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<mlua::lua::ExtraData>`
= note: required because it appears within the type `alloc::sync::ArcInner<UnsafeCell<mlua::lua::ExtraData>>`
= note: required because it appears within the type `PhantomData<alloc::sync::ArcInner<UnsafeCell<mlua::lua::ExtraData>>>`
@@ -33,3 +28,8 @@ error[E0277]: the type `UnsafeCell<mlua::lua::ExtraData>` may contain interior m
= note: required because it appears within the type `Lua`
= note: required because of the requirements on the impl of `UnwindSafe` for `&Lua`
= note: required because it appears within the type `[closure@$DIR/tests/compile/lua_norefunwindsafe.rs:7:18: 7:48]`
note: required by a bound in `catch_unwind`
--> $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ^^^^^^^^^^ required by this bound in `catch_unwind`
+12 -12
View File
@@ -1,14 +1,9 @@
error[E0277]: the type `UnsafeCell<()>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> $DIR/ref_nounwindsafe.rs:8:5
--> tests/compile/ref_nounwindsafe.rs:8:5
|
8 | catch_unwind(move || table.set("a", "b").unwrap());
| ^^^^^^^^^^^^ `UnsafeCell<()>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
|
::: $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ---------- required by this bound in `catch_unwind`
|
= help: within `Lua`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<()>`
= note: required because it appears within the type `PhantomData<UnsafeCell<()>>`
= note: required because it appears within the type `Lua`
@@ -16,18 +11,18 @@ error[E0277]: the type `UnsafeCell<()>` may contain interior mutability and a re
= note: required because it appears within the type `mlua::types::LuaRef<'_>`
= note: required because it appears within the type `LuaTable<'_>`
= note: required because it appears within the type `[closure@$DIR/tests/compile/ref_nounwindsafe.rs:8:18: 8:54]`
note: required by a bound in `catch_unwind`
--> $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ^^^^^^^^^^ required by this bound in `catch_unwind`
error[E0277]: the type `UnsafeCell<mlua::lua::ExtraData>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> $DIR/ref_nounwindsafe.rs:8:5
--> tests/compile/ref_nounwindsafe.rs:8:5
|
8 | catch_unwind(move || table.set("a", "b").unwrap());
| ^^^^^^^^^^^^ `UnsafeCell<mlua::lua::ExtraData>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
|
::: $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ---------- required by this bound in `catch_unwind`
|
= help: within `Lua`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<mlua::lua::ExtraData>`
= note: required because it appears within the type `alloc::sync::ArcInner<UnsafeCell<mlua::lua::ExtraData>>`
= note: required because it appears within the type `PhantomData<alloc::sync::ArcInner<UnsafeCell<mlua::lua::ExtraData>>>`
@@ -37,3 +32,8 @@ error[E0277]: the type `UnsafeCell<mlua::lua::ExtraData>` may contain interior m
= note: required because it appears within the type `mlua::types::LuaRef<'_>`
= note: required because it appears within the type `LuaTable<'_>`
= note: required because it appears within the type `[closure@$DIR/tests/compile/ref_nounwindsafe.rs:8:18: 8:54]`
note: required by a bound in `catch_unwind`
--> $RUST/std/src/panic.rs
|
| pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
| ^^^^^^^^^^ required by this bound in `catch_unwind`
+4 -4
View File
@@ -1,5 +1,5 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/scope_callback_inner.rs:7:17
--> tests/compile/scope_callback_inner.rs:7:17
|
5 | lua.scope(|scope| {
| -----
@@ -16,7 +16,7 @@ error[E0521]: borrowed data escapes outside of closure
| |______________^ `scope` escapes the closure body here
error[E0373]: closure may outlive the current function, but it borrows `inner`, which is owned by the current function
--> $DIR/scope_callback_inner.rs:8:34
--> tests/compile/scope_callback_inner.rs:8:34
|
5 | lua.scope(|scope| {
| ----- has type `&Scope<'_, '2>`
@@ -27,7 +27,7 @@ error[E0373]: closure may outlive the current function, but it borrows `inner`,
| ----- `inner` is borrowed here
|
note: function requires argument type to outlive `'2`
--> $DIR/scope_callback_inner.rs:7:17
--> tests/compile/scope_callback_inner.rs:7:17
|
7 | let f = scope
| _________________^
@@ -39,4 +39,4 @@ note: function requires argument type to outlive `'2`
help: to force the closure to take ownership of `inner` (and any other referenced variables), use the `move` keyword
|
8 | .create_function_mut(move |_, t: Table| {
| ^^^^^^^^^^^^^^^^^^
| ++++
+3 -3
View File
@@ -1,5 +1,5 @@
error[E0373]: closure may outlive the current function, but it borrows `test`, which is owned by the current function
--> $DIR/scope_invariance.rs:14:38
--> tests/compile/scope_invariance.rs:14:38
|
9 | lua.scope(|scope| {
| ----- has type `&Scope<'_, '1>`
@@ -10,7 +10,7 @@ error[E0373]: closure may outlive the current function, but it borrows `test`, w
| ---------- `test` is borrowed here
|
note: function requires argument type to outlive `'1`
--> $DIR/scope_invariance.rs:13:13
--> tests/compile/scope_invariance.rs:13:13
|
13 | / scope
14 | | .create_function_mut(|_, ()| {
@@ -22,4 +22,4 @@ note: function requires argument type to outlive `'1`
help: to force the closure to take ownership of `test` (and any other referenced variables), use the `move` keyword
|
14 | .create_function_mut(move |_, ()| {
| ^^^^^^^^^^^^
| ++++