diff options
Diffstat (limited to 'tests/compile_fail')
-rw-r--r-- | tests/compile_fail/lua_norefunwindsafe.stderr | 27 | ||||
-rw-r--r-- | tests/compile_fail/ref_nounwindsafe.stderr | 29 | ||||
-rw-r--r-- | tests/compile_fail/scope_callback_capture.rs | 22 | ||||
-rw-r--r-- | tests/compile_fail/scope_callback_capture.stderr | 45 | ||||
-rw-r--r-- | tests/compile_fail/scope_callback_inner.rs | 19 | ||||
-rw-r--r-- | tests/compile_fail/scope_callback_inner.stderr | 45 | ||||
-rw-r--r-- | tests/compile_fail/scope_callback_outer.rs | 19 | ||||
-rw-r--r-- | tests/compile_fail/scope_callback_outer.stderr | 11 | ||||
-rw-r--r-- | tests/compile_fail/scope_invariance.rs | 23 | ||||
-rw-r--r-- | tests/compile_fail/scope_invariance.stderr | 25 | ||||
-rw-r--r-- | tests/compile_fail/scope_mutable_aliasing.rs | 15 | ||||
-rw-r--r-- | tests/compile_fail/scope_mutable_aliasing.stderr | 9 | ||||
-rw-r--r-- | tests/compile_fail/scope_userdata_borrow.rs | 20 | ||||
-rw-r--r-- | tests/compile_fail/scope_userdata_borrow.stderr | 13 |
14 files changed, 44 insertions, 278 deletions
diff --git a/tests/compile_fail/lua_norefunwindsafe.stderr b/tests/compile_fail/lua_norefunwindsafe.stderr index 1cf48ad..edd2803 100644 --- a/tests/compile_fail/lua_norefunwindsafe.stderr +++ b/tests/compile_fail/lua_norefunwindsafe.stderr @@ -10,6 +10,21 @@ error[E0277]: the type `std::cell::UnsafeCell<()>` may contain interior mutabili = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/lua_norefunwindsafe.rs:7:18: 7:48 lua:&mlua::lua::Lua]` +error[E0277]: the type `std::cell::UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/lua_norefunwindsafe.rs:7:5 + | +7 | catch_unwind(|| lua.create_table().unwrap()); + | ^^^^^^^^^^^^ `std::cell::UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `mlua::lua::Lua`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<usize>` + = note: required because it appears within the type `std::cell::Cell<usize>` + = note: required because it appears within the type `std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::marker::PhantomData<std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>>` + = note: required because it appears within the type `std::rc::Rc<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `mlua::lua::Lua` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` + = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/lua_norefunwindsafe.rs:7:18: 7:48 lua:&mlua::lua::Lua]` + error[E0277]: the type `std::cell::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 | @@ -18,9 +33,9 @@ error[E0277]: the type `std::cell::UnsafeCell<mlua::lua::ExtraData>` may contain | = help: within `mlua::lua::Lua`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<mlua::lua::ExtraData>` = note: required because it appears within the type `std::cell::RefCell<mlua::lua::ExtraData>` - = note: required because it appears within the type `alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>` - = note: required because it appears within the type `std::marker::PhantomData<alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>>` - = note: required because it appears within the type `std::sync::Arc<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::marker::PhantomData<std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>>` + = note: required because it appears within the type `std::rc::Rc<std::cell::RefCell<mlua::lua::ExtraData>>` = note: required because it appears within the type `mlua::lua::Lua` = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/lua_norefunwindsafe.rs:7:18: 7:48 lua:&mlua::lua::Lua]` @@ -34,9 +49,9 @@ error[E0277]: the type `std::cell::UnsafeCell<isize>` may contain interior mutab = help: within `mlua::lua::Lua`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<isize>` = note: required because it appears within the type `std::cell::Cell<isize>` = note: required because it appears within the type `std::cell::RefCell<mlua::lua::ExtraData>` - = note: required because it appears within the type `alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>` - = note: required because it appears within the type `std::marker::PhantomData<alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>>` - = note: required because it appears within the type `std::sync::Arc<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::marker::PhantomData<std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>>` + = note: required because it appears within the type `std::rc::Rc<std::cell::RefCell<mlua::lua::ExtraData>>` = note: required because it appears within the type `mlua::lua::Lua` = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/lua_norefunwindsafe.rs:7:18: 7:48 lua:&mlua::lua::Lua]` diff --git a/tests/compile_fail/ref_nounwindsafe.stderr b/tests/compile_fail/ref_nounwindsafe.stderr index 46f8352..ba6e696 100644 --- a/tests/compile_fail/ref_nounwindsafe.stderr +++ b/tests/compile_fail/ref_nounwindsafe.stderr @@ -12,6 +12,23 @@ error[E0277]: the type `std::cell::UnsafeCell<()>` may contain interior mutabili = note: required because it appears within the type `mlua::table::Table<'_>` = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/ref_nounwindsafe.rs:8:18: 8:54 table:mlua::table::Table<'_>]` +error[E0277]: the type `std::cell::UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + --> $DIR/ref_nounwindsafe.rs:8:5 + | +8 | catch_unwind(move || table.set("a", "b").unwrap()); + | ^^^^^^^^^^^^ `std::cell::UnsafeCell<usize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary + | + = help: within `mlua::lua::Lua`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<usize>` + = note: required because it appears within the type `std::cell::Cell<usize>` + = note: required because it appears within the type `std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::marker::PhantomData<std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>>` + = note: required because it appears within the type `std::rc::Rc<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `mlua::lua::Lua` + = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` + = note: required because it appears within the type `mlua::types::LuaRef<'_>` + = note: required because it appears within the type `mlua::table::Table<'_>` + = note: required because it appears within the type `[closure@$DIR/tests/compile_fail/ref_nounwindsafe.rs:8:18: 8:54 table:mlua::table::Table<'_>]` + error[E0277]: the type `std::cell::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 | @@ -20,9 +37,9 @@ error[E0277]: the type `std::cell::UnsafeCell<mlua::lua::ExtraData>` may contain | = help: within `mlua::lua::Lua`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<mlua::lua::ExtraData>` = note: required because it appears within the type `std::cell::RefCell<mlua::lua::ExtraData>` - = note: required because it appears within the type `alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>` - = note: required because it appears within the type `std::marker::PhantomData<alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>>` - = note: required because it appears within the type `std::sync::Arc<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::marker::PhantomData<std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>>` + = note: required because it appears within the type `std::rc::Rc<std::cell::RefCell<mlua::lua::ExtraData>>` = note: required because it appears within the type `mlua::lua::Lua` = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` = note: required because it appears within the type `mlua::types::LuaRef<'_>` @@ -38,9 +55,9 @@ error[E0277]: the type `std::cell::UnsafeCell<isize>` may contain interior mutab = help: within `mlua::lua::Lua`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<isize>` = note: required because it appears within the type `std::cell::Cell<isize>` = note: required because it appears within the type `std::cell::RefCell<mlua::lua::ExtraData>` - = note: required because it appears within the type `alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>` - = note: required because it appears within the type `std::marker::PhantomData<alloc::sync::ArcInner<std::cell::RefCell<mlua::lua::ExtraData>>>` - = note: required because it appears within the type `std::sync::Arc<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>` + = note: required because it appears within the type `std::marker::PhantomData<std::rc::RcBox<std::cell::RefCell<mlua::lua::ExtraData>>>` + = note: required because it appears within the type `std::rc::Rc<std::cell::RefCell<mlua::lua::ExtraData>>` = note: required because it appears within the type `mlua::lua::Lua` = note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `&mlua::lua::Lua` = note: required because it appears within the type `mlua::types::LuaRef<'_>` diff --git a/tests/compile_fail/scope_callback_capture.rs b/tests/compile_fail/scope_callback_capture.rs deleted file mode 100644 index 93667f0..0000000 --- a/tests/compile_fail/scope_callback_capture.rs +++ /dev/null @@ -1,22 +0,0 @@ -use mlua::{Lua, Table, Result}; - -struct Test { - field: i32, -} - -fn main() { - let lua = Lua::new(); - lua.scope(|scope| -> Result<()> { - let mut inner: Option<Table> = None; - let f = scope - .create_function_mut(move |lua, t: Table| { - if let Some(old) = inner.take() { - // Access old callback `Lua`. - } - inner = Some(t); - Ok(()) - })?; - f.call::<_, ()>(lua.create_table()?)?; - Ok(()) - }); -} diff --git a/tests/compile_fail/scope_callback_capture.stderr b/tests/compile_fail/scope_callback_capture.stderr deleted file mode 100644 index b23ea95..0000000 --- a/tests/compile_fail/scope_callback_capture.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/scope_callback_capture.rs:12:14 - | -12 | .create_function_mut(move |lua, t: Table| { - | ^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 9:15... - --> $DIR/scope_callback_capture.rs:9:15 - | -9 | lua.scope(|scope| -> Result<()> { - | _______________^ -10 | | let mut inner: Option<Table> = None; -11 | | let f = scope -12 | | .create_function_mut(move |lua, t: Table| { -... | -20 | | Ok(()) -21 | | }); - | |_____^ -note: ...so that reference does not outlive borrowed content - --> $DIR/scope_callback_capture.rs:11:17 - | -11 | let f = scope - | ^^^^^ -note: but, the lifetime must be valid for the method call at 9:5... - --> $DIR/scope_callback_capture.rs:9:5 - | -9 | / lua.scope(|scope| -> Result<()> { -10 | | let mut inner: Option<Table> = None; -11 | | let f = scope -12 | | .create_function_mut(move |lua, t: Table| { -... | -20 | | Ok(()) -21 | | }); - | |______^ -note: ...so that a type/lifetime parameter is in scope here - --> $DIR/scope_callback_capture.rs:9:5 - | -9 | / lua.scope(|scope| -> Result<()> { -10 | | let mut inner: Option<Table> = None; -11 | | let f = scope -12 | | .create_function_mut(move |lua, t: Table| { -... | -20 | | Ok(()) -21 | | }); - | |______^ diff --git a/tests/compile_fail/scope_callback_inner.rs b/tests/compile_fail/scope_callback_inner.rs deleted file mode 100644 index 56b56ba..0000000 --- a/tests/compile_fail/scope_callback_inner.rs +++ /dev/null @@ -1,19 +0,0 @@ -use mlua::{Lua, Table, Result}; - -struct Test { - field: i32, -} - -fn main() { - let lua = Lua::new(); - lua.scope(|scope| -> Result<()> { - let mut inner: Option<Table> = None; - let f = scope - .create_function_mut(|_, t: Table| { - inner = Some(t); - Ok(()) - })?; - f.call::<_, ()>(lua.create_table()?)?; - Ok(()) - }); -} diff --git a/tests/compile_fail/scope_callback_inner.stderr b/tests/compile_fail/scope_callback_inner.stderr deleted file mode 100644 index 077fba4..0000000 --- a/tests/compile_fail/scope_callback_inner.stderr +++ /dev/null @@ -1,45 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements - --> $DIR/scope_callback_inner.rs:12:14 - | -12 | .create_function_mut(|_, t: Table| { - | ^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 9:15... - --> $DIR/scope_callback_inner.rs:9:15 - | -9 | lua.scope(|scope| -> Result<()> { - | _______________^ -10 | | let mut inner: Option<Table> = None; -11 | | let f = scope -12 | | .create_function_mut(|_, t: Table| { -... | -17 | | Ok(()) -18 | | }); - | |_____^ -note: ...so that reference does not outlive borrowed content - --> $DIR/scope_callback_inner.rs:11:17 - | -11 | let f = scope - | ^^^^^ -note: but, the lifetime must be valid for the method call at 9:5... - --> $DIR/scope_callback_inner.rs:9:5 - | -9 | / lua.scope(|scope| -> Result<()> { -10 | | let mut inner: Option<Table> = None; -11 | | let f = scope -12 | | .create_function_mut(|_, t: Table| { -... | -17 | | Ok(()) -18 | | }); - | |______^ -note: ...so that a type/lifetime parameter is in scope here - --> $DIR/scope_callback_inner.rs:9:5 - | -9 | / lua.scope(|scope| -> Result<()> { -10 | | let mut inner: Option<Table> = None; -11 | | let f = scope -12 | | .create_function_mut(|_, t: Table| { -... | -17 | | Ok(()) -18 | | }); - | |______^ diff --git a/tests/compile_fail/scope_callback_outer.rs b/tests/compile_fail/scope_callback_outer.rs deleted file mode 100644 index 57437c9..0000000 --- a/tests/compile_fail/scope_callback_outer.rs +++ /dev/null @@ -1,19 +0,0 @@ -use mlua::{Lua, Table, Result}; - -struct Test { - field: i32, -} - -fn main() { - let lua = Lua::new(); - let mut outer: Option<Table> = None; - lua.scope(|scope| -> Result<()> { - let f = scope - .create_function_mut(|_, t: Table| { - outer = Some(t); - Ok(()) - })?; - f.call::<_, ()>(lua.create_table()?)?; - Ok(()) - }); -} diff --git a/tests/compile_fail/scope_callback_outer.stderr b/tests/compile_fail/scope_callback_outer.stderr deleted file mode 100644 index c68bb4f..0000000 --- a/tests/compile_fail/scope_callback_outer.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: borrowed data cannot be stored outside of its closure - --> $DIR/scope_callback_outer.rs:11:17 - | -9 | let mut outer: Option<Table> = None; - | --------- ...so that variable is valid at time of its declaration -10 | lua.scope(|scope| -> Result<()> { - | --------------------- borrowed data cannot outlive this closure -11 | let f = scope - | ^^^^^ cannot be stored outside of its closure -12 | .create_function_mut(|_, t: Table| { - | ------------------- cannot infer an appropriate lifetime... diff --git a/tests/compile_fail/scope_invariance.rs b/tests/compile_fail/scope_invariance.rs deleted file mode 100644 index 569ada1..0000000 --- a/tests/compile_fail/scope_invariance.rs +++ /dev/null @@ -1,23 +0,0 @@ -use mlua::{Lua, Result}; - -struct Test { - field: i32, -} - -fn main() { - let lua = Lua::new(); - lua.scope(|scope| -> Result<()> { - let f = { - let mut test = Test { field: 0 }; - - scope - .create_function_mut(|_, ()| { - test.field = 42; - //~^ error: `test` does not live long enough - Ok(()) - })? - }; - - f.call::<_, ()>(()) - }); -} diff --git a/tests/compile_fail/scope_invariance.stderr b/tests/compile_fail/scope_invariance.stderr deleted file mode 100644 index 434eb78..0000000 --- a/tests/compile_fail/scope_invariance.stderr +++ /dev/null @@ -1,25 +0,0 @@ -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 - | -9 | lua.scope(|scope| -> Result<()> { - | ----- has type `&mlua::scope::Scope<'_, '1>` -... -14 | .create_function_mut(|_, ()| { - | ^^^^^^^ may outlive borrowed value `test` -15 | test.field = 42; - | ---- `test` is borrowed here - | -note: function requires argument type to outlive `'1` - --> $DIR/scope_invariance.rs:13:13 - | -13 | / scope -14 | | .create_function_mut(|_, ()| { -15 | | test.field = 42; -16 | | //~^ error: `test` does not live long enough -17 | | Ok(()) -18 | | })? - | |__________________^ -help: to force the closure to take ownership of `test` (and any other referenced variables), use the `move` keyword - | -14 | .create_function_mut(move |_, ()| { - | ^^^^^^^^^^^^ diff --git a/tests/compile_fail/scope_mutable_aliasing.rs b/tests/compile_fail/scope_mutable_aliasing.rs deleted file mode 100644 index 4d8d2f0..0000000 --- a/tests/compile_fail/scope_mutable_aliasing.rs +++ /dev/null @@ -1,15 +0,0 @@ -use mlua::{Lua, UserData, Result}; - -struct MyUserData<'a>(&'a mut i32); -impl<'a> UserData for MyUserData<'a> {} - -fn main() { - let mut i = 1; - - let lua = Lua::new(); - lua.scope(|scope| -> Result<()> { - let _a = scope.create_nonstatic_userdata(MyUserData(&mut i))?; - let _b = scope.create_nonstatic_userdata(MyUserData(&mut i))?; - Ok(()) - }); -} diff --git a/tests/compile_fail/scope_mutable_aliasing.stderr b/tests/compile_fail/scope_mutable_aliasing.stderr deleted file mode 100644 index d78f983..0000000 --- a/tests/compile_fail/scope_mutable_aliasing.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0499]: cannot borrow `i` as mutable more than once at a time - --> $DIR/scope_mutable_aliasing.rs:12:61 - | -11 | let _a = scope.create_nonstatic_userdata(MyUserData(&mut i))?; - | ------ first mutable borrow occurs here -12 | let _b = scope.create_nonstatic_userdata(MyUserData(&mut i))?; - | ------------------------- ^^^^^^ second mutable borrow occurs here - | | - | first borrow later used by call diff --git a/tests/compile_fail/scope_userdata_borrow.rs b/tests/compile_fail/scope_userdata_borrow.rs deleted file mode 100644 index b88d1d6..0000000 --- a/tests/compile_fail/scope_userdata_borrow.rs +++ /dev/null @@ -1,20 +0,0 @@ -use mlua::{Lua, UserData, Result}; - -struct MyUserData<'a>(&'a i32); -impl<'a> UserData for MyUserData<'a> {} - -fn main() { - // Should not allow userdata borrow to outlive lifetime of AnyUserData handle - - let igood = 1; - - let lua = Lua::new(); - lua.scope(|scope| -> Result<()> { - let _ugood = scope.create_nonstatic_userdata(MyUserData(&igood))?; - let _ubad = { - let ibad = 42; - scope.create_nonstatic_userdata(MyUserData(&ibad))?; - }; - Ok(()) - }); -} diff --git a/tests/compile_fail/scope_userdata_borrow.stderr b/tests/compile_fail/scope_userdata_borrow.stderr deleted file mode 100644 index c143c9a..0000000 --- a/tests/compile_fail/scope_userdata_borrow.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `ibad` does not live long enough - --> $DIR/scope_userdata_borrow.rs:16:56 - | -12 | lua.scope(|scope| -> Result<()> { - | ----- has type `&mlua::scope::Scope<'_, '1>` -... -16 | scope.create_nonstatic_userdata(MyUserData(&ibad))?; - | -------------------------------------------^^^^^-- - | | | - | | borrowed value does not live long enough - | argument requires that `ibad` is borrowed for `'1` -17 | }; - | - `ibad` dropped here while still borrowed |