From 0d3b31ab8e2f0b9977ef718bb2256de37e714d3a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 16 Apr 2019 16:22:24 +0200 Subject: Revert "Preserve notes when normalizing" This reverts commit fd9e37dfbc49e850a784fa3e907bd0a358d91e28. --- dhall/src/normalize.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'dhall/src') diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index 076f889..fa669d8 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -221,20 +221,16 @@ enum WhatNext<'a, N, E> { // The following expression is the normal form Done(Expr), DoneRef(&'a Expr), - DoneSub(SubExpr), DoneRefSub(&'a SubExpr), // The current expression is already in normal form DoneAsIs, } -fn normalize_ref(expr: &Expr>) -> Expr -where - N: fmt::Debug + Clone, -{ +fn normalize_ref(expr: &Expr>) -> Expr { use dhall_core::BinOp::*; use dhall_core::ExprF::*; // Recursively normalize all subexpressions - let expr: ExprF, Label, N, Normalized<'static>> = + let expr: ExprF, Label, X, Normalized<'static>> = expr.map_ref_simple(|e| normalize_ref(e.as_ref())); use WhatNext::*; @@ -245,6 +241,7 @@ where ContinueSub(subst_shift(vf0, &r.roll(), &b.roll())) } Annot(x, _) => DoneRef(x), + Note(_, e) => DoneRef(e), App(f, args) if args.is_empty() => DoneRef(f), App(App(f, args1), args2) => Continue(App( f.clone(), @@ -306,7 +303,7 @@ where .filter_map(|l| kvs.get(l).map(|x| (l.clone(), x.clone()))) .collect(), )), - Embed(e) => DoneSub(e.0.note_absurd()), + Embed(e) => DoneRefSub(&e.0), _ => DoneAsIs, }; @@ -315,13 +312,12 @@ where ContinueSub(e) => normalize_ref(e.absurd().as_ref()), Done(e) => e, DoneRef(e) => e.clone(), - DoneSub(e) => e.unroll(), DoneRefSub(e) => e.unroll(), DoneAsIs => match expr.map_ref_simple(ExprF::roll) { e => e.map_ref( SubExpr::clone, |_, e| e.clone(), - N::clone, + X::clone, |_| unreachable!(), Label::clone, ), @@ -338,10 +334,7 @@ where /// However, `normalize` will not fail if the expression is ill-typed and will /// leave ill-typed sub-expressions unevaluated. /// -fn normalize(e: SubExpr>) -> SubExpr -where - N: fmt::Debug + Clone, -{ +fn normalize(e: SubExpr>) -> SubExpr { normalize_ref(e.as_ref()).roll() } -- cgit v1.2.3