From c62162b3c5dbc40e24147ebc4f41393e081f96be Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 17 Mar 2023 06:15:59 +0800 Subject: [PATCH] Use {} style for auto_restore. --- src/api/eval.rs | 4 ++-- src/eval/chaining.rs | 6 +++--- src/eval/expr.rs | 2 +- src/eval/stmt.rs | 6 +++--- src/func/call.rs | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/api/eval.rs b/src/api/eval.rs index 3882fae5..2c93b182 100644 --- a/src/api/eval.rs +++ b/src/api/eval.rs @@ -242,7 +242,7 @@ impl Engine { ast.resolver().cloned(), ); - auto_restore!(global => move |g| { + auto_restore! { global => move |g| { #[cfg(not(feature = "no_module"))] { g.embedded_module_resolver = orig_embedded_module_resolver; @@ -252,7 +252,7 @@ impl Engine { g.lib.truncate(orig_lib_len); g.source = orig_source; - }); + }} let r = self.eval_global_statements(global, caches, scope, ast.statements())?; diff --git a/src/eval/chaining.rs b/src/eval/chaining.rs index 22e8ae46..a6184061 100644 --- a/src/eval/chaining.rs +++ b/src/eval/chaining.rs @@ -688,7 +688,7 @@ impl Engine { let reset = self.run_debugger_with_reset(global, caches, scope, this_ptr, rhs)?; #[cfg(feature = "debugging")] - auto_restore!(global if Some(reset) => move |g| g.debugger_mut().reset_status(reset)); + auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) } let crate::ast::FnCallExpr { name, hashes, args, .. @@ -857,7 +857,7 @@ impl Engine { let reset = self .run_debugger_with_reset(global, caches, scope, _tp, _node)?; #[cfg(feature = "debugging")] - auto_restore!(global if Some(reset) => move |g| g.debugger_mut().reset_status(reset)); + auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) } let crate::ast::FnCallExpr { name, hashes, args, .. @@ -977,7 +977,7 @@ impl Engine { global, caches, scope, _tp, _node, )?; #[cfg(feature = "debugging")] - auto_restore!(global if Some(reset) => move |g| g.debugger_mut().reset_status(reset)); + auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) } let crate::ast::FnCallExpr { name, hashes, args, .. diff --git a/src/eval/expr.rs b/src/eval/expr.rs index c2aaf79d..f73bd496 100644 --- a/src/eval/expr.rs +++ b/src/eval/expr.rs @@ -243,7 +243,7 @@ impl Engine { let reset = self.run_debugger_with_reset(global, caches, scope, this_ptr.as_deref_mut(), expr)?; #[cfg(feature = "debugging")] - auto_restore!(global if Some(reset) => move |g| g.debugger_mut().reset_status(reset)); + auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) } self.track_operation(global, expr.position())?; diff --git a/src/eval/stmt.rs b/src/eval/stmt.rs index 1f4ae51d..799846b3 100644 --- a/src/eval/stmt.rs +++ b/src/eval/stmt.rs @@ -54,7 +54,7 @@ impl Engine { global.scope_level += 1; } - auto_restore!(global if restore_orig_state => move |g| { + auto_restore! { global if restore_orig_state => move |g| { g.scope_level -= 1; #[cfg(not(feature = "no_module"))] @@ -63,7 +63,7 @@ impl Engine { // The impact of new local variables goes away at the end of a block // because any new variables introduced will go out of scope g.always_search_scope = orig_always_search_scope; - }); + }} // Pop new function resolution caches at end of block auto_restore! { @@ -271,7 +271,7 @@ impl Engine { let reset = self.run_debugger_with_reset(global, caches, scope, this_ptr.as_deref_mut(), stmt)?; #[cfg(feature = "debugging")] - auto_restore!(global if Some(reset) => move |g| g.debugger_mut().reset_status(reset)); + auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) } self.track_operation(global, stmt.position())?; diff --git a/src/func/call.rs b/src/func/call.rs index 079c095b..886cdd75 100644 --- a/src/func/call.rs +++ b/src/func/call.rs @@ -658,7 +658,7 @@ impl Engine { }; let orig_source = mem::replace(&mut global.source, source.clone()); - auto_restore!(global => move |g| g.source = orig_source); + auto_restore! { global => move |g| g.source = orig_source } return if _is_method_call { // Method call of script function - map first argument to `this` @@ -686,7 +686,7 @@ impl Engine { backup.change_first_arg_to_copy(_args); } - auto_restore!(args = (_args) if swap => move |a| backup.restore_first_arg(a)); + auto_restore! { args = (_args) if swap => move |a| backup.restore_first_arg(a) } self.call_script_fn(global, caches, scope, None, environ, f, args, true, pos) } @@ -730,7 +730,7 @@ impl Engine { }) }); #[cfg(feature = "debugging")] - auto_restore!(global if Some(reset) => move |g| g.debugger_mut().reset_status(reset)); + auto_restore! { global if Some(reset) => move |g| g.debugger_mut().reset_status(reset) } self.eval_expr(global, caches, scope, this_ptr, arg_expr) .map(|r| (r, arg_expr.start_position())) @@ -1457,7 +1457,7 @@ impl Engine { let scope = &mut Scope::new(); let orig_source = mem::replace(&mut global.source, module.id_raw().cloned()); - auto_restore!(global => move |g| g.source = orig_source); + auto_restore! { global => move |g| g.source = orig_source } self.call_script_fn(global, caches, scope, None, environ, f, args, true, pos) }