From a4ef23fd3e7a053def648dca05dfc9a043af9860 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 11 Apr 2019 19:04:19 +0200 Subject: Respect import boundaries Closes #54 --- dhall/src/expr.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'dhall/src/expr.rs') diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs index 30ca6c6..1ce20e3 100644 --- a/dhall/src/expr.rs +++ b/dhall/src/expr.rs @@ -25,11 +25,11 @@ pub struct Parsed(pub(crate) SubExpr, pub(crate) ImportRoot); derive_other_traits!(Parsed); #[derive(Debug, Clone, Eq)] -pub struct Resolved(pub(crate) SubExpr); +pub struct Resolved(pub(crate) SubExpr); derive_other_traits!(Resolved); #[derive(Debug, Clone, Eq)] -pub struct Typed(pub(crate) SubExpr, pub(crate) Option); +pub struct Typed(pub(crate) SubExpr, pub(crate) Option); derive_other_traits!(Typed); #[derive(Debug, Clone, Eq)] @@ -67,11 +67,19 @@ impl From> for SimpleType { } } +// Exposed for the macros +#[doc(hidden)] +impl From for Typed { + fn from(x: Normalized) -> Typed { + Typed(x.0.absurd(), x.1) + } +} + impl Typed { - pub(crate) fn as_expr(&self) -> &SubExpr { + pub(crate) fn as_expr(&self) -> &SubExpr { &self.0 } - pub(crate) fn into_expr(self) -> SubExpr { + pub(crate) fn into_expr(self) -> SubExpr { self.0 } } @@ -80,8 +88,8 @@ impl Normalized { pub(crate) fn as_expr(&self) -> &SubExpr { &self.0 } - pub(crate) fn into_expr(self) -> SubExpr { - self.0 + pub(crate) fn into_expr(self) -> SubExpr { + self.0.absurd() } pub(crate) fn into_type(self) -> Type { crate::expr::Type(TypeInternal::Expr(Box::new(self))) -- cgit v1.2.3