From d035e6ea0783cc270b70238bbbc1387fe511e576 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 27 Dec 2019 15:17:58 +0000 Subject: TypecheckContext doesn't need PartialEq --- dhall/src/semantics/core/context.rs | 9 --------- 1 file changed, 9 deletions(-) (limited to 'dhall') diff --git a/dhall/src/semantics/core/context.rs b/dhall/src/semantics/core/context.rs index f755f72..79f2737 100644 --- a/dhall/src/semantics/core/context.rs +++ b/dhall/src/semantics/core/context.rs @@ -133,12 +133,3 @@ impl Subst for TypecheckContext { self.subst_shift(var, val) } } - -/// Don't count contexts when comparing stuff. -/// This is dirty but needed. -impl PartialEq for TypecheckContext { - fn eq(&self, _: &Self) -> bool { - true - } -} -impl Eq for TypecheckContext {} -- cgit v1.2.3 From 89003e1652a41419a1b6dd14f0a8a0769911a7cc Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 27 Dec 2019 15:21:37 +0000 Subject: TypecheckContext doesn't need Rc It's almost never cloned anymore --- dhall/src/semantics/core/context.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'dhall') diff --git a/dhall/src/semantics/core/context.rs b/dhall/src/semantics/core/context.rs index 79f2737..c198e8e 100644 --- a/dhall/src/semantics/core/context.rs +++ b/dhall/src/semantics/core/context.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::rc::Rc; use crate::error::TypeError; use crate::semantics::core::value::Value; @@ -14,21 +13,24 @@ enum CtxItem { } #[derive(Debug, Clone)] -pub(crate) struct TypecheckContext(Rc>); +pub(crate) struct TypecheckContext(Vec<(Label, CtxItem)>); impl TypecheckContext { pub fn new() -> Self { - TypecheckContext(Rc::new(Vec::new())) + TypecheckContext(Vec::new()) + } + fn with_vec(&self, vec: Vec<(Label, CtxItem)>) -> Self { + TypecheckContext(vec) } pub fn insert_type(&self, x: &Label, t: Value) -> Self { - let mut vec = self.0.as_ref().clone(); + let mut vec = self.0.clone(); vec.push((x.clone(), CtxItem::Kept(x.into(), t.under_binder(x)))); - TypecheckContext(Rc::new(vec)) + self.with_vec(vec) } pub fn insert_value(&self, x: &Label, e: Value) -> Result { - let mut vec = self.0.as_ref().clone(); + let mut vec = self.0.clone(); vec.push((x.clone(), CtxItem::Replaced(e))); - Ok(TypecheckContext(Rc::new(vec))) + Ok(self.with_vec(vec)) } pub fn lookup(&self, var: &V