From a3acf09bdacce6926ee45fdbcaec524df745b385 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Tue, 3 Aug 2021 12:38:12 +0800 Subject: [PATCH] typedef: make it send Rc in calls is not send, so we use Arc instead. --- nac3core/src/typecheck/type_inferencer/mod.rs | 9 ++++----- nac3core/src/typecheck/type_inferencer/test.rs | 2 +- nac3core/src/typecheck/typedef/mod.rs | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index 8b9c098e..f474a66f 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -1,8 +1,7 @@ -use std::cell::RefCell; +use std::{cell::RefCell, sync::Arc}; use std::collections::HashMap; use std::convert::{TryInto, From}; use std::iter::once; -use std::rc::Rc; use super::magic_methods::*; use super::symbol_resolver::SymbolResolver; @@ -53,7 +52,7 @@ pub struct Inferencer<'a> { pub primitives: &'a PrimitiveStore, pub virtual_checks: &'a mut Vec<(Type, Type)>, pub variable_mapping: HashMap, - pub calls: &'a mut HashMap>, + pub calls: &'a mut HashMap>, } struct NaiveFolder(); @@ -192,7 +191,7 @@ impl<'a> Inferencer<'a> { ret: Type, ) -> InferenceResult { let call = - Rc::new(Call { posargs: params, kwargs: HashMap::new(), ret, fun: RefCell::new(None) }); + Arc::new(Call { posargs: params, kwargs: HashMap::new(), ret, fun: RefCell::new(None) }); let call = self.unifier.add_ty(TypeEnum::TCall(vec![call].into())); let fields = once((method, call)).collect(); let record = self.unifier.add_record(fields); @@ -389,7 +388,7 @@ impl<'a> Inferencer<'a> { .map(|v| fold::fold_keyword(self, v)) .collect::, _>>()?; let ret = self.unifier.get_fresh_var().0; - let call = Rc::new(Call { + let call = Arc::new(Call { posargs: args.iter().map(|v| v.custom.unwrap()).collect(), kwargs: keywords .iter() diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs index 16200dc9..c6b2c394 100644 --- a/nac3core/src/typecheck/type_inferencer/test.rs +++ b/nac3core/src/typecheck/type_inferencer/test.rs @@ -42,7 +42,7 @@ struct TestEnvironment { pub id_to_name: HashMap, pub identifier_mapping: HashMap, pub virtual_checks: Vec<(Type, Type)>, - pub calls: HashMap>, + pub calls: HashMap>, } impl TestEnvironment { diff --git a/nac3core/src/typecheck/typedef/mod.rs b/nac3core/src/typecheck/typedef/mod.rs index 37adb67f..20736dca 100644 --- a/nac3core/src/typecheck/typedef/mod.rs +++ b/nac3core/src/typecheck/typedef/mod.rs @@ -1,5 +1,5 @@ use itertools::{chain, zip, Itertools}; -use std::borrow::Cow; +use std::{borrow::Cow, sync::Arc}; use std::cell::RefCell; use std::collections::HashMap; use std::iter::once; @@ -70,7 +70,7 @@ pub enum TypeEnum { TVirtual { ty: Type, }, - TCall(RefCell>>), + TCall(RefCell>>), TFunc(FunSignature), }