From a3990858840a737d7831be45953b38bd67361fb7 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 18 Feb 2020 19:08:53 +0000 Subject: Discard import headers while we don't use them --- dhall/src/error/mod.rs | 4 ++-- dhall/src/semantics/resolve/hir.rs | 10 +--------- dhall/src/semantics/resolve/resolve.rs | 9 +++++++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs index 51bd549..b8f2fca 100644 --- a/dhall/src/error/mod.rs +++ b/dhall/src/error/mod.rs @@ -27,8 +27,8 @@ pub(crate) enum ErrorKind { #[derive(Debug)] pub(crate) enum ImportError { - UnexpectedImport(Import), - ImportCycle(ImportStack, Import), + UnexpectedImport(Import<()>), + ImportCycle(ImportStack, Import<()>), } #[derive(Debug)] diff --git a/dhall/src/semantics/resolve/hir.rs b/dhall/src/semantics/resolve/hir.rs index d0bec5a..73fc371 100644 --- a/dhall/src/semantics/resolve/hir.rs +++ b/dhall/src/semantics/resolve/hir.rs @@ -9,7 +9,7 @@ pub struct AlphaVar { idx: usize, } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq)] pub(crate) enum HirKind { /// A resolved variable (i.e. a DeBruijn index) Var(AlphaVar), @@ -128,11 +128,3 @@ impl std::cmp::PartialEq for Hir { } } impl std::cmp::Eq for Hir {} -impl std::hash::Hash for Hir { - fn hash(&self, state: &mut H) - where - H: std::hash::Hasher, - { - self.kind.hash(state) - } -} diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs index 22fb1a0..23d4c3d 100644 --- a/dhall/src/semantics/resolve/resolve.rs +++ b/dhall/src/semantics/resolve/resolve.rs @@ -8,7 +8,8 @@ use crate::syntax; use crate::syntax::{BinOp, Expr, ExprKind, FilePath, ImportLocation, URL}; use crate::{Parsed, ParsedExpr, Resolved}; -pub(crate) type Import = syntax::Import; +// TODO: evaluate import headers +pub(crate) type Import = syntax::Import<()>; /// A root from which to resolve relative imports. #[derive(Debug, Clone, PartialEq, Eq)] @@ -120,7 +121,11 @@ fn traverse_resolve_expr( Ok::<_, Error>(hir) })?; let kind = match kind { - ExprKind::Import(import) => f(import)?.kind().clone(), + ExprKind::Import(import) => { + // TODO: evaluate import headers + let import = import.traverse_ref(|_| Ok::<_, Error>(()))?; + f(import)?.kind().clone() + } kind => HirKind::Expr(kind), }; Hir::new(kind, expr.span()) -- cgit v1.2.3