From db3ca819283f9bd99d197de464717f0b58b52fe4 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 2 May 2019 17:07:11 +0200 Subject: Instead of possibly nonexistent Type, treat Sort specially --- dhall/src/traits/dynamic_type.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'dhall/src/traits/dynamic_type.rs') 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 DynamicType for T { impl<'a> DynamicType for Type<'a> { fn get_type(&self) -> Result>, 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>, 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>, TypeError> { - match &self.1 { - Some(t) => Ok(Cow::Borrowed(t)), - None => Err(TypeError::new( - &TypecheckContext::new(), - TypeMessage::Untyped, - )), - } + self.0.get_type() } } -- cgit v1.2.3