diff --git a/tests/compile/async_any_userdata_method.stderr b/tests/compile/async_any_userdata_method.stderr index 970feef..3e01c45 100644 --- a/tests/compile/async_any_userdata_method.stderr +++ b/tests/compile/async_any_userdata_method.stderr @@ -1,15 +1,19 @@ error[E0596]: cannot borrow `s` as mutable, as it is a captured variable in a `Fn` closure --> tests/compile/async_any_userdata_method.rs:9:49 | -9 | reg.add_async_method("t", |_, this, ()| async { - | ^^^^^ cannot borrow as mutable + 8 | let mut s = &s; + | ----- `s` declared here, outside the closure + 9 | reg.add_async_method("t", |_, this, ()| async { + | ------------- ^^^^^ cannot borrow as mutable + | | + | in this closure 10 | s = &*this; | - mutable borrow occurs due to use of `s` in closure error[E0373]: async block may outlive the current function, but it borrows `this`, which is owned by the current function --> tests/compile/async_any_userdata_method.rs:9:49 | -9 | reg.add_async_method("t", |_, this, ()| async { + 9 | reg.add_async_method("t", |_, this, ()| async { | ^^^^^ may outlive borrowed value `this` 10 | s = &*this; | ---- `this` is borrowed here @@ -17,7 +21,7 @@ error[E0373]: async block may outlive the current function, but it borrows `this note: async block is returned here --> tests/compile/async_any_userdata_method.rs:9:49 | -9 | reg.add_async_method("t", |_, this, ()| async { + 9 | reg.add_async_method("t", |_, this, ()| async { | _________________________________________________^ 10 | | s = &*this; 11 | | Ok(()) @@ -25,13 +29,13 @@ note: async block is returned here | |_________^ help: to force the async block to take ownership of `this` (and any other referenced variables), use the `move` keyword | -9 | reg.add_async_method("t", |_, this, ()| async move { + 9 | reg.add_async_method("t", |_, this, ()| async move { | ++++ error: lifetime may not live long enough --> tests/compile/async_any_userdata_method.rs:9:49 | -9 | reg.add_async_method("t", |_, this, ()| async { + 9 | reg.add_async_method("t", |_, this, ()| async { | ___________________________________-------------_^ | | | | | | | return type of closure `{async block@$DIR/tests/compile/async_any_userdata_method.rs:9:49: 9:54}` contains a lifetime `'2` @@ -46,22 +50,28 @@ error: lifetime may not live long enough error[E0597]: `s` does not live long enough --> tests/compile/async_any_userdata_method.rs:8:21 | -7 | let s = String::new(); + 7 | let s = String::new(); | - binding `s` declared here -8 | let mut s = &s; + 8 | let mut s = &s; | ^^ borrowed value does not live long enough -9 | / reg.add_async_method("t", |_, this, ()| async { + 9 | / reg.add_async_method("t", |_, this, ()| async { 10 | | s = &*this; 11 | | Ok(()) 12 | | }); | |__________- argument requires that `s` is borrowed for `'static` 13 | }) | - `s` dropped here while still borrowed + | +note: requirement that the value outlives `'static` introduced here + --> src/userdata.rs + | + | M: Fn(Lua, UserDataRef, A) -> MR + MaybeSend + 'static, + | ^^^^^^^ error[E0373]: closure may outlive the current function, but it borrows `s`, which is owned by the current function --> tests/compile/async_any_userdata_method.rs:9:35 | -9 | reg.add_async_method("t", |_, this, ()| async { + 9 | reg.add_async_method("t", |_, this, ()| async { | ^^^^^^^^^^^^^ may outlive borrowed value `s` 10 | s = &*this; | - `s` is borrowed here @@ -69,12 +79,12 @@ error[E0373]: closure may outlive the current function, but it borrows `s`, whic note: function requires argument type to outlive `'static` --> tests/compile/async_any_userdata_method.rs:9:9 | -9 | / reg.add_async_method("t", |_, this, ()| async { + 9 | / reg.add_async_method("t", |_, this, ()| async { 10 | | s = &*this; 11 | | Ok(()) 12 | | }); | |__________^ help: to force the closure to take ownership of `s` (and any other referenced variables), use the `move` keyword | -9 | reg.add_async_method("t", move |_, this, ()| async { + 9 | reg.add_async_method("t", move |_, this, ()| async { | ++++ diff --git a/tests/compile/async_nonstatic_userdata.stderr b/tests/compile/async_nonstatic_userdata.stderr index 368e9f3..18412e4 100644 --- a/tests/compile/async_nonstatic_userdata.stderr +++ b/tests/compile/async_nonstatic_userdata.stderr @@ -1,10 +1,10 @@ error: lifetime may not live long enough --> tests/compile/async_nonstatic_userdata.rs:9:13 | -7 | impl UserData for MyUserData<'_> { + 7 | impl UserData for MyUserData<'_> { | -- lifetime `'1` appears in the `impl`'s self type -8 | fn add_methods>(methods: &mut M) { -9 | / methods.add_async_method("print", |_, data, ()| async move { + 8 | fn add_methods>(methods: &mut M) { + 9 | / methods.add_async_method("print", |_, data, ()| async move { 10 | | println!("{}", data.0); 11 | | Ok(()) 12 | | }); diff --git a/tests/compile/lua_norefunwindsafe.stderr b/tests/compile/lua_norefunwindsafe.stderr index a482a8d..814ae6b 100644 --- a/tests/compile/lua_norefunwindsafe.stderr +++ b/tests/compile/lua_norefunwindsafe.stderr @@ -1,28 +1,32 @@ -error[E0277]: the type `UnsafeCell<*mut lua_State>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary +error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary --> tests/compile/lua_norefunwindsafe.rs:7:18 | 7 | catch_unwind(|| lua.create_table().unwrap()); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<*mut lua_State>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary | | | required by a bound introduced by this call | - = help: within `mlua::types::sync::inner::ReentrantMutex`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<*mut lua_State>` -note: required because it appears within the type `Cell<*mut lua_State>` - --> $RUST/core/src/cell.rs + = help: within `Lua`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell` +note: required because it appears within the type `lock_api::remutex::ReentrantMutex` + --> $CARGO/lock_api-$VERSION/src/remutex.rs | - | pub struct Cell { - | ^^^^ -note: required because it appears within the type `mlua::state::raw::RawLua` - --> src/state/raw.rs + | pub struct ReentrantMutex { + | ^^^^^^^^^^^^^^ +note: required because it appears within the type `alloc::sync::ArcInner>` + --> $RUST/alloc/src/sync.rs | - | pub struct RawLua { - | ^^^^^^ -note: required because it appears within the type `mlua::types::sync::inner::ReentrantMutex` - --> src/types/sync.rs + | struct ArcInner { + | ^^^^^^^^ +note: required because it appears within the type `PhantomData>>` + --> $RUST/core/src/marker.rs | - | pub(crate) struct ReentrantMutex(T); - | ^^^^^^^^^^^^^^ - = note: required for `Rc>` to implement `RefUnwindSafe` + | pub struct PhantomData; + | ^^^^^^^^^^^ +note: required because it appears within the type `Arc>` + --> $RUST/alloc/src/sync.rs + | + | pub struct Arc< + | ^^^ note: required because it appears within the type `Lua` --> src/state.rs | @@ -40,27 +44,45 @@ note: required by a bound in `std::panic::catch_unwind` | pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { | ^^^^^^^^^^ required by this bound in `catch_unwind` -error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary +error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary --> tests/compile/lua_norefunwindsafe.rs:7:18 | 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 + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary | | | required by a bound introduced by this call | - = help: the trait `RefUnwindSafe` is not implemented for `UnsafeCell` - = note: required for `Rc>` to implement `RefUnwindSafe` -note: required because it appears within the type `mlua::state::raw::RawLua` - --> src/state/raw.rs + = help: within `Lua`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell` +note: required because it appears within the type `Cell` + --> $RUST/core/src/cell.rs | - | pub struct RawLua { - | ^^^^^^ -note: required because it appears within the type `mlua::types::sync::inner::ReentrantMutex` - --> src/types/sync.rs + | pub struct Cell { + | ^^^^ +note: required because it appears within the type `lock_api::remutex::RawReentrantMutex` + --> $CARGO/lock_api-$VERSION/src/remutex.rs | - | pub(crate) struct ReentrantMutex(T); - | ^^^^^^^^^^^^^^ - = note: required for `Rc>` to implement `RefUnwindSafe` + | pub struct RawReentrantMutex { + | ^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `lock_api::remutex::ReentrantMutex` + --> $CARGO/lock_api-$VERSION/src/remutex.rs + | + | pub struct ReentrantMutex { + | ^^^^^^^^^^^^^^ +note: required because it appears within the type `alloc::sync::ArcInner>` + --> $RUST/alloc/src/sync.rs + | + | struct ArcInner { + | ^^^^^^^^ +note: required because it appears within the type `PhantomData>>` + --> $RUST/core/src/marker.rs + | + | pub struct PhantomData; + | ^^^^^^^^^^^ +note: required because it appears within the type `Arc>` + --> $RUST/alloc/src/sync.rs + | + | pub struct Arc< + | ^^^ note: required because it appears within the type `Lua` --> src/state.rs | diff --git a/tests/compile/ref_nounwindsafe.stderr b/tests/compile/ref_nounwindsafe.stderr index 048f9d3..4903255 100644 --- a/tests/compile/ref_nounwindsafe.stderr +++ b/tests/compile/ref_nounwindsafe.stderr @@ -1,143 +1,86 @@ -error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary +error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary --> tests/compile/ref_nounwindsafe.rs:8:18 | 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 + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary | | | required by a bound introduced by this call | - = help: within `rc::RcInner>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell` + = help: within `alloc::sync::ArcInner>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell` +note: required because it appears within the type `lock_api::remutex::ReentrantMutex` + --> $CARGO/lock_api-$VERSION/src/remutex.rs + | + | pub struct ReentrantMutex { + | ^^^^^^^^^^^^^^ +note: required because it appears within the type `alloc::sync::ArcInner>` + --> $RUST/alloc/src/sync.rs + | + | struct ArcInner { + | ^^^^^^^^ + = note: required for `NonNull>>` to implement `UnwindSafe` +note: required because it appears within the type `std::sync::Weak>` + --> $RUST/alloc/src/sync.rs + | + | pub struct Weak< + | ^^^^ +note: required because it appears within the type `WeakLua` + --> src/state.rs + | + | pub struct WeakLua(XWeak>); + | ^^^^^^^ +note: required because it appears within the type `mlua::types::value_ref::ValueRef` + --> src/types/value_ref.rs + | + | pub struct ValueRef { + | ^^^^^^^^ +note: required because it appears within the type `LuaTable` + --> src/table.rs + | + | pub struct Table(pub(crate) ValueRef); + | ^^^^^ +note: required because it's used within this closure + --> tests/compile/ref_nounwindsafe.rs:8:18 + | +8 | catch_unwind(move || table.set("a", "b").unwrap()); + | ^^^^^^^ +note: required by a bound in `std::panic::catch_unwind` + --> $RUST/std/src/panic.rs + | + | pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { + | ^^^^^^^^^^ required by this bound in `catch_unwind` + +error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary + --> tests/compile/ref_nounwindsafe.rs:8:18 + | +8 | catch_unwind(move || table.set("a", "b").unwrap()); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell` may contain interior mutability and a reference may not be safely transferable across a catch_unwind boundary + | | + | required by a bound introduced by this call + | + = help: within `alloc::sync::ArcInner>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell` note: required because it appears within the type `Cell` --> $RUST/core/src/cell.rs | | pub struct Cell { | ^^^^ -note: required because it appears within the type `rc::RcInner>` - --> $RUST/alloc/src/rc.rs +note: required because it appears within the type `lock_api::remutex::RawReentrantMutex` + --> $CARGO/lock_api-$VERSION/src/remutex.rs | - | struct RcInner { - | ^^^^^^^ - = note: required for `NonNull>>` to implement `UnwindSafe` -note: required because it appears within the type `std::rc::Weak>` - --> $RUST/alloc/src/rc.rs - | - | pub struct Weak< - | ^^^^ -note: required because it appears within the type `WeakLua` - --> src/state.rs - | - | pub struct WeakLua(XWeak>); - | ^^^^^^^ -note: required because it appears within the type `mlua::types::value_ref::ValueRef` - --> src/types/value_ref.rs - | - | pub struct ValueRef { - | ^^^^^^^^ -note: required because it appears within the type `LuaTable` - --> src/table.rs - | - | pub struct Table(pub(crate) ValueRef); - | ^^^^^ -note: required because it's used within this closure - --> tests/compile/ref_nounwindsafe.rs:8:18 - | -8 | catch_unwind(move || table.set("a", "b").unwrap()); - | ^^^^^^^ -note: required by a bound in `std::panic::catch_unwind` - --> $RUST/std/src/panic.rs - | - | pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { - | ^^^^^^^^^^ required by this bound in `catch_unwind` - -error[E0277]: the type `UnsafeCell<*mut lua_State>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - --> tests/compile/ref_nounwindsafe.rs:8:18 - | -8 | catch_unwind(move || table.set("a", "b").unwrap()); - | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<*mut lua_State>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - | | - | required by a bound introduced by this call - | - = help: within `rc::RcInner>`, the trait `RefUnwindSafe` is not implemented for `UnsafeCell<*mut lua_State>` -note: required because it appears within the type `Cell<*mut lua_State>` - --> $RUST/core/src/cell.rs - | - | pub struct Cell { - | ^^^^ -note: required because it appears within the type `mlua::state::raw::RawLua` - --> src/state/raw.rs - | - | pub struct RawLua { - | ^^^^^^ -note: required because it appears within the type `mlua::types::sync::inner::ReentrantMutex` - --> src/types/sync.rs - | - | pub(crate) struct ReentrantMutex(T); - | ^^^^^^^^^^^^^^ -note: required because it appears within the type `rc::RcInner>` - --> $RUST/alloc/src/rc.rs - | - | struct RcInner { - | ^^^^^^^ - = note: required for `NonNull>>` to implement `UnwindSafe` -note: required because it appears within the type `std::rc::Weak>` - --> $RUST/alloc/src/rc.rs - | - | pub struct Weak< - | ^^^^ -note: required because it appears within the type `WeakLua` - --> src/state.rs - | - | pub struct WeakLua(XWeak>); - | ^^^^^^^ -note: required because it appears within the type `mlua::types::value_ref::ValueRef` - --> src/types/value_ref.rs - | - | pub struct ValueRef { - | ^^^^^^^^ -note: required because it appears within the type `LuaTable` - --> src/table.rs - | - | pub struct Table(pub(crate) ValueRef); - | ^^^^^ -note: required because it's used within this closure - --> tests/compile/ref_nounwindsafe.rs:8:18 - | -8 | catch_unwind(move || table.set("a", "b").unwrap()); - | ^^^^^^^ -note: required by a bound in `std::panic::catch_unwind` - --> $RUST/std/src/panic.rs - | - | pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { - | ^^^^^^^^^^ required by this bound in `catch_unwind` - -error[E0277]: the type `UnsafeCell` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary - --> tests/compile/ref_nounwindsafe.rs:8:18 - | -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 - | | - | required by a bound introduced by this call - | - = help: the trait `RefUnwindSafe` is not implemented for `UnsafeCell` - = note: required for `Rc>` to implement `RefUnwindSafe` -note: required because it appears within the type `mlua::state::raw::RawLua` - --> src/state/raw.rs - | - | pub struct RawLua { - | ^^^^^^ -note: required because it appears within the type `mlua::types::sync::inner::ReentrantMutex` - --> src/types/sync.rs - | - | pub(crate) struct ReentrantMutex(T); - | ^^^^^^^^^^^^^^ -note: required because it appears within the type `rc::RcInner>` - --> $RUST/alloc/src/rc.rs - | - | struct RcInner { - | ^^^^^^^ - = note: required for `NonNull>>` to implement `UnwindSafe` -note: required because it appears within the type `std::rc::Weak>` - --> $RUST/alloc/src/rc.rs + | pub struct RawReentrantMutex { + | ^^^^^^^^^^^^^^^^^ +note: required because it appears within the type `lock_api::remutex::ReentrantMutex` + --> $CARGO/lock_api-$VERSION/src/remutex.rs + | + | pub struct ReentrantMutex { + | ^^^^^^^^^^^^^^ +note: required because it appears within the type `alloc::sync::ArcInner>` + --> $RUST/alloc/src/sync.rs + | + | struct ArcInner { + | ^^^^^^^^ + = note: required for `NonNull>>` to implement `UnwindSafe` +note: required because it appears within the type `std::sync::Weak>` + --> $RUST/alloc/src/sync.rs | | pub struct Weak< | ^^^^ diff --git a/tests/compile/scope_callback_capture.stderr b/tests/compile/scope_callback_capture.stderr index 94844dc..7fa3a5e 100644 --- a/tests/compile/scope_callback_capture.stderr +++ b/tests/compile/scope_callback_capture.stderr @@ -1,24 +1,24 @@ error[E0373]: closure may outlive the current function, but it borrows `inner`, which is owned by the current function --> tests/compile/scope_callback_capture.rs:7:43 | -5 | lua.scope(|scope| { + 5 | lua.scope(|scope| { | ----- has type `&'1 mlua::Scope<'1, '_>` -6 | let mut inner: Option = None; -7 | let f = scope.create_function_mut(|_, t: Table| { + 6 | let mut inner: Option
= None; + 7 | let f = scope.create_function_mut(|_, t: Table| { | ^^^^^^^^^^^^^ may outlive borrowed value `inner` -8 | inner = Some(t); + 8 | inner = Some(t); | ----- `inner` is borrowed here | note: function requires argument type to outlive `'1` --> tests/compile/scope_callback_capture.rs:7:17 | -7 | let f = scope.create_function_mut(|_, t: Table| { + 7 | let f = scope.create_function_mut(|_, t: Table| { | _________________^ -8 | | inner = Some(t); -9 | | Ok(()) + 8 | | inner = Some(t); + 9 | | Ok(()) 10 | | })?; | |__________^ help: to force the closure to take ownership of `inner` (and any other referenced variables), use the `move` keyword | -7 | let f = scope.create_function_mut(move |_, t: Table| { + 7 | let f = scope.create_function_mut(move |_, t: Table| { | ++++ diff --git a/tests/compile/scope_invariance.stderr b/tests/compile/scope_invariance.stderr index a3f218d..8bad0c1 100644 --- a/tests/compile/scope_invariance.stderr +++ b/tests/compile/scope_invariance.stderr @@ -1,7 +1,7 @@ error[E0373]: closure may outlive the current function, but it borrows `test.field`, which is owned by the current function --> tests/compile/scope_invariance.rs:13:39 | -9 | lua.scope(|scope| { + 9 | lua.scope(|scope| { | ----- has type `&'1 mlua::Scope<'1, '_>` ... 13 | scope.create_function_mut(|_, ()| { diff --git a/tests/compile/scope_mutable_aliasing.stderr b/tests/compile/scope_mutable_aliasing.stderr index e6e57f1..d772466 100644 --- a/tests/compile/scope_mutable_aliasing.stderr +++ b/tests/compile/scope_mutable_aliasing.stderr @@ -10,3 +10,9 @@ error[E0499]: cannot borrow `i` as mutable more than once at a time | argument requires that `i` is borrowed for `'1` 12 | let _b = scope.create_userdata(MyUserData(&mut i)).unwrap(); | ^^^^^^ second mutable borrow occurs here + | +note: requirement that the value outlives `'1` introduced here + --> src/scope.rs + | + | T: UserData + 'env, + | ^^^^ diff --git a/tests/compile/scope_userdata_borrow.stderr b/tests/compile/scope_userdata_borrow.stderr index 43025dd..7aa771f 100644 --- a/tests/compile/scope_userdata_borrow.stderr +++ b/tests/compile/scope_userdata_borrow.stderr @@ -13,3 +13,9 @@ error[E0597]: `ibad` does not live long enough | argument requires that `ibad` is borrowed for `'1` 16 | }; | - `ibad` dropped here while still borrowed + | +note: requirement that the value outlives `'1` introduced here + --> src/scope.rs + | + | T: UserData + 'env, + | ^^^^