From 1b1c34b90bb4bf3859b05b1da6db2dcb374996bb Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 4 May 2019 14:58:18 +0200 Subject: Move `Note`s into the spine of the AST --- dhall_syntax/src/printer.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'dhall_syntax/src/printer.rs') diff --git a/dhall_syntax/src/printer.rs b/dhall_syntax/src/printer.rs index 704000a..e3b180b 100644 --- a/dhall_syntax/src/printer.rs +++ b/dhall_syntax/src/printer.rs @@ -3,7 +3,7 @@ use itertools::Itertools; use std::fmt::{self, Display}; /// Generic instance that delegates to subexpressions -impl Display for ExprF { +impl Display for ExprF { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { use crate::ExprF::*; match self { @@ -102,7 +102,6 @@ impl Display for ExprF { f.write_str(" >")? } Embed(a) => a.fmt(f)?, - Note(_, b) => b.fmt(f)?, } Ok(()) } @@ -143,7 +142,7 @@ impl Expr { fn fmt_phase( &self, f: &mut fmt::Formatter, - mut phase: PrintPhase, + phase: PrintPhase, ) -> Result<(), fmt::Error> { use crate::ExprF::*; use PrintPhase::*; @@ -170,10 +169,6 @@ impl Expr { _ => false, }; - if needs_paren { - phase = Base; - } - // Annotate subexpressions with the appropriate phase, defaulting to Base let phased_self = match self.map_ref_simple(|e| PhasedExpr(e, Base)) { Pi(a, b, c) => { @@ -200,7 +195,6 @@ impl Expr { ExprF::App(f, a) => ExprF::App(f.phase(Import), a.phase(Import)), Field(a, b) => Field(a.phase(Primitive), b), Projection(e, ls) => Projection(e.phase(Primitive), ls), - Note(n, b) => Note(n, b.phase(phase)), e => e, }; -- cgit v1.2.3