From bb1f698c23a83f60020a72bb5be1f9a386c60d44 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 18 Apr 2019 11:58:21 +0200 Subject: Start cleaning up the mess of mapping functions --- dhall_generator/src/quote.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dhall_generator') diff --git a/dhall_generator/src/quote.rs b/dhall_generator/src/quote.rs index c335666..7128511 100644 --- a/dhall_generator/src/quote.rs +++ b/dhall_generator/src/quote.rs @@ -103,7 +103,7 @@ fn quote_subexpr( ctx: &Context, ) -> TokenStream { use dhall_core::ExprF::*; - match expr.as_ref().map_ref( + match expr.as_ref().map_ref_with_special_handling_of_binders( |e| quote_subexpr(e, ctx), |l, e| quote_subexpr(e, &ctx.insert(l.clone(), ())), |_| unreachable!(), @@ -138,7 +138,7 @@ fn quote_subexpr( // to be of type SubExpr<_, _>. fn quote_expr(expr: &Expr, ctx: &Context) -> TokenStream { use dhall_core::ExprF::*; - match expr.map_ref( + match expr.map_ref_with_special_handling_of_binders( |e| quote_subexpr(e, ctx), |l, e| quote_subexpr(e, &ctx.insert(l.clone(), ())), |_| unreachable!(), -- cgit v1.2.3 From e68e34f361a29e0661201ac3c93a711a9884833f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 18 Apr 2019 13:15:42 +0200 Subject: Reduce duplication between mapping functions --- dhall_generator/src/quote.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'dhall_generator') diff --git a/dhall_generator/src/quote.rs b/dhall_generator/src/quote.rs index 7128511..d680288 100644 --- a/dhall_generator/src/quote.rs +++ b/dhall_generator/src/quote.rs @@ -10,7 +10,7 @@ pub fn expr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let expr: SubExpr<_, Import> = parse_expr(&input_str).unwrap().unnote(); let no_import = |_: &Import| -> X { panic!("Don't use import in dhall::expr!()") }; - let expr = expr.as_ref().map_embed(&no_import); + let expr = expr.as_ref().map_embed(no_import); let output = quote_expr(&expr, &Context::new()); output.into() } @@ -20,7 +20,7 @@ pub fn subexpr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let expr: SubExpr<_, Import> = parse_expr(&input_str).unwrap().unnote(); let no_import = |_: &Import| -> X { panic!("Don't use import in dhall::subexpr!()") }; - let expr = expr.as_ref().map_embed(&no_import); + let expr = expr.as_ref().map_embed(no_import); let output = quote_subexpr(&dhall_core::rc(expr), &Context::new()); output.into() } -- cgit v1.2.3 From 9474d4939db6f844285182fc15aad74f6aa18e21 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Thu, 18 Apr 2019 14:39:56 +0200 Subject: Remove more duplication --- dhall_generator/src/quote.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'dhall_generator') diff --git a/dhall_generator/src/quote.rs b/dhall_generator/src/quote.rs index d680288..400c12c 100644 --- a/dhall_generator/src/quote.rs +++ b/dhall_generator/src/quote.rs @@ -10,8 +10,8 @@ pub fn expr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let expr: SubExpr<_, Import> = parse_expr(&input_str).unwrap().unnote(); let no_import = |_: &Import| -> X { panic!("Don't use import in dhall::expr!()") }; - let expr = expr.as_ref().map_embed(no_import); - let output = quote_expr(&expr, &Context::new()); + let expr = expr.map_embed(no_import); + let output = quote_expr(&expr.unroll(), &Context::new()); output.into() } @@ -20,8 +20,8 @@ pub fn subexpr(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let expr: SubExpr<_, Import> = parse_expr(&input_str).unwrap().unnote(); let no_import = |_: &Import| -> X { panic!("Don't use import in dhall::subexpr!()") }; - let expr = expr.as_ref().map_embed(no_import); - let output = quote_subexpr(&dhall_core::rc(expr), &Context::new()); + let expr = expr.map_embed(no_import); + let output = quote_subexpr(&expr, &Context::new()); output.into() } -- cgit v1.2.3