summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
authorNadrieril2019-04-18 14:39:56 +0200
committerNadrieril2019-04-18 14:39:56 +0200
commit9474d4939db6f844285182fc15aad74f6aa18e21 (patch)
tree7f14c06afccd10e32c3003555bce809e713d2bfe /dhall/src
parent69267c7cc108a2f5db35c52a71afaa5be7be7355 (diff)
Remove more duplication
Diffstat (limited to '')
-rw-r--r--dhall/src/expr.rs2
-rw-r--r--dhall/src/imports.rs8
-rw-r--r--dhall/src/normalize.rs18
-rw-r--r--dhall/src/traits/dynamic_type.rs2
-rw-r--r--dhall/src/typecheck.rs6
5 files changed, 17 insertions, 19 deletions
diff --git a/dhall/src/expr.rs b/dhall/src/expr.rs
index 7c62a33..5885359 100644
--- a/dhall/src/expr.rs
+++ b/dhall/src/expr.rs
@@ -98,7 +98,7 @@ impl<'a> From<SubExpr<X, X>> for SimpleType<'a> {
#[doc(hidden)]
impl<'a> From<Normalized<'a>> for Typed<'a> {
fn from(x: Normalized<'a>) -> Typed<'a> {
- Typed(x.0.absurd(), x.1, x.2)
+ Typed(x.0.embed_absurd(), x.1, x.2)
}
}
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index b6dd80b..e367725 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -98,8 +98,8 @@ fn do_resolve_expr<'a>(
}
}
};
- let expr = expr.as_ref().traverse_embed(resolve)?;
- Ok(Resolved(rc(expr)))
+ let expr = expr.traverse_embed(resolve)?;
+ Ok(Resolved(expr))
}
fn skip_resolve_expr(
@@ -109,8 +109,8 @@ fn skip_resolve_expr(
|import: &Import| -> Result<Normalized<'static>, ImportError> {
Err(ImportError::UnexpectedImport(import.clone()))
};
- let expr = expr.as_ref().traverse_embed(&resolve)?;
- Ok(Resolved(rc(expr)))
+ let expr = expr.traverse_embed(resolve)?;
+ Ok(Resolved(expr))
}
impl<'a> Parsed<'a> {
diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs
index 9110624..a54e48e 100644
--- a/dhall/src/normalize.rs
+++ b/dhall/src/normalize.rs
@@ -325,19 +325,17 @@ fn normalize_ref(expr: &Expr<X, Normalized<'static>>) -> Expr<X, X> {
};
match what_next {
- Continue(e) => normalize_ref(&e.absurd_rec()),
- ContinueSub(e) => normalize_ref(e.absurd().as_ref()),
+ Continue(e) => normalize_ref(&e.embed_absurd()),
+ ContinueSub(e) => normalize_ref(e.embed_absurd().as_ref()),
Done(e) => e,
DoneRef(e) => e.clone(),
DoneRefSub(e) => e.unroll(),
- DoneAsIs => match expr.map_ref_simple(ExprF::roll) {
- e => e.map_ref(
- SubExpr::clone,
- X::clone,
- |_| unreachable!(),
- Label::clone,
- ),
- },
+ DoneAsIs => expr.map_ref_simple(ExprF::roll).map_ref(
+ SubExpr::clone,
+ X::clone,
+ |_| unreachable!(),
+ Label::clone,
+ ),
}
}
diff --git a/dhall/src/traits/dynamic_type.rs b/dhall/src/traits/dynamic_type.rs
index d2a5414..d4faf45 100644
--- a/dhall/src/traits/dynamic_type.rs
+++ b/dhall/src/traits/dynamic_type.rs
@@ -35,7 +35,7 @@ impl<'a> DynamicType for Normalized<'a> {
Some(t) => Ok(Cow::Borrowed(t)),
None => Err(TypeError::new(
&Context::new(),
- self.0.absurd(),
+ self.0.embed_absurd(),
TypeMessage::Untyped,
)),
}
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index de3899c..5aaeb08 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -496,7 +496,7 @@ fn type_last_layer(
PhantomData
)))
);
- let tx = mktype(ctx, tx.absurd())?;
+ let tx = mktype(ctx, tx.embed_absurd())?;
ensure_equal!(&tx, a.get_type()?, {
let a = a.clone();
mkerr(TypeMismatch(
@@ -511,7 +511,7 @@ fn type_last_layer(
x.clone(),
None,
a.clone().normalize().embed(),
- tb.absurd(),
+ tb.embed_absurd(),
)),
)?;
}
@@ -675,7 +675,7 @@ fn type_last_layer(
}
Field(r, x) => match r.get_type()?.unroll_ref()?.as_ref() {
RecordType(kts) => match kts.get(&x) {
- Some(t) => Ok(RetExpr(t.unroll().absurd_rec())),
+ Some(t) => Ok(RetExpr(t.unroll().embed_absurd())),
None => Err(mkerr(MissingRecordField(x, r))),
},
_ => {