From 3c522217b7445c6df9e170d830f485086ad7e062 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 7 Dec 2020 13:47:21 +0000 Subject: Tag cx ids with the cx lifetime To make sure we don't let ids escape and we don't mix scopes. --- dhall/src/semantics/resolve/env.rs | 6 +++--- dhall/src/semantics/resolve/resolve.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'dhall/src/semantics') diff --git a/dhall/src/semantics/resolve/env.rs b/dhall/src/semantics/resolve/env.rs index 2b998f8..ba6205f 100644 --- a/dhall/src/semantics/resolve/env.rs +++ b/dhall/src/semantics/resolve/env.rs @@ -17,7 +17,7 @@ pub type CyclesStack = Vec; pub struct ImportEnv<'cx> { cx: Ctxt<'cx>, disk_cache: Option, // `None` if it failed to initialize - mem_cache: HashMap, + mem_cache: HashMap>, stack: CyclesStack, } @@ -82,7 +82,7 @@ impl<'cx> ImportEnv<'cx> { pub fn get_from_mem_cache( &self, location: &ImportLocation, - ) -> Option { + ) -> Option> { Some(*self.mem_cache.get(location)?) } @@ -98,7 +98,7 @@ impl<'cx> ImportEnv<'cx> { pub fn write_to_mem_cache( &mut self, location: ImportLocation, - result: ImportResultId, + result: ImportResultId<'cx>, ) { self.mem_cache.insert(location, result); } diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs index 488c516..9021155 100644 --- a/dhall/src/semantics/resolve/resolve.rs +++ b/dhall/src/semantics/resolve/resolve.rs @@ -398,7 +398,7 @@ fn traverse_resolve_expr<'cx>( /// Fetch the import and store the result in the global context. fn fetch_import<'cx>( env: &mut ImportEnv<'cx>, - import_id: ImportId, + import_id: ImportId<'cx>, ) -> Result<(), Error> { let cx = env.cx(); let import = &cx[import_id].import; -- cgit v1.2.3