From c93e94c7cd9784cf1eda216b20cbeaaff1d91c53 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 28 Jan 2022 21:35:16 +0800 Subject: [PATCH] Fix builds. --- src/eval/global_state.rs | 4 +++- src/module/mod.rs | 8 +++++++- src/parser.rs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/eval/global_state.rs b/src/eval/global_state.rs index 9a9ddc35..4e7e33d4 100644 --- a/src/eval/global_state.rs +++ b/src/eval/global_state.rs @@ -57,6 +57,8 @@ impl GlobalRuntimeState<'_> { #[inline(always)] #[must_use] pub fn new(engine: &Engine) -> Self { + let _engine = engine; + Self { keys: StaticVec::new_const(), modules: StaticVec::new_const(), @@ -71,7 +73,7 @@ impl GlobalRuntimeState<'_> { #[cfg(not(feature = "no_function"))] constants: std::collections::BTreeMap::new().into(), #[cfg(feature = "debugging")] - debugger: crate::eval::Debugger::new(engine), + debugger: crate::eval::Debugger::new(_engine), dummy: PhantomData::default(), } } diff --git a/src/module/mod.rs b/src/module/mod.rs index cd6c3430..0a613af4 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -1685,6 +1685,8 @@ impl Module { // Save global state let orig_imports_len = global.num_imports(); let orig_source = global.source.clone(); + #[cfg(not(feature = "no_module"))] + #[cfg(not(feature = "no_function"))] let orig_constants = std::mem::take(&mut global.constants); // Run the script @@ -1717,7 +1719,11 @@ impl Module { } // Restore global state - global.constants = orig_constants; + #[cfg(not(feature = "no_module"))] + #[cfg(not(feature = "no_function"))] + { + global.constants = orig_constants; + } global.truncate_imports(orig_imports_len); global.source = orig_source; diff --git a/src/parser.rs b/src/parser.rs index d205b1dc..80d98e3a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -4,7 +4,7 @@ use crate::api::custom_syntax::{markers::*, CustomSyntax}; use crate::api::options::LanguageOptions; use crate::ast::{ BinaryExpr, ConditionalStmtBlock, CustomExpr, Expr, FnCallExpr, FnCallHashes, Ident, - OpAssignment, ScriptFnDef, Stmt, StmtBlock, SwitchCases, TryCatchBlock, AST_OPTION_FLAGS::*, + OpAssignment, ScriptFnDef, Stmt, SwitchCases, TryCatchBlock, AST_OPTION_FLAGS::*, }; use crate::engine::{Precedence, KEYWORD_THIS, OP_CONTAINS}; use crate::func::hashing::get_hasher; @@ -3184,7 +3184,7 @@ fn make_curry_from_externals( let mut statements = StaticVec::with_capacity(externals.len() + 1); statements.extend(externals.into_iter().map(Stmt::Share)); statements.push(Stmt::Expr(expr)); - Expr::Stmt(StmtBlock::new(statements, pos).into()) + Expr::Stmt(crate::ast::StmtBlock::new(statements, pos).into()) } /// Parse an anonymous function definition.