From 2c245e7f5ce4019381e0fa47a1e2caf6276106be Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sun, 1 Nov 2020 15:17:42 +0000 Subject: Store file cache in ImportEnv --- dhall/src/error/mod.rs | 4 ++-- dhall/src/semantics/resolve/cache.rs | 2 +- dhall/src/semantics/resolve/env.rs | 23 ++++++++++++++--------- dhall/src/semantics/resolve/resolve.rs | 14 +++++--------- 4 files changed, 22 insertions(+), 21 deletions(-) (limited to 'dhall') diff --git a/dhall/src/error/mod.rs b/dhall/src/error/mod.rs index d533264..800b8c1 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::{ImportLocation, ImportStack}; +use crate::semantics::resolve::{CyclesStack, ImportLocation}; use crate::syntax::{Import, ParseError}; mod builder; @@ -31,7 +31,7 @@ pub enum ImportError { MissingEnvVar, SanityCheck, UnexpectedImport(Import<()>), - ImportCycle(ImportStack, ImportLocation), + ImportCycle(CyclesStack, ImportLocation), Url(url::ParseError), } diff --git a/dhall/src/semantics/resolve/cache.rs b/dhall/src/semantics/resolve/cache.rs index 164baea..dd686ea 100644 --- a/dhall/src/semantics/resolve/cache.rs +++ b/dhall/src/semantics/resolve/cache.rs @@ -40,7 +40,7 @@ fn load_cache_dir( Err(CacheError::MissingConfiguration) } -#[derive(Debug, PartialEq)] +#[derive(Debug, Clone, PartialEq)] pub struct Cache { cache_dir: Option, } diff --git a/dhall/src/semantics/resolve/env.rs b/dhall/src/semantics/resolve/env.rs index 25d2277..4d502ce 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, ImportLocation, TypedHir, VarEnv}; +use crate::semantics::{AlphaVar, Cache, ImportLocation, TypedHir, VarEnv}; use crate::syntax::{Label, V}; /// Environment for resolving names. @@ -10,14 +10,15 @@ pub struct NameEnv { names: Vec