summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril Feneanar2020-03-18 00:01:11 +0000
committerGitHub2020-03-18 00:01:11 +0000
commitf42ab8acdaa4dee753b7daccfed1ca3c8738095a (patch)
tree9fba7dd6d865884c0651af2dd7e01b243a0f25f0
parent71fddc59b5b427f52dd2f0cd76f788eb995a4e2e (diff)
parent40441abd2d6c2938244fa1bb2ca26ee9b8e4ab27 (diff)
Merge pull request #146 from Nadrieril/never_never
Use stable toolchain 🎉
-rw-r--r--README.md3
-rw-r--r--dhall/src/lib.rs1
-rw-r--r--dhall/src/semantics/nze/normalize.rs27
-rw-r--r--dhall/src/semantics/tck/typecheck.rs4
-rw-r--r--dhall/src/syntax/ast/expr.rs6
-rw-r--r--rust-toolchain2
6 files changed, 21 insertions, 22 deletions
diff --git a/README.md b/README.md
index ba73b6d..19912e1 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,6 @@ official tooling instead; instructions can be found
For now, the only supported way of integrating Dhall in your application is via
the `serde_dhall` crate, and only parsing is supported.
-`serde_dhall` is a nightly crate, and only works with a nightly compiler.
Add this to your `Cargo.toml`:
```toml
@@ -110,7 +109,7 @@ $ nix-shell -p rustup
Once `rustup` is installed we can get it to manage our toolchain by running:
```bash
-$ rustup toolchain install nightly
+$ rustup toolchain install stable
```
Then we can manage our building and testing with the [`cargo`](https://crates.io/) dependency manager:
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index d7d7f05..058411c 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -1,5 +1,4 @@
#![doc(html_root_url = "https://docs.rs/dhall/0.3.0")]
-#![feature(never_type)]
#![allow(
clippy::int_plus_one, // Comes from pest_consume macro
clippy::module_inception,
diff --git a/dhall/src/semantics/nze/normalize.rs b/dhall/src/semantics/nze/normalize.rs
index 08e3e87..79d55e8 100644
--- a/dhall/src/semantics/nze/normalize.rs
+++ b/dhall/src/semantics/nze/normalize.rs
@@ -58,20 +58,21 @@ pub(crate) fn squash_textlit(
ret
}
-pub(crate) fn merge_maps<K, V, F, Err>(
+pub(crate) fn merge_maps<K, V, F>(
map1: &HashMap<K, V>,
map2: &HashMap<K, V>,
mut f: F,
-) -> Result<HashMap<K, V>, Err>
+) -> HashMap<K, V>
where
- F: FnMut(&K, &V, &V) -> Result<V, Err>,
+ F: FnMut(&K, &V, &V) -> V,
K: std::hash::Hash + Eq + Clone,
V: Clone,
{
let mut kvs = HashMap::new();
for (x, v2) in map2 {
let newv = if let Some(v1) = map1.get(x) {
- f(x, v1, v2)?
+ // Collision: the key is present in both maps
+ f(x, v1, v2)
} else {
v2.clone()
};
@@ -81,7 +82,7 @@ where
// Insert only if key not already present
kvs.entry(x.clone()).or_insert_with(|| v1.clone());
}
- Ok(kvs)
+ kvs
}
// Small helper enum to avoid repetition
@@ -175,29 +176,29 @@ fn apply_binop<'a>(o: BinOp, x: &'a Nir, y: &'a Nir) -> Option<Ret<'a>> {
Ret::NirRef(y)
}
(RecursiveRecordMerge, RecordLit(kvs1), RecordLit(kvs2)) => {
- let kvs = merge_maps::<_, _, _, !>(kvs1, kvs2, |_, v1, v2| {
- Ok(Nir::from_partial_expr(ExprKind::BinOp(
+ let kvs = merge_maps(kvs1, kvs2, |_, v1, v2| {
+ Nir::from_partial_expr(ExprKind::BinOp(
RecursiveRecordMerge,
v1.clone(),
v2.clone(),
- )))
- })?;
+ ))
+ });
Ret::NirKind(RecordLit(kvs))
}
(RecursiveRecordTypeMerge, RecordType(kts_x), RecordType(kts_y)) => {
- let kts = merge_maps::<_, _, _, !>(
+ let kts = merge_maps(
kts_x,
kts_y,
// If the Label exists for both records, then we hit the recursive case.
|_, l: &Nir, r: &Nir| {
- Ok(Nir::from_partial_expr(ExprKind::BinOp(
+ Nir::from_partial_expr(ExprKind::BinOp(
RecursiveRecordTypeMerge,
l.clone(),
r.clone(),
- )))
+ ))
},
- )?;
+ );
Ret::NirKind(RecordType(kts))
}
diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs
index 365df25..173b76d 100644
--- a/dhall/src/semantics/tck/typecheck.rs
+++ b/dhall/src/semantics/tck/typecheck.rs
@@ -346,9 +346,7 @@ fn type_one_layer(
// Union the two records, prefering
// the values found in the RHS.
- let kts = merge_maps::<_, _, _, !>(kts_x, kts_y, |_, _, r_t| {
- Ok(r_t.clone())
- })?;
+ let kts = merge_maps(kts_x, kts_y, |_, _, r_t| r_t.clone());
let u = max(x.ty().ty(), y.ty().ty());
Nir::from_kind(NirKind::RecordType(kts)).to_type(u)
diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs
index ce0a3d2..8023771 100644
--- a/dhall/src/syntax/ast/expr.rs
+++ b/dhall/src/syntax/ast/expr.rs
@@ -257,10 +257,12 @@ impl Expr {
}
}
-pub fn trivial_result<T>(x: Result<T, !>) -> T {
+// Empty enum to indicate that no error can occur
+enum X {}
+fn trivial_result<T>(x: Result<T, X>) -> T {
match x {
Ok(x) => x,
- Err(e) => e,
+ Err(e) => match e {},
}
}
diff --git a/rust-toolchain b/rust-toolchain
index 7b70b33..a50908c 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1 +1 @@
-nightly-2020-03-12
+1.42.0