From 31cefbdf0364a3d224420365049885051734669b Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 4 Mar 2020 21:36:41 +0000 Subject: Cache imports correctly --- dhall/build.rs | 3 --- dhall/src/error/mod.rs | 4 ++-- dhall/src/semantics/resolve/env.rs | 24 ++++++++++++------------ dhall/src/semantics/resolve/resolve.rs | 14 +++++++------- dhall/tests/import/failure/cycle.txt | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/dhall/build.rs b/dhall/build.rs index 565c37e..4bd56a3 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -324,9 +324,6 @@ fn generate_tests() -> std::io::Result<()> { // Too slow, but also not all features implemented // For now needs support for hashed imports || path == "prelude" - // TODO: remote imports - || path == "CacheImports" - || path == "CacheImportsCanonicalize" }), input_type: FileType::Text, output_type: Some(FileType::Text), diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs index 29dd5ad..6dd8393 100644 --- a/dhall/src/error/mod.rs +++ b/dhall/src/error/mod.rs @@ -1,6 +1,6 @@ use std::io::Error as IOError; -use crate::semantics::resolve::ImportStack; +use crate::semantics::resolve::{ImportLocation, ImportStack}; use crate::syntax::{Import, ParseError}; mod builder; @@ -29,7 +29,7 @@ pub(crate) enum ImportError { Missing, MissingEnvVar, UnexpectedImport(Import<()>), - ImportCycle(ImportStack, Import<()>), + ImportCycle(ImportStack, ImportLocation), Url(url::ParseError), } diff --git a/dhall/src/semantics/resolve/env.rs b/dhall/src/semantics/resolve/env.rs index 43676cc..2342dcc 100644 --- a/dhall/src/semantics/resolve/env.rs +++ b/dhall/src/semantics/resolve/env.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use crate::error::{Error, ImportError}; -use crate::semantics::{AlphaVar, Import, TypedHir, VarEnv}; +use crate::semantics::{AlphaVar, ImportLocation, TypedHir, VarEnv}; use crate::syntax::{Label, V}; /// Environment for resolving names. @@ -10,8 +10,8 @@ pub(crate) struct NameEnv { names: Vec