From f691fbb4dc1adb65c909ae53af4aac256c4179b3 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Mon, 4 Jan 2021 14:47:43 +0800 Subject: [PATCH] formatting --- nac3core/src/context/inference_context.rs | 7 ++---- nac3core/src/context/mod.rs | 5 ++--- nac3core/src/expression_inference.rs | 26 +++++++---------------- nac3core/src/primitives.rs | 11 ++++++---- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/nac3core/src/context/inference_context.rs b/nac3core/src/context/inference_context.rs index a03889f75c..d056e3d4e8 100644 --- a/nac3core/src/context/inference_context.rs +++ b/nac3core/src/context/inference_context.rs @@ -121,7 +121,7 @@ impl<'a> InferenceContext<'a> { /// get the type of an identifier /// may return error if the identifier is not defined, and cannot be resolved with the /// resolution function. - pub fn resolve(&mut self, name: & str) -> Result { + pub fn resolve(&mut self, name: &str) -> Result { if let Some((t, x)) = self.sym_table.get(name) { if *x { Ok(t.clone()) @@ -194,10 +194,7 @@ impl TypeEnum { match self { TypeEnum::ParametricType(id, params) => TypeEnum::ParametricType( *id, - params - .iter() - .map(|v| v.as_ref().inv_subst(map)) - .collect(), + params.iter().map(|v| v.as_ref().inv_subst(map)).collect(), ), _ => self.clone(), } diff --git a/nac3core/src/context/mod.rs b/nac3core/src/context/mod.rs index 88e2a43a09..f59140d94a 100644 --- a/nac3core/src/context/mod.rs +++ b/nac3core/src/context/mod.rs @@ -1,5 +1,4 @@ -mod top_level_context; mod inference_context; -pub use top_level_context::TopLevelContext; +mod top_level_context; pub use inference_context::InferenceContext; - +pub use top_level_context::TopLevelContext; diff --git a/nac3core/src/expression_inference.rs b/nac3core/src/expression_inference.rs index 8ec37303ee..34acf4ddc7 100644 --- a/nac3core/src/expression_inference.rs +++ b/nac3core/src/expression_inference.rs @@ -532,15 +532,9 @@ mod test { parents: vec![], }); let foo_def = ctx.get_class_def_mut(foo); - foo_def - .base - .fields - .insert("a", int32.clone()); + foo_def.base.fields.insert("a", int32.clone()); foo_def.base.fields.insert("b", ClassType(foo).into()); - foo_def - .base - .fields - .insert("c", int32.clone()); + foo_def.base.fields.insert("c", int32.clone()); let bar = ctx.add_class(ClassDef { base: TypeDef { @@ -551,15 +545,9 @@ mod test { parents: vec![], }); let bar_def = ctx.get_class_def_mut(bar); - bar_def - .base - .fields - .insert("a", int32); + bar_def.base.fields.insert("a", int32); bar_def.base.fields.insert("b", ClassType(bar).into()); - bar_def - .base - .fields - .insert("c", float); + bar_def.base.fields.insert("c", float); let v0 = ctx.add_variable(VarDef { name: "v0", @@ -574,7 +562,8 @@ mod test { let mut ctx = get_inference_context(ctx); ctx.assign("foo", Rc::new(ClassType(foo))).unwrap(); ctx.assign("bar", Rc::new(ClassType(bar))).unwrap(); - ctx.assign("foobar", Rc::new(VirtualClassType(foo))).unwrap(); + ctx.assign("foobar", Rc::new(VirtualClassType(foo))) + .unwrap(); ctx.assign("v0", ctx.get_variable(v0)).unwrap(); ctx.assign("v1", ctx.get_variable(v1)).unwrap(); ctx.assign("bot", Rc::new(BotType)).unwrap(); @@ -790,7 +779,8 @@ mod test { let mut ctx = get_inference_context(ctx); ctx.assign("foo", Rc::new(ClassType(foo))).unwrap(); ctx.assign("bar", Rc::new(ClassType(bar))).unwrap(); - ctx.assign("foobar", Rc::new(VirtualClassType(foo))).unwrap(); + ctx.assign("foobar", Rc::new(VirtualClassType(foo))) + .unwrap(); ctx.assign("v0", ctx.get_variable(v0)).unwrap(); ctx.assign("v1", ctx.get_variable(v1)).unwrap(); ctx.assign("v2", ctx.get_variable(v2)).unwrap(); diff --git a/nac3core/src/primitives.rs b/nac3core/src/primitives.rs index 7dceb358c7..e777749192 100644 --- a/nac3core/src/primitives.rs +++ b/nac3core/src/primitives.rs @@ -19,10 +19,13 @@ fn impl_math(def: &mut TypeDef, ty: &Type) { def.methods.insert("__add__", fun.clone()); def.methods.insert("__sub__", fun.clone()); def.methods.insert("__mul__", fun.clone()); - def.methods.insert("__neg__", FnDef { - args: vec![], - result - }); + def.methods.insert( + "__neg__", + FnDef { + args: vec![], + result, + }, + ); def.methods.insert( "__truediv__", FnDef {