diff options
Diffstat (limited to 'dhall')
-rw-r--r-- | dhall/Cargo.toml | 1 | ||||
-rw-r--r-- | dhall/src/semantics/core/value.rs | 47 |
2 files changed, 22 insertions, 26 deletions
diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index b795898..1479eaa 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -19,7 +19,6 @@ pest_consume = "1.0" serde = "1.0" serde_cbor = "0.9.0" smallvec = "1.0.0" -take_mut = "0.2.2" [dev-dependencies] pretty_assertions = "0.6.1" diff --git a/dhall/src/semantics/core/value.rs b/dhall/src/semantics/core/value.rs index 0fda870..f6d273c 100644 --- a/dhall/src/semantics/core/value.rs +++ b/dhall/src/semantics/core/value.rs @@ -412,33 +412,30 @@ impl ValueInternal { } fn normalize_whnf(&mut self) { - take_mut::take_or_recover( - self, - // Dummy value in case the other closure panics - || ValueInternal { - form: Unevaled, - kind: ValueKind::Const(Const::Type), - ty: None, - span: Span::Artificial, + let dummy = ValueInternal { + form: Unevaled, + kind: ValueKind::Const(Const::Type), + ty: None, + span: Span::Artificial, + }; + let vint = std::mem::replace(self, dummy); + *self = match (&vint.form, &vint.ty) { + (Unevaled, Some(ty)) => ValueInternal { + form: WHNF, + kind: normalize_whnf(vint.kind, &ty), + ty: vint.ty, + span: vint.span, }, - |vint| match (&vint.form, &vint.ty) { - (Unevaled, Some(ty)) => ValueInternal { - form: WHNF, - kind: normalize_whnf(vint.kind, &ty), - ty: vint.ty, - span: vint.span, - }, - // `value` is `Sort` - (Unevaled, None) => ValueInternal { - form: NF, - kind: ValueKind::Const(Const::Sort), - ty: None, - span: vint.span, - }, - // Already in WHNF - (WHNF, _) | (NF, _) => vint, + // `value` is `Sort` + (Unevaled, None) => ValueInternal { + form: NF, + kind: ValueKind::Const(Const::Sort), + ty: None, + span: vint.span, }, - ) + // Already in WHNF + (WHNF, _) | (NF, _) => vint, + } } fn normalize_nf(&mut self) { match self.form { |