diff options
author | Nadrieril | 2019-05-02 17:07:11 +0200 |
---|---|---|
committer | Nadrieril | 2019-05-02 17:07:11 +0200 |
commit | db3ca819283f9bd99d197de464717f0b58b52fe4 (patch) | |
tree | 51ae89e9b1153a7f9b3aa5dae38cfe4441aef9af /dhall/src/traits/dynamic_type.rs | |
parent | c13a4881b56bf2f5b2d5d4d0018a48927b45e7e0 (diff) |
Instead of possibly nonexistent Type, treat Sort specially
Diffstat (limited to '')
-rw-r--r-- | dhall/src/traits/dynamic_type.rs | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/dhall/src/traits/dynamic_type.rs b/dhall/src/traits/dynamic_type.rs index c15b277..74c2e0a 100644 --- a/dhall/src/traits/dynamic_type.rs +++ b/dhall/src/traits/dynamic_type.rs @@ -1,9 +1,7 @@ use crate::expr::*; use crate::traits::StaticType; #[allow(unused_imports)] -use crate::typecheck::{ - type_of_const, TypeError, TypeMessage, TypecheckContext, -}; +use crate::typecheck::{TypeError, TypeMessage, TypecheckContext}; #[allow(unused_imports)] use dhall_core::{Const, ExprF}; use std::borrow::Cow; @@ -20,32 +18,18 @@ impl<T: StaticType> DynamicType for T { impl<'a> DynamicType for Type<'a> { fn get_type(&self) -> Result<Cow<'_, Type<'static>>, TypeError> { - Ok(Cow::Owned( - self.clone().into_normalized()?.get_type()?.into_owned(), - )) + self.get_type() } } impl<'a> DynamicType for Normalized<'a> { fn get_type(&self) -> Result<Cow<'_, Type<'static>>, TypeError> { - match &self.1 { - Some(t) => Ok(Cow::Borrowed(t)), - None => Err(TypeError::new( - &TypecheckContext::new(), - TypeMessage::Untyped, - )), - } + self.0.get_type() } } impl<'a> DynamicType for Typed<'a> { fn get_type(&self) -> Result<Cow<'_, Type<'static>>, TypeError> { - match &self.1 { - Some(t) => Ok(Cow::Borrowed(t)), - None => Err(TypeError::new( - &TypecheckContext::new(), - TypeMessage::Untyped, - )), - } + self.0.get_type() } } |