summaryrefslogtreecommitdiff
path: root/dhall/src/semantics
diff options
context:
space:
mode:
authorNadrieril2020-01-30 14:13:09 +0000
committerNadrieril2020-01-30 14:13:09 +0000
commitadbf51213a0df5d645d3d9423f0b284f5aff9a4e (patch)
tree87b40c6495cf2ac5397001922622042543ba48dd /dhall/src/semantics
parent17732b041dbd44f39ce3d04a289146db9882e865 (diff)
Remove use of take_mut
Diffstat (limited to '')
-rw-r--r--dhall/src/semantics/core/value.rs47
1 files changed, 22 insertions, 25 deletions
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 {