From 47c0a3ca296a9b775275c2c7118a172b9f0bcc54 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 8 Apr 2019 18:23:55 +0200 Subject: clippy --- dhall/src/normalize.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'dhall/src/normalize.rs') diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs index a43f73f..2454db4 100644 --- a/dhall/src/normalize.rs +++ b/dhall/src/normalize.rs @@ -14,7 +14,7 @@ impl Typed { } } -fn apply_builtin(b: Builtin, args: &Vec>) -> WhatNext +fn apply_builtin(b: Builtin, args: &[Expr]) -> WhatNext where S: fmt::Debug + Clone, A: fmt::Debug + Clone, @@ -22,7 +22,7 @@ where use dhall_core::Builtin::*; use dhall_core::ExprF::*; use WhatNext::*; - let (ret, rest) = match (b, args.as_slice()) { + let (ret, rest) = match (b, args) { (OptionalSome, [x, rest..]) => (rc(NEOptionalLit(x.roll())), rest), (OptionalNone, [t, rest..]) => (rc(EmptyOptionalLit(t.roll())), rest), (NaturalIsZero, [NaturalLit(n), rest..]) => { @@ -80,19 +80,22 @@ where (rc(NEListLit(xs)), rest) } (ListBuild, [a0, g, rest..]) => { - loop { + 'ret: { if let App(f2, args2) = g { if let (Builtin(ListFold), [_, x, rest_inner..]) = (f2.as_ref(), args2.as_slice()) { // fold/build fusion - break (rc(App(x.clone(), rest_inner.to_vec())), rest); + break 'ret ( + rc(App(x.clone(), rest_inner.to_vec())), + rest, + ); } }; let a0 = a0.roll(); let a1 = shift(1, &V("a".into(), 0), &a0); let g = g.roll(); - break ( + break 'ret ( dhall_expr!( g (List a0) @@ -104,18 +107,21 @@ where } } (OptionalBuild, [a0, g, rest..]) => { - loop { + 'ret: { if let App(f2, args2) = g { if let (Builtin(OptionalFold), [_, x, rest_inner..]) = (f2.as_ref(), args2.as_slice()) { // fold/build fusion - break (rc(App(x.clone(), rest_inner.to_vec())), rest); + break 'ret ( + rc(App(x.clone(), rest_inner.to_vec())), + rest, + ); } }; let a0 = a0.roll(); let g = g.roll(); - break ( + break 'ret ( dhall_expr!( g (Optional a0) @@ -155,17 +161,20 @@ where // normalize_ref(&App(bx(x.clone()), rest.to_vec())) // } (NaturalBuild, [g, rest..]) => { - loop { + 'ret: { if let App(f2, args2) = g { if let (Builtin(NaturalFold), [x, rest_inner..]) = (f2.as_ref(), args2.as_slice()) { // fold/build fusion - break (rc(App(x.clone(), rest_inner.to_vec())), rest); + break 'ret ( + rc(App(x.clone(), rest_inner.to_vec())), + rest, + ); } }; let g = g.roll(); - break ( + break 'ret ( dhall_expr!(g Natural (λ(x : Natural) -> x + 1) 0), rest, ); @@ -270,8 +279,8 @@ where BinOp(ListAppend, EmptyListLit(_), y) => DoneRef(y), BinOp(ListAppend, x, EmptyListLit(_)) => DoneRef(x), BinOp(ListAppend, NEListLit(xs), NEListLit(ys)) => { - let xs = xs.into_iter().cloned(); - let ys = ys.into_iter().cloned(); + let xs = xs.iter().cloned(); + let ys = ys.iter().cloned(); Done(NEListLit(xs.chain(ys).collect())) } Merge(RecordLit(handlers), UnionLit(k, v, _), _) => { -- cgit v1.2.3