From b6f57069b75febf1d312a98efcd6544c9db2fe59 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 4 May 2019 14:19:43 +0200 Subject: Remove dummy lifetimes --- dhall/src/expr.rs | 100 ++++++++++------------- dhall/src/imports.rs | 86 ++++++++++---------- dhall/src/normalize.rs | 50 ++++-------- dhall/src/traits/deserialize.rs | 10 +-- dhall/src/traits/dynamic_type.rs | 16 ++-- dhall/src/traits/static_type.rs | 40 +++++----- dhall/src/typecheck.rs | 167 +++++++++++++++++---------------------- 7 files changed, 202 insertions(+), 267 deletions(-) (limited to 'dhall/src') diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs index b0b6215..db426ce 100644 --- a/dhall/src/expr.rs +++ b/dhall/src/expr.rs @@ -1,19 +1,18 @@ use crate::imports::ImportRoot; use crate::normalize::{Thunk, Value}; use dhall_syntax::*; -use std::marker::PhantomData; macro_rules! derive_other_traits { ($ty:ident) => { - impl<'a> std::cmp::PartialEq for $ty<'a> { + impl std::cmp::PartialEq for $ty { fn eq(&self, other: &Self) -> bool { self.0 == other.0 } } - impl<'a> std::cmp::Eq for $ty<'a> {} + impl std::cmp::Eq for $ty {} - impl<'a> std::fmt::Display for $ty<'a> { + impl std::fmt::Display for $ty { fn fmt( &self, f: &mut std::fmt::Formatter, @@ -25,41 +24,33 @@ macro_rules! derive_other_traits { } #[derive(Debug, Clone)] -pub(crate) struct Parsed<'a>( - pub(crate) SubExpr, Import>, +pub(crate) struct Parsed( + pub(crate) SubExpr, pub(crate) ImportRoot, ); derive_other_traits!(Parsed); #[derive(Debug, Clone)] -pub(crate) struct Resolved<'a>( - pub(crate) SubExpr, Normalized<'static>>, -); +pub(crate) struct Resolved(pub(crate) SubExpr); derive_other_traits!(Resolved); pub(crate) use self::typed::TypedInternal; #[derive(Debug, Clone)] -pub(crate) struct Typed<'a>( - pub(crate) TypedInternal, - pub(crate) PhantomData<&'a ()>, -); +pub(crate) struct Typed(pub(crate) TypedInternal); #[derive(Debug, Clone)] -pub(crate) struct Normalized<'a>( - pub(crate) TypedInternal, - pub(crate) PhantomData<&'a ()>, -); +pub(crate) struct Normalized(pub(crate) TypedInternal); -impl<'a> std::cmp::PartialEq for Normalized<'a> { +impl std::cmp::PartialEq for Normalized { fn eq(&self, other: &Self) -> bool { self.to_expr() == other.to_expr() } } -impl<'a> std::cmp::Eq for Normalized<'a> {} +impl std::cmp::Eq for Normalized {} -impl<'a> std::fmt::Display for Normalized<'a> { +impl std::fmt::Display for Normalized { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { self.to_expr().fmt(f) } @@ -73,18 +64,17 @@ mod typed { }; use dhall_syntax::{Const, Label, SubExpr, V, X}; use std::borrow::Cow; - use std::marker::PhantomData; #[derive(Debug, Clone)] pub(crate) enum TypedInternal { // The `Sort` higher-kinded type doesn't have a type Sort, // Any other value, along with its type - Value(Thunk, Option>), + Value(Thunk, Option), } impl TypedInternal { - pub(crate) fn from_thunk_and_type(th: Thunk, t: Type<'static>) -> Self { + pub(crate) fn from_thunk_and_type(th: Thunk, t: Type) -> Self { TypedInternal::Value(th, Some(t)) } @@ -113,22 +103,19 @@ mod typed { } } - pub(crate) fn to_type(&self) -> Type<'static> { + pub(crate) fn to_type(&self) -> Type { match self { TypedInternal::Sort => Type(TypeInternal::Const(Const::Sort)), TypedInternal::Value(th, _) => match &*th.as_value() { Value::Const(c) => Type(TypeInternal::Const(*c)), - _ => Type(TypeInternal::Typed(Box::new(Typed( - self.clone(), - PhantomData, - )))), + _ => { + Type(TypeInternal::Typed(Box::new(Typed(self.clone())))) + } }, } } - pub(crate) fn get_type( - &self, - ) -> Result>, TypeError> { + pub(crate) fn get_type(&self) -> Result, TypeError> { match self { TypedInternal::Value(_, Some(t)) => Ok(Cow::Borrowed(t)), TypedInternal::Value(_, None) => Err(TypeError::new( @@ -152,11 +139,7 @@ mod typed { } } - pub(crate) fn subst_shift( - &self, - var: &V