From fc6c5ecd00914ae541876dd66bd530214015bd11 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 29 Mar 2021 13:07:10 +0800 Subject: [PATCH] Fix no_closure builds. --- src/ast.rs | 10 +++++----- src/fn_call.rs | 1 + src/packages/fn_basic.rs | 4 ++-- src/parser.rs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 86d0e017..81a277c5 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -5,7 +5,7 @@ use crate::fn_native::shared_make_mut; use crate::module::NamespaceRef; use crate::stdlib::{ boxed::Box, - collections::{BTreeMap, BTreeSet}, + collections::BTreeMap, fmt, hash::Hash, num::NonZeroUsize, @@ -58,7 +58,7 @@ pub struct ScriptFnDef { pub params: StaticVec, /// Access to external variables. #[cfg(not(feature = "no_closure"))] - pub externals: BTreeSet, + pub externals: crate::stdlib::collections::BTreeSet, /// Function doc-comments (if any). pub comments: StaticVec, } @@ -901,7 +901,7 @@ pub enum Stmt { Export(Vec<(Ident, Option)>, Position), /// Convert a variable to shared. #[cfg(not(feature = "no_closure"))] - Share(Ident), + Share(Box), } impl Default for Stmt { @@ -1864,8 +1864,8 @@ mod tests { assert_eq!(size_of::(), 4); assert_eq!(size_of::(), 16); assert_eq!(size_of::>(), 16); - assert_eq!(size_of::(), 40); - assert_eq!(size_of::>(), 40); + assert_eq!(size_of::(), 32); + assert_eq!(size_of::>(), 32); assert_eq!(size_of::(), 80); assert_eq!(size_of::(), 288); assert_eq!(size_of::(), 56); diff --git a/src/fn_call.rs b/src/fn_call.rs index d02d75e6..e7cef8ca 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -96,6 +96,7 @@ impl Drop for ArgBackup<'_> { } } +#[cfg(not(feature = "no_closure"))] #[inline(always)] pub fn ensure_no_data_race( fn_name: &str, diff --git a/src/packages/fn_basic.rs b/src/packages/fn_basic.rs index 634f5253..3331f32c 100644 --- a/src/packages/fn_basic.rs +++ b/src/packages/fn_basic.rs @@ -1,5 +1,5 @@ use crate::plugin::*; -use crate::{def_package, FnPtr, Identifier, ImmutableString, NativeCallContext}; +use crate::{def_package, FnPtr, ImmutableString, NativeCallContext}; def_package!(crate:BasicFnPackage:"Basic Fn functions.", lib, { combine_with_exported_module!(lib, "FnPtr", fn_ptr_functions); @@ -34,7 +34,7 @@ mod fn_ptr_functions { #[cfg(not(feature = "no_index"))] #[cfg(not(feature = "no_object"))] fn collect_fn_metadata(ctx: NativeCallContext) -> crate::Array { - use crate::{ast::ScriptFnDef, stdlib::collections::BTreeSet, Array, Map}; + use crate::{ast::ScriptFnDef, stdlib::collections::BTreeSet, Array, Identifier, Map}; // Create a metadata record for a function. fn make_metadata( diff --git a/src/parser.rs b/src/parser.rs index daa02cfb..0d6de2ba 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2800,7 +2800,7 @@ fn make_curry_from_externals( // Convert the entire expression into a statement block, then insert the relevant // [`Share`][Stmt::Share] statements. let mut statements: StaticVec<_> = Default::default(); - statements.extend(externals.into_iter().map(Stmt::Share)); + statements.extend(externals.into_iter().map(|v| Stmt::Share(Box::new(v)))); statements.push(Stmt::Expr(expr)); Expr::Stmt(Box::new(StmtBlock { statements, pos })) }