diff --git a/rust/kcl-derive-docs/src/lib.rs b/rust/kcl-derive-docs/src/lib.rs index 58ed9e83b..4cfb9a989 100644 --- a/rust/kcl-derive-docs/src/lib.rs +++ b/rust/kcl-derive-docs/src/lib.rs @@ -797,7 +797,7 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr let ctx = crate::ExecutorContext { engine: std::sync::Arc::new(Box::new(crate::engine::conn_mock::EngineConnection::new().await.unwrap())), fs: std::sync::Arc::new(crate::fs::FileManager::new()), - stdlib: std::sync::Arc::new(tokio::sync::RwLock::new(crate::std::StdLib::new())), + stdlib: std::sync::Arc::new(crate::std::StdLib::new()), settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; diff --git a/rust/kcl-lib/src/execution/exec_ast.rs b/rust/kcl-lib/src/execution/exec_ast.rs index 1c0d400d4..0f01a2282 100644 --- a/rust/kcl-lib/src/execution/exec_ast.rs +++ b/rust/kcl-lib/src/execution/exec_ast.rs @@ -1217,7 +1217,7 @@ impl Node { ctx.clone(), exec_state.mod_local.pipe_value.clone().map(|v| Arg::new(v, callsite)), ); - match ctx.stdlib.read().await.get_either(fn_name) { + match ctx.stdlib.get_either(fn_name) { FunctionKind::Core(func) => { if func.deprecated() { exec_state.warn(CompilationError::err( @@ -1369,7 +1369,7 @@ impl Node { } let fn_args = fn_args; // remove mutability - match ctx.stdlib.read().await.get_either(fn_name) { + match ctx.stdlib.get_either(fn_name) { FunctionKind::Core(func) => { if func.deprecated() { exec_state.warn(CompilationError::err( @@ -2228,7 +2228,7 @@ mod test { parsing::ast::types::{DefaultParamVal, Identifier, Parameter}, }; use std::sync::Arc; - use tokio::{sync::RwLock, task::JoinSet}; + use tokio::task::JoinSet; #[tokio::test(flavor = "multi_thread")] async fn test_assign_args_to_params() { @@ -2347,7 +2347,7 @@ mod test { crate::engine::conn_mock::EngineConnection::new().await.unwrap(), )), fs: Arc::new(crate::fs::FileManager::new()), - stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())), + stdlib: Arc::new(crate::std::StdLib::new()), settings: Default::default(), context_type: ContextType::Mock, }; @@ -2487,7 +2487,7 @@ import 'a.kcl' .unwrap(), )), fs: Arc::new(crate::fs::FileManager::new()), - stdlib: Arc::new(RwLock::new(crate::std::StdLib::new())), + stdlib: Arc::new(crate::std::StdLib::new()), settings: Default::default(), context_type: ContextType::Mock, }; diff --git a/rust/kcl-lib/src/execution/mod.rs b/rust/kcl-lib/src/execution/mod.rs index 6c1de6748..278ac02ec 100644 --- a/rust/kcl-lib/src/execution/mod.rs +++ b/rust/kcl-lib/src/execution/mod.rs @@ -27,7 +27,6 @@ pub use memory::EnvironmentRef; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; pub use state::{ExecState, MetaSettings}; -use tokio::sync::RwLock; use crate::{ engine::EngineManager, @@ -257,7 +256,7 @@ pub enum ContextType { pub struct ExecutorContext { pub engine: Arc>, pub fs: Arc, - pub stdlib: Arc>, + pub stdlib: Arc, pub settings: ExecutorSettings, pub context_type: ContextType, } @@ -402,7 +401,7 @@ impl ExecutorContext { Ok(Self { engine, fs: Arc::new(FileManager::new()), - stdlib: Arc::new(RwLock::new(StdLib::new())), + stdlib: Arc::new(StdLib::new()), settings, context_type: ContextType::Live, }) @@ -421,7 +420,7 @@ impl ExecutorContext { .map_err(|e| format!("{:?}", e))?, )), fs: Arc::new(FileManager::new(fs_manager)), - stdlib: Arc::new(RwLock::new(StdLib::new())), + stdlib: Arc::new(StdLib::new()), settings, context_type: ContextType::Live, }) @@ -434,7 +433,7 @@ impl ExecutorContext { crate::engine::conn_mock::EngineConnection::new().await.unwrap(), )), fs: Arc::new(FileManager::new()), - stdlib: Arc::new(RwLock::new(StdLib::new())), + stdlib: Arc::new(StdLib::new()), settings: Default::default(), context_type: ContextType::Mock, } @@ -452,7 +451,7 @@ impl ExecutorContext { .map_err(|e| format!("{:?}", e))?, )), fs: Arc::new(FileManager::new(fs_manager)), - stdlib: Arc::new(RwLock::new(StdLib::new())), + stdlib: Arc::new(StdLib::new()), settings, context_type: ContextType::Mock, }) @@ -463,7 +462,7 @@ impl ExecutorContext { ExecutorContext { engine, fs: Arc::new(FileManager::new()), - stdlib: Arc::new(RwLock::new(StdLib::new())), + stdlib: Arc::new(StdLib::new()), settings: Default::default(), context_type: ContextType::MockCustomForwarded, } @@ -979,7 +978,7 @@ pub(crate) async fn parse_execute(code: &str) -> Result