diff --git a/src/api/custom_syntax.rs b/src/api/custom_syntax.rs index 91b89b2c..f0368b9a 100644 --- a/src/api/custom_syntax.rs +++ b/src/api/custom_syntax.rs @@ -402,7 +402,8 @@ impl Engine { parse: Box::new(parse), func: Box::new(func), scope_may_be_changed, - }, + } + .into(), ); self } diff --git a/src/api/events.rs b/src/api/events.rs index 1b7d0749..7fd2dafd 100644 --- a/src/api/events.rs +++ b/src/api/events.rs @@ -363,7 +363,7 @@ impl Engine { + SendSync + 'static, ) -> &mut Self { - self.debugger_interface = Some(Box::new((Box::new(init), Box::new(callback)))); + self.debugger_interface = Some((Box::new(init), Box::new(callback))); self } } diff --git a/src/engine.rs b/src/engine.rs index 255ab7eb..1e35d21f 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -115,7 +115,7 @@ pub struct Engine { /// Custom syntax. #[cfg(not(feature = "no_custom_syntax"))] pub(crate) custom_syntax: Option< - Box>, + Box>>, >, /// Callback closure for filtering variable definition. pub(crate) def_var_filter: Option>, @@ -147,12 +147,10 @@ pub struct Engine { /// Callback closure for debugging. #[cfg(feature = "debugging")] - pub(crate) debugger_interface: Option< - Box<( - Box, - Box, - )>, - >, + pub(crate) debugger_interface: Option<( + Box, + Box, + )>, } impl fmt::Debug for Engine { diff --git a/src/eval/data_check.rs b/src/eval/data_check.rs index e4e5dc68..f5016ea3 100644 --- a/src/eval/data_check.rs +++ b/src/eval/data_check.rs @@ -205,9 +205,13 @@ impl Engine { } // Report progress - self.progress - .as_ref() - .and_then(|p| p(global.num_operations)) - .map_or(Ok(()), |token| Err(ERR::ErrorTerminated(token, pos).into())) + if let Some(ref progress) = self.progress { + match progress(global.num_operations) { + None => Ok(()), + Some(token) => Err(ERR::ErrorTerminated(token, pos).into()), + } + } else { + Ok(()) + } } } diff --git a/src/eval/debugger.rs b/src/eval/debugger.rs index 0302bdc2..de0bdd64 100644 --- a/src/eval/debugger.rs +++ b/src/eval/debugger.rs @@ -510,7 +510,7 @@ impl Engine { let src = global.source_raw().cloned(); let src = src.as_ref().map(|s| s.as_str()); let context = EvalContext::new(self, global, caches, scope, this_ptr); - let (.., ref on_debugger) = **x; + let (.., ref on_debugger) = *x; let command = on_debugger(context, event, node, src, node.position()); diff --git a/src/func/call.rs b/src/func/call.rs index a47c3495..f28d6f08 100644 --- a/src/func/call.rs +++ b/src/func/call.rs @@ -464,7 +464,7 @@ impl Engine { let t = self.map_type_name(type_name::()).into(); ERR::ErrorMismatchOutputType(t, typ.into(), pos) })?; - ((print)(&text).into(), false) + (print(&text).into(), false) } else { (Dynamic::UNIT, false) } @@ -475,7 +475,7 @@ impl Engine { let t = self.map_type_name(type_name::()).into(); ERR::ErrorMismatchOutputType(t, typ.into(), pos) })?; - ((debug)(&text, global.source(), pos).into(), false) + (debug(&text, global.source(), pos).into(), false) } else { (Dynamic::UNIT, false) } diff --git a/src/optimizer.rs b/src/optimizer.rs index c2dcb0c1..021a62d0 100644 --- a/src/optimizer.rs +++ b/src/optimizer.rs @@ -1139,7 +1139,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, _chaining: bool) { .and_then(|(f, ctx)| { let context = ctx.then(|| (state.engine, x.name.as_str(), None, &state.global, *pos).into()); let (first, second) = arg_values.split_first_mut().unwrap(); - (f)(context, &mut [ first, &mut second[0] ]).ok() + f(context, &mut [ first, &mut second[0] ]).ok() }) { state.set_dirty(); *expr = Expr::from_dynamic(result, *pos); diff --git a/src/tests.rs b/src/tests.rs index e6f07dd4..de018e67 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -13,6 +13,7 @@ fn check_struct_sizes() { feature = "only_i32", any(feature = "no_float", feature = "f32_float") )); + const WORD_SIZE: usize = size_of::(); assert_eq!(size_of::(), if PACKED { 8 } else { 16 }); assert_eq!(size_of::>(), if PACKED { 8 } else { 16 }); @@ -20,10 +21,7 @@ fn check_struct_sizes() { size_of::(), if cfg!(feature = "no_position") { 0 } else { 4 } ); - assert_eq!( - size_of::(), - if IS_32_BIT { 8 } else { 16 } - ); + assert_eq!(size_of::(), 2 * WORD_SIZE); assert_eq!(size_of::(), if PACKED { 12 } else { 16 }); assert_eq!(size_of::>(), if PACKED { 12 } else { 16 }); assert_eq!(size_of::(), if IS_32_BIT { 12 } else { 16 }); @@ -34,40 +32,41 @@ fn check_struct_sizes() { #[cfg(feature = "internals")] { - assert_eq!( - size_of::(), - if IS_32_BIT { 12 } else { 24 } - ); - assert_eq!( - size_of::(), - if IS_32_BIT { 16 } else { 32 } - ); + assert_eq!(size_of::(), 3 * WORD_SIZE); + assert_eq!(size_of::(), 4 * WORD_SIZE); } - #[cfg(target_pointer_width = "64")] - { - assert_eq!(size_of::(), 536); - assert_eq!( - size_of::(), - if cfg!(feature = "no_function") { - 72 - } else { - 80 - } - ); - assert_eq!(size_of::(), 56); - assert_eq!( - size_of::(), - if cfg!(feature = "no_position") { 8 } else { 16 } - ); - assert_eq!(size_of::(), 64); - assert_eq!( - size_of::(), - if cfg!(feature = "no_position") { - 48 - } else { - 56 - } - ); + // The following only on 64-bit platforms + + if !cfg!(target_pointer_width = "64") { + return; } + + assert_eq!(size_of::(), 536); + assert_eq!( + size_of::(), + 80 - if cfg!(feature = "no_function") { + WORD_SIZE + } else { + 0 + } + ); + assert_eq!(size_of::(), 56); + assert_eq!( + size_of::(), + 16 - if cfg!(feature = "no_position") { + WORD_SIZE + } else { + 0 + } + ); + assert_eq!(size_of::(), 64); + assert_eq!( + size_of::(), + 56 - if cfg!(feature = "no_position") { + WORD_SIZE + } else { + 0 + } + ); }