Skip to content

Commit 2297437

Browse files
committed
Fix rust 2018 dyn warnings
1 parent 2542d29 commit 2297437

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ target/
33
Cargo.lock
44
.DS_Store
55
.#*
6+
.envrc
7+
shell.nix

src/lua.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub(crate) struct ExtraData {
383383
used_memory: usize,
384384
memory_limit: Option<usize>,
385385

386-
pub hook_callback: Option<Rc<RefCell<FnMut(Context, Debug) -> Result<()>>>>,
386+
pub hook_callback: Option<Rc<RefCell<dyn FnMut(Context, Debug) -> Result<()>>>>,
387387
}
388388

389389
pub(crate) unsafe fn extra_data(state: *mut ffi::lua_State) -> *mut ExtraData {

src/scope.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::value::{FromLuaMulti, MultiValue, ToLuaMulti, Value};
2626
/// [`Context::scope`]: struct.Context.html#method.scope
2727
pub struct Scope<'lua, 'scope> {
2828
lua: Context<'lua>,
29-
destructors: RefCell<Vec<(LuaRef<'lua>, fn(LuaRef<'lua>) -> Box<Any>)>>,
29+
destructors: RefCell<Vec<(LuaRef<'lua>, fn(LuaRef<'lua>) -> Box<dyn Any>)>>,
3030
_scope_invariant: Invariant<'scope>,
3131
}
3232

@@ -330,10 +330,10 @@ impl<'lua, 'scope> Drop for Scope<'lua, 'scope> {
330330
}
331331

332332
enum NonStaticMethod<'lua, T> {
333-
Method(Box<Fn(Context<'lua>, &T, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
334-
MethodMut(Box<FnMut(Context<'lua>, &mut T, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
335-
Function(Box<Fn(Context<'lua>, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
336-
FunctionMut(Box<FnMut(Context<'lua>, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
333+
Method(Box<dyn Fn(Context<'lua>, &T, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
334+
MethodMut(Box<dyn FnMut(Context<'lua>, &mut T, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
335+
Function(Box<dyn Fn(Context<'lua>, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
336+
FunctionMut(Box<dyn FnMut(Context<'lua>, MultiValue<'lua>) -> Result<MultiValue<'lua>>>),
337337
}
338338

339339
struct NonStaticUserDataMethods<'lua, T: UserData> {

src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub type Number = ffi::lua_Number;
1717
pub struct LightUserData(pub *mut c_void);
1818

1919
pub(crate) type Callback<'lua, 'a> =
20-
Box<Fn(Context<'lua>, MultiValue<'lua>) -> Result<MultiValue<'lua>> + 'a>;
20+
Box<dyn Fn(Context<'lua>, MultiValue<'lua>) -> Result<MultiValue<'lua>> + 'a>;
2121

2222
/// An auto generated key into the Lua registry.
2323
///

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ pub unsafe fn init_error_registry(state: *mut ffi::lua_State) {
688688
}
689689

690690
struct WrappedError(pub Error);
691-
struct WrappedPanic(pub Option<Box<Any + Send>>);
691+
struct WrappedPanic(pub Option<Box<dyn Any + Send>>);
692692

693693
// Converts the given lua value to a string in a reasonable format without causing a Lua error or
694694
// panicking.

tests/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ fn test_error() {
165165
"test error"
166166
}
167167

168-
fn cause(&self) -> Option<&error::Error> {
168+
fn cause(&self) -> Option<&dyn error::Error> {
169169
None
170170
}
171171
}

0 commit comments

Comments
 (0)