From 78a0c10a4595683c034b8d3617f55c88cea2aa3c Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Fri, 8 Mar 2019 18:17:22 +0100 Subject: Slowly propagate the new type parameter throughout the codebase --- dhall_generator/src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'dhall_generator') diff --git a/dhall_generator/src/lib.rs b/dhall_generator/src/lib.rs index 1cc62d0..7f2e295 100644 --- a/dhall_generator/src/lib.rs +++ b/dhall_generator/src/lib.rs @@ -4,8 +4,6 @@ use dhall_core::*; use proc_macro2::Literal; use proc_macro2::TokenStream; use quote::quote; -use std::fmt::Debug; -use std::hash::Hash; #[proc_macro] pub fn dhall(input: proc_macro::TokenStream) -> proc_macro::TokenStream { @@ -20,7 +18,7 @@ pub fn dhall(input: proc_macro::TokenStream) -> proc_macro::TokenStream { // Returns an expression of type Expr<_, _>. Expects input variables // to be of type Box> (future-proof for structural sharing). -fn dhall_to_tokenstream>( +fn dhall_to_tokenstream( expr: &Expr_, ctx: &Context, ) -> TokenStream { @@ -34,7 +32,7 @@ fn dhall_to_tokenstream>( let t = dhall_to_tokenstream_bx(t, ctx); let b = dhall_to_tokenstream_bx(b, &ctx.insert(x.clone(), ())); let x = Literal::string(&x.clone().into()); - quote! { Lam(#x, #t, #b) } + quote! { Lam(#x.to_owned().into(), #t, #b) } } App(f, a) => { let f = dhall_to_tokenstream_bx(f, ctx); @@ -76,18 +74,18 @@ fn dhall_to_tokenstream>( } // Returns an expression of type Box> -fn dhall_to_tokenstream_bx>( +fn dhall_to_tokenstream_bx( expr: &Expr_, ctx: &Context, ) -> TokenStream { use dhall_core::Expr_::*; match expr { Var(V(s, n)) => { - match ctx.lookup(s.clone(), *n) { + match ctx.lookup(&s, *n) { // Non-free variable; interpolates as itself Some(()) => { let s: String = s.clone().into(); - quote! { bx(Var(V(#s, #n))) } + quote! { bx(Var(V(#s.to_owned().into(), #n))) } } // Free variable; interpolates as a rust variable None => { @@ -95,7 +93,7 @@ fn dhall_to_tokenstream_bx>( // TODO: insert appropriate shifts ? let v: TokenStream = s.parse().unwrap(); quote! { { - let x: Box> = #v.clone(); + let x: Box> = #v.clone(); x } } } -- cgit v1.2.3