summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Bogus2017-09-08 23:48:29 +0200
committernanotech2017-09-08 17:02:00 -0600
commit7fe85bcd1ddecf58814e35f02cab8ef652a1e9c2 (patch)
treed9ff2e18bb5fc9aac9a870596f727ffb26248f0b
parentb3694b66f9302e9d6e540f0ff7941ccda7e0000d (diff)
fixed some clippy warnings
Diffstat (limited to '')
-rw-r--r--Cargo.lock267
-rw-r--r--Cargo.toml4
-rw-r--r--src/context.rs4
-rw-r--r--src/core.rs240
-rw-r--r--src/lexer.rs2
-rw-r--r--src/main.rs6
-rw-r--r--src/typecheck.rs123
7 files changed, 336 insertions, 310 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7c142e5..8a86c4a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,19 +2,27 @@
name = "dhall"
version = "0.1.0"
dependencies = [
- "bytecount 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-util 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "nom 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "term-painter 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bytecount 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "nom 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term-painter 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "aho-corasick"
-version = "0.5.3"
+version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "ascii-canvas"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -23,58 +31,66 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bit-set"
-version = "0.3.0"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bit-vec"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "bitflags"
-version = "0.4.0"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bytecount"
-version = "0.1.4"
+version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "diff"
-version = "0.1.9"
+version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "docopt"
-version = "0.6.86"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
- "strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
+name = "either"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "ena"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "fixedbitset"
-version = "0.1.5"
+version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "itertools"
-version = "0.3.25"
+version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "kernel32-sys"
@@ -87,123 +103,126 @@ dependencies = [
[[package]]
name = "lalrpop"
-version = "0.12.4"
+version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "bit-set 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "diff 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
- "itertools 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-intern 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-snap 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-util 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "petgraph 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-snap 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "petgraph 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lalrpop-intern"
-version = "0.12.4"
+version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lalrpop-snap"
-version = "0.12.4"
+version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "bit-set 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "diff 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
- "itertools 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-intern 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-util 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "petgraph 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "petgraph 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lalrpop-util"
-version = "0.12.4"
+version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
-version = "0.2.2"
+version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
-version = "0.2.18"
+version = "0.2.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "memchr"
-version = "0.1.11"
+version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "nom"
-version = "2.0.0"
+version = "2.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "ordermap"
+version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "petgraph"
-version = "0.1.18"
+version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "fixedbitset 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fixedbitset 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ordermap 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
-version = "0.1.80"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "regex-syntax"
-version = "0.3.9"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-serialize"
-version = "0.3.21"
+version = "0.3.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "strsim"
-version = "0.5.2"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "term"
-version = "0.4.4"
+version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -212,37 +231,42 @@ dependencies = [
[[package]]
name = "term-painter"
-version = "0.2.3"
+version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "thread-id"
-version = "2.0.0"
+name = "thread_local"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "thread_local"
-version = "0.2.7"
+name = "unicode-xid"
+version = "0.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "unreachable"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
-name = "unicode-xid"
-version = "0.0.2"
+name = "utf8-ranges"
+version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
-name = "utf8-ranges"
-version = "0.1.3"
+name = "void"
+version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -256,36 +280,39 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
-"checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66"
+"checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
+"checksum ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2"
"checksum atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0fd4c0631f06448cc45a6bbb3b710ebb7ff8ccb96a0800c994afe23a70d5df2"
-"checksum bit-set 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84527c7b0452f22545cc010e72d366a435561d2b28b978035550b3778c4d428d"
-"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
-"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
-"checksum bytecount 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49e3c21915578e2300b08d3c174a8ac887e0c6421dff86fdc4d741dc29e5d413"
-"checksum diff 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e48977eec6d3b7707462c2dc2e1363ad91b5dd822cf942537ccdc2085dc87587"
-"checksum docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)" = "4a7ef30445607f6fc8720f0a0a2c7442284b629cf0d049286860fae23e71c4d9"
-"checksum fixedbitset 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3c33fc4c00db33f5174eb98aea809c4c007db0b71351d810a7e094ea3b64d"
-"checksum itertools 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "16b73f1c685cfd8ff8d75698ed87e6188cd09944b30c0863d45c2c3699d1da0c"
+"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
+"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
+"checksum bytecount 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4bbeb7c30341fce29f6078b4bdf876ea4779600866e98f5b2d203a534f195050"
+"checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472"
+"checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8"
+"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
+"checksum ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe5a5078ac8c506d3e4430763b1ba9b609b1286913e7d08e581d1c2de9b7e5"
+"checksum fixedbitset 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b0cb3d75726fa0c5ed3dce5dfcf0796affa2a60b33967f45012d86fb95a886f2"
+"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum lalrpop 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "95af72b26d2056ca73387cb71d29e727c336d2b8a766ee09b210bed44d6f857b"
-"checksum lalrpop-intern 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e76b1f6eead09c4edde090dc69e3757775ab36cbf907fb0857181160b9ca5a1"
-"checksum lalrpop-snap 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a096006ebe9cef49295a142af7cb3cf2f782bf594213c786e0cc070b0d237073"
-"checksum lalrpop-util 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab0e358c557ea426b05719c82ac649cae0f0f7f2855145111fe59eab207b285"
-"checksum lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6abe0ee2e758cd6bc8a2cd56726359007748fbf4128da998b65d0b70f881e19b"
-"checksum libc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a51822fc847e7a8101514d1d44e354ba2ffa7d4c194dcab48870740e327cac70"
-"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
-"checksum nom 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "628d6ee18ab0ca1c1feb3331caa6ad2e53f6053b2505662b90d194889bbcd571"
-"checksum petgraph 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "bfd1de18b0a5f1777162e5b61aaf498032467d5409ab4ca6dbd03049f5708de1"
-"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
-"checksum regex-syntax 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a21935ce5a4dfa48e3ded1aefbbe353fb9ab258b0d3fa0bd168bef00797b3dc7"
-"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957"
-"checksum rustc-serialize 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)" = "bff9fc1c79f2dec76b253273d07682e94a978bd8f132ded071188122b2af9818"
-"checksum strsim 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67f84c44fbb2f91db7fef94554e6b2ac05909c9c0b0bc23bb98d3a1aebfe7f7c"
-"checksum term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3deff8a2b3b6607d6d7cc32ac25c0b33709453ca9cceac006caac51e963cf94a"
-"checksum term-painter 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ab900bf2f05175932b13d4fc12f8ff09ef777715b04998791ab2c930841e496b"
-"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
-"checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5"
-"checksum unicode-xid 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f69506a2561962651710609304bbb961fa3da598c812f877975a82e48ee144f9"
-"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
+"checksum lalrpop 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8ebe5a5c90d5edeecb7f62f6ebec0a3d0f6faf4759a052708348cda99fd311a0"
+"checksum lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05410c1e4aff497bdea1ccb274ac35536fda0ee858600df36966502d4f7acbe3"
+"checksum lalrpop-snap 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f866ece35287f5223a1a022c5d86417c260cda2ca9c8a156af9959404ce5313"
+"checksum lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c7743f235fc17f5f50f3b1e64a8690ee154f17f86bd68cbb78787c5b37907f7"
+"checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
+"checksum libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "2370ca07ec338939e356443dac2296f581453c35fe1e3a3ed06023c49435f915"
+"checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
+"checksum nom 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf51a729ecf40266a2368ad335a5fdde43471f545a967109cd62146ecf8b66ff"
+"checksum ordermap 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e2df2a1933286f9d5f370ce42c3056a426845c5491b42ebcab900715bf2c5e"
+"checksum petgraph 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "14c6ae5ccb73b438781abc93d35615019b1ad6e24b44116377fb819cfd7587de"
+"checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
+"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
+"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
+"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
+"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
+"checksum term-painter 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dcaa948f0e3e38470cd8dc8dcfe561a75c9e43f28075bb183845be2b9b3c08cf"
+"checksum thread_local 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14"
+"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
+"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
+"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
+"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
diff --git a/Cargo.toml b/Cargo.toml
index ea1250e..d86ac45 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,10 +5,10 @@ authors = ["NanoTech <nanotech@nanotechcorp.net>"]
build = "build.rs"
[build-dependencies]
-lalrpop = "0.12.4"
+lalrpop = "0.13.1"
[dependencies]
bytecount = "0.1.4"
-lalrpop-util = "0.12.4"
+lalrpop-util = "0.13.1"
nom = "2.0.0"
term-painter = "0.2.3"
diff --git a/src/context.rs b/src/context.rs
index 9fb3bf4..c2e1913 100644
--- a/src/context.rs
+++ b/src/context.rs
@@ -34,7 +34,7 @@ impl<'i, T> Context<'i, T> {
}
pub fn map<U, F: Fn(&T) -> U>(&self, f: F) -> Context<'i, U> {
- Context(self.0.iter().map(|(k, v)| (k.clone(), v.iter().map(&f).collect())).collect())
+ Context(self.0.iter().map(|(k, v)| (*k, v.iter().map(&f).collect())).collect())
}
}
@@ -43,7 +43,7 @@ impl<'i, T: Clone> Context<'i, T> {
pub fn insert(&self, k: &'i str, v: T) -> Self {
let mut ctx = (*self).clone();
{
- let m = ctx.0.entry(k).or_insert(vec![]);
+ let m = ctx.0.entry(k).or_insert_with(Vec::new);
m.push(v);
}
ctx
diff --git a/src/core.rs b/src/core.rs
index 02ff6ac..a9de523 100644
--- a/src/core.rs
+++ b/src/core.rs
@@ -257,22 +257,22 @@ impl<'i, S, A> From<BuiltinValue> for Expr<'i, S, A> {
impl<'i, S, A> Expr<'i, S, A> {
fn bool_lit(&self) -> Option<bool> {
- match self {
- &Expr::BoolLit(v) => Some(v),
+ match *self {
+ Expr::BoolLit(v) => Some(v),
_ => None,
}
}
fn natural_lit(&self) -> Option<usize> {
- match self {
- &Expr::NaturalLit(v) => Some(v),
+ match *self {
+ Expr::NaturalLit(v) => Some(v),
_ => None,
}
}
fn text_lit(&self) -> Option<String> {
- match self {
- &Expr::TextLit(ref t) => Some(t.clone()), // FIXME?
+ match *self {
+ Expr::TextLit(ref t) => Some(t.clone()), // FIXME?
_ => None,
}
}
@@ -423,7 +423,7 @@ impl<'i, S, A: Display> Expr<'i, S, A> {
fmt_list("{ ", " }", a, f, |(k, v), f| write!(f, "{} = {}", k, v))
}
&Union(ref _a) => f.write_str("Union"),
- &UnionLit(ref _a, ref _b, ref _c) => f.write_str("UnionLit"),
+ &UnionLit(_a, ref _b, ref _c) => f.write_str("UnionLit"),
&Embed(ref a) => a.fmt(f),
&Note(_, ref b) => b.fmt_f(f),
a => write!(f, "({})", a),
@@ -531,7 +531,7 @@ pub fn bx<T>(x: T) -> Box<T> {
fn add_ui(u: usize, i: isize) -> usize {
if i < 0 {
- u.checked_sub((i.checked_neg().unwrap() as usize)).unwrap()
+ u.checked_sub(i.checked_neg().unwrap() as usize).unwrap()
} else {
u.checked_add(i as usize).unwrap()
}
@@ -627,75 +627,75 @@ fn map_op2<T, U, V, F, G>(f: F, g: G, a: T, b: T) -> V
pub fn shift<'i, S, T, A: Clone>(d: isize, v: V, e: &Expr<'i, S, A>) -> Expr<'i, T, A> {
use Expr::*;
let V(x, n) = v;
- match e {
- &Const(a) => Const(a),
- &Var(V(x2, n2)) => {
+ match *e {
+ Const(a) => Const(a),
+ Var(V(x2, n2)) => {
let n3 = if x == x2 && n <= n2 { add_ui(n2, d) } else { n2 };
Var(V(x2, n3))
}
- &Lam(x2, ref tA, ref b) => {
+ Lam(x2, ref tA, ref b) => {
let n2 = if x == x2 { n + 1 } else { n };
let tA2 = shift(d, V(x, n ), tA);
let b2 = shift(d, V(x, n2), b);
Lam(x2, bx(tA2), bx(b2))
}
- &Pi(x2, ref tA, ref tB) => {
+ Pi(x2, ref tA, ref tB) => {
let n2 = if x == x2 { n + 1 } else { n };
let tA2 = shift(d, V(x, n ), tA);
let tB2 = shift(d, V(x, n2), tB);
pi(x2, tA2, tB2)
}
- &App(ref f, ref a) => app(shift(d, v, f), shift(d, v, a)),
- &Let(f, ref mt, ref r, ref e) => {
+ App(ref f, ref a) => app(shift(d, v, f), shift(d, v, a)),
+ Let(f, ref mt, ref r, ref e) => {
let n2 = if x == f { n + 1 } else { n };
let e2 = shift(d, V(x, n2), e);
let mt2 = mt.as_ref().map(|t| bx(shift(d, V(x, n), t)));
let r2 = shift(d, V(x, n), r);
Let(f, mt2, bx(r2), bx(e2))
}
- &Annot(ref a, ref b) => shift_op2(Annot, d, v, a, b),
- &BuiltinType(t) => BuiltinType(t),
- &BuiltinValue(v) => BuiltinValue(v),
- &BoolLit(a) => BoolLit(a),
- &BoolAnd(ref a, ref b) => shift_op2(BoolAnd, d, v, a, b),
- &BoolOr(ref a, ref b) => shift_op2(BoolOr, d, v, a, b),
- &BoolEQ(ref a, ref b) => shift_op2(BoolEQ, d, v, a, b),
- &BoolNE(ref a, ref b) => shift_op2(BoolNE, d, v, a, b),
- &BoolIf(ref a, ref b, ref c) => {
+ Annot(ref a, ref b) => shift_op2(Annot, d, v, a, b),
+ BuiltinType(t) => BuiltinType(t),
+ BuiltinValue(v) => BuiltinValue(v),
+ BoolLit(a) => BoolLit(a),
+ BoolAnd(ref a, ref b) => shift_op2(BoolAnd, d, v, a, b),
+ BoolOr(ref a, ref b) => shift_op2(BoolOr, d, v, a, b),
+ BoolEQ(ref a, ref b) => shift_op2(BoolEQ, d, v, a, b),
+ BoolNE(ref a, ref b) => shift_op2(BoolNE, d, v, a, b),
+ BoolIf(ref a, ref b, ref c) => {
BoolIf(bx(shift(d, v, a)), bx(shift(d, v, b)), bx(shift(d, v, c)))
}
- &NaturalLit(a) => NaturalLit(a),
- &NaturalPlus(ref a, ref b) => NaturalPlus(bx(shift(d, v, a)), bx(shift(d, v, b))),
- &NaturalTimes(ref a, ref b) => shift_op2(NaturalTimes, d, v, a, b),
- &IntegerLit(a) => IntegerLit(a),
- &DoubleLit(a) => DoubleLit(a),
- &TextLit(ref a) => TextLit(a.clone()),
- &TextAppend(ref a, ref b) => shift_op2(TextAppend, d, v, a, b),
- &ListLit(ref t, ref es) => {
+ NaturalLit(a) => NaturalLit(a),
+ NaturalPlus(ref a, ref b) => NaturalPlus(bx(shift(d, v, a)), bx(shift(d, v, b))),
+ NaturalTimes(ref a, ref b) => shift_op2(NaturalTimes, d, v, a, b),
+ IntegerLit(a) => IntegerLit(a),
+ DoubleLit(a) => DoubleLit(a),
+ TextLit(ref a) => TextLit(a.clone()),
+ TextAppend(ref a, ref b) => shift_op2(TextAppend, d, v, a, b),
+ ListLit(ref t, ref es) => {
ListLit(bx(shift(d, v, t)),
es.iter().map(|e| shift(d, v, e)).collect())
}
- &OptionalLit(ref t, ref es) => {
+ OptionalLit(ref t, ref es) => {
OptionalLit(bx(shift(d, v, t)),
es.iter().map(|e| shift(d, v, e)).collect())
}
- &Record(ref a) => Record(map_record_value(a, |val| shift(d, v, val))),
- &RecordLit(ref a) => RecordLit(map_record_value(a, |val| shift(d, v, val))),
- &Union(ref a) => Union(map_record_value(a, |val| shift(d, v, val))),
- &UnionLit(k, ref uv, ref a) => {
+ Record(ref a) => Record(map_record_value(a, |val| shift(d, v, val))),
+ RecordLit(ref a) => RecordLit(map_record_value(a, |val| shift(d, v, val))),
+ Union(ref a) => Union(map_record_value(a, |val| shift(d, v, val))),
+ UnionLit(k, ref uv, ref a) => {
UnionLit(k,
bx(shift(d, v, uv)),
map_record_value(a, |val| shift(d, v, val)))
}
- &Combine(ref a, ref b) => shift_op2(Combine, d, v, a, b),
- &Merge(ref a, ref b, ref c) => {
+ Combine(ref a, ref b) => shift_op2(Combine, d, v, a, b),
+ Merge(ref a, ref b, ref c) => {
Merge(bx(shift(d, v, a)), bx(shift(d, v, b)), bx(shift(d, v, c)))
}
- &Field(ref a, b) => Field(bx(shift(d, v, a)), b),
- &Note(_, ref b) => shift(d, v, b),
+ Field(ref a, b) => Field(bx(shift(d, v, a)), b),
+ Note(_, ref b) => shift(d, v, b),
// The Dhall compiler enforces that all embedded values are closed expressions
// and `shift` does nothing to a closed expression
- &Embed(ref p) => Embed(p.clone()),
+ Embed(ref p) => Embed(p.clone()),
}
}
@@ -723,76 +723,76 @@ pub fn subst<'i, S, T, A>(v: V<'i>, e: &Expr<'i, S, A>, b: &Expr<'i, T, A>) -> E
{
use Expr::*;
let V(x, n) = v;
- match b {
- &Const(a) => Const(a),
- &Lam(y, ref tA, ref b) => {
+ match *b {
+ Const(a) => Const(a),
+ Lam(y, ref tA, ref b) => {
let n2 = if x == y { n + 1 } else { n };
- let b2 = subst(V(x, n2), &shift(1, V(y, 0), &e), b);
- let tA2 = subst(V(x, n), &e, tA);
+ let b2 = subst(V(x, n2), &shift(1, V(y, 0), e), b);
+ let tA2 = subst(V(x, n), e, tA);
Lam(y, bx(tA2), bx(b2))
}
- &Pi(y, ref tA, ref tB) => {
+ Pi(y, ref tA, ref tB) => {
let n2 = if x == y { n + 1 } else { n };
- let tB2 = subst(V(x, n2), &shift(1, V(y, 0), &e), tB);
- let tA2 = subst(V(x, n), &e, tA);
+ let tB2 = subst(V(x, n2), &shift(1, V(y, 0), e), tB);
+ let tA2 = subst(V(x, n), e, tA);
pi(y, tA2, tB2)
}
- &App(ref f, ref a) => {
+ App(ref f, ref a) => {
let f2 = subst(v, e, f);
let a2 = subst(v, e, a);
app(f2, a2)
}
- &Var(v2) => if v == v2 { e.clone() } else { Var(v2) },
- &Let(f, ref mt, ref r, ref b) => {
+ Var(v2) => if v == v2 { e.clone() } else { Var(v2) },
+ Let(f, ref mt, ref r, ref b) => {
let n2 = if x == f { n + 1 } else { n };
let b2 = subst(V(x, n2), &shift(1, V(f, 0), e), b);
let mt2 = mt.as_ref().map(|t| bx(subst(V(x, n), e, t)));
let r2 = subst(V(x, n), e, r);
Let(f, mt2, bx(r2), bx(b2))
}
- &Annot(ref a, ref b) => subst_op2(Annot, v, e, a, b),
- &BuiltinType(t) => BuiltinType(t),
- &BuiltinValue(v) => BuiltinValue(v),
- &BoolLit(a) => BoolLit(a),
- &BoolAnd(ref a, ref b) => subst_op2(BoolAnd, v, e, a, b),
- &BoolOr(ref a, ref b) => subst_op2(BoolOr, v, e, a, b),
- &BoolEQ(ref a, ref b) => subst_op2(BoolEQ, v, e, a, b),
- &BoolNE(ref a, ref b) => subst_op2(BoolNE, v, e, a, b),
- &BoolIf(ref a, ref b, ref c) => {
+ Annot(ref a, ref b) => subst_op2(Annot, v, e, a, b),
+ BuiltinType(t) => BuiltinType(t),
+ BuiltinValue(v) => BuiltinValue(v),
+ BoolLit(a) => BoolLit(a),
+ BoolAnd(ref a, ref b) => subst_op2(BoolAnd, v, e, a, b),
+ BoolOr(ref a, ref b) => subst_op2(BoolOr, v, e, a, b),
+ BoolEQ(ref a, ref b) => subst_op2(BoolEQ, v, e, a, b),
+ BoolNE(ref a, ref b) => subst_op2(BoolNE, v, e, a, b),
+ BoolIf(ref a, ref b, ref c) => {
BoolIf(bx(subst(v, e, a)), bx(subst(v, e, b)), bx(subst(v, e, c)))
}
- &NaturalLit(a) => NaturalLit(a),
- &NaturalPlus(ref a, ref b) => subst_op2(NaturalPlus, v, e, a, b),
- &NaturalTimes(ref a, ref b) => subst_op2(NaturalTimes, v, e, a, b),
- &IntegerLit(a) => IntegerLit(a),
- &DoubleLit(a) => DoubleLit(a),
- &TextLit(ref a) => TextLit(a.clone()),
- &TextAppend(ref a, ref b) => subst_op2(TextAppend, v, e, a, b),
- &ListLit(ref a, ref b) => {
+ NaturalLit(a) => NaturalLit(a),
+ NaturalPlus(ref a, ref b) => subst_op2(NaturalPlus, v, e, a, b),
+ NaturalTimes(ref a, ref b) => subst_op2(NaturalTimes, v, e, a, b),
+ IntegerLit(a) => IntegerLit(a),
+ DoubleLit(a) => DoubleLit(a),
+ TextLit(ref a) => TextLit(a.clone()),
+ TextAppend(ref a, ref b) => subst_op2(TextAppend, v, e, a, b),
+ ListLit(ref a, ref b) => {
let a2 = subst(v, e, a);
let b2 = b.iter().map(|be| subst(v, e, be)).collect();
ListLit(bx(a2), b2)
}
- &OptionalLit(ref a, ref b) => {
+ OptionalLit(ref a, ref b) => {
let a2 = subst(v, e, a);
let b2 = b.iter().map(|be| subst(v, e, be)).collect();
OptionalLit(bx(a2), b2)
}
- &Record(ref kts) => Record(map_record_value(kts, |t| subst(v, e, t))),
- &RecordLit(ref kvs) => RecordLit(map_record_value(kvs, |val| subst(v, e, val))),
- &Union(ref kts) => Union(map_record_value(kts, |t| subst(v, e, t))),
- &UnionLit(k, ref uv, ref kvs) => {
+ Record(ref kts) => Record(map_record_value(kts, |t| subst(v, e, t))),
+ RecordLit(ref kvs) => RecordLit(map_record_value(kvs, |val| subst(v, e, val))),
+ Union(ref kts) => Union(map_record_value(kts, |t| subst(v, e, t))),
+ UnionLit(k, ref uv, ref kvs) => {
UnionLit(k,
bx(subst(v, e, uv)),
map_record_value(kvs, |val| subst(v, e, val)))
}
- &Combine(ref a, ref b) => subst_op2(Combine, v, e, a, b),
- &Merge(ref a, ref b, ref c) => {
+ Combine(ref a, ref b) => subst_op2(Combine, v, e, a, b),
+ Merge(ref a, ref b, ref c) => {
Merge(bx(subst(v, e, a)), bx(subst(v, e, b)), bx(subst(v, e, c)))
}
- &Field(ref a, b) => Field(bx(subst(v, e, a)), b),
- &Note(_, ref b) => subst(v, e, b),
- &Embed(ref p) => Embed(p.clone()),
+ Field(ref a, b) => Field(bx(subst(v, e, a)), b),
+ Note(_, ref b) => subst(v, e, b),
+ Embed(ref p) => Embed(p.clone()),
}
}
@@ -825,20 +825,20 @@ pub fn normalize<'i, S, T, A>(e: &Expr<'i, S, A>) -> Expr<'i, T, A>
{
use BuiltinValue::*;
use Expr::*;
- match e {
- &Const(k) => Const(k),
- &Var(v) => Var(v),
- &Lam(x, ref tA, ref b) => {
+ match *e {
+ Const(k) => Const(k),
+ Var(v) => Var(v),
+ Lam(x, ref tA, ref b) => {
let tA2 = normalize(tA);
let b2 = normalize(b);
Lam(x, bx(tA2), bx(b2))
}
- &Pi(x, ref tA, ref tB) => {
+ Pi(x, ref tA, ref tB) => {
let tA2 = normalize(tA);
let tB2 = normalize(tB);
pi(x, tA2, tB2)
}
- &App(ref f, ref a) => match normalize::<S, T, A>(f) {
+ App(ref f, ref a) => match normalize::<S, T, A>(f) {
Lam(x, _A, b) => { // Beta reduce
let vx0 = V(x, 0);
let a2 = shift::<S, S, A>( 1, vx0, a);
@@ -848,11 +848,11 @@ pub fn normalize<'i, S, T, A>(e: &Expr<'i, S, A>) -> Expr<'i, T, A>
}
f2 => match (f2, normalize::<S, T, A>(a)) {
// fold/build fusion for `List`
- (App(box BuiltinValue(ListBuild), _), App(box App(box BuiltinValue(ListFold), _), box e2)) => normalize(&e2),
- (App(box BuiltinValue(ListFold), _), App(box App(box BuiltinValue(ListBuild), _), box e2)) => normalize(&e2),
+ (App(box BuiltinValue(ListBuild), _), App(box App(box BuiltinValue(ListFold), _), box e2)) |
+ (App(box BuiltinValue(ListFold), _), App(box App(box BuiltinValue(ListBuild), _), box e2)) |
// fold/build fusion for `Natural`
- (BuiltinValue(NaturalBuild), App(box BuiltinValue(NaturalFold), box e2)) => normalize(&e2),
+ (BuiltinValue(NaturalBuild), App(box BuiltinValue(NaturalFold), box e2)) |
(BuiltinValue(NaturalFold), App(box BuiltinValue(NaturalBuild), box e2)) => normalize(&e2),
/*
@@ -900,9 +900,9 @@ pub fn normalize<'i, S, T, A>(e: &Expr<'i, S, A>) -> Expr<'i, T, A>
}
}
fn check<S, A>(e: &Expr<S, A>) -> bool {
- match e {
- &App(box App(box Var(V("Cons", _)), _), ref e2) => check(e2),
- &Var(V("Nil", _)) => true,
+ match *e {
+ App(box App(box Var(V("Cons", _)), _), ref e2) => check(e2),
+ Var(V("Nil", _)) => true,
_ => false,
}
}
@@ -958,85 +958,85 @@ pub fn normalize<'i, S, T, A>(e: &Expr<'i, S, A>) -> Expr<'i, T, A>
(f2, a2) => app(f2, a2),
}
},
- &Let(f, _, ref r, ref b) => {
+ Let(f, _, ref r, ref b) => {
let r2 = shift::<_, S, _>( 1, V(f, 0), r);
let b2 = subst(V(f, 0), &r2, b);
let b3 = shift::<_, T, _>(-1, V(f, 0), &b2);
normalize(&b3)
}
- &Annot(ref x, _) => normalize(x),
- &BuiltinType(t) => BuiltinType(t),
- &BuiltinValue(v) => BuiltinValue(v),
- &BoolLit(b) => BoolLit(b),
- &BoolAnd(ref x, ref y) => {
+ Annot(ref x, _) => normalize(x),
+ BuiltinType(t) => BuiltinType(t),
+ BuiltinValue(v) => BuiltinValue(v),
+ BoolLit(b) => BoolLit(b),
+ BoolAnd(ref x, ref y) => {
with_binop(BoolAnd, Expr::bool_lit,
|xn, yn| BoolLit(xn && yn),
normalize(x), normalize(y))
}
- &BoolOr(ref x, ref y) => {
+ BoolOr(ref x, ref y) => {
with_binop(BoolOr, Expr::bool_lit,
|xn, yn| BoolLit(xn || yn),
normalize(x), normalize(y))
}
- &BoolEQ(ref x, ref y) => {
+ BoolEQ(ref x, ref y) => {
with_binop(BoolEQ, Expr::bool_lit,
|xn, yn| BoolLit(xn == yn),
normalize(x), normalize(y))
}
- &BoolNE(ref x, ref y) => {
+ BoolNE(ref x, ref y) => {
with_binop(BoolNE, Expr::bool_lit,
|xn, yn| BoolLit(xn != yn),
normalize(x), normalize(y))
}
- &BoolIf(ref b, ref t, ref f) => match normalize(b) {
+ BoolIf(ref b, ref t, ref f) => match normalize(b) {
BoolLit(true) => normalize(t),
BoolLit(false) => normalize(f),
b2 => BoolIf(bx(b2), bx(normalize(t)), bx(normalize(f))),
},
- &NaturalLit(n) => NaturalLit(n),
- &NaturalPlus(ref x, ref y) => {
+ NaturalLit(n) => NaturalLit(n),
+ NaturalPlus(ref x, ref y) => {
with_binop(NaturalPlus, Expr::natural_lit,
|xn, yn| NaturalLit(xn + yn),
normalize(x), normalize(y))
}
- &NaturalTimes(ref x, ref y) => {
+ NaturalTimes(ref x, ref y) => {
with_binop(NaturalTimes, Expr::natural_lit,
|xn, yn| NaturalLit(xn * yn),
normalize(x), normalize(y))
}
- &IntegerLit(n) => IntegerLit(n),
- &DoubleLit(n) => DoubleLit(n),
- &TextLit(ref t) => TextLit(t.clone()),
- &TextAppend(ref x, ref y) => {
+ IntegerLit(n) => IntegerLit(n),
+ DoubleLit(n) => DoubleLit(n),
+ TextLit(ref t) => TextLit(t.clone()),
+ TextAppend(ref x, ref y) => {
with_binop(TextAppend, Expr::text_lit,
|xt, yt| TextLit(xt + &yt),
normalize(x), normalize(y))
}
- &ListLit(ref t, ref es) => {
+ ListLit(ref t, ref es) => {
let t2 = normalize(t);
let es2 = es.iter().map(normalize).collect();
ListLit(bx(t2), es2)
}
- &OptionalLit(ref t, ref es) => {
+ OptionalLit(ref t, ref es) => {
let t2 = normalize(t);
let es2 = es.iter().map(normalize).collect();
OptionalLit(bx(t2), es2)
}
- &Record(ref kts) => Record(map_record_value(kts, normalize)),
- &RecordLit(ref kvs) => RecordLit(map_record_value(kvs, normalize)),
- &Union(ref kts) => Union(map_record_value(kts, normalize)),
- &UnionLit(k, ref v, ref kvs) => UnionLit(k, bx(normalize(v)), map_record_value(kvs, normalize)),
- &Combine(ref _x0, ref _y0) => unimplemented!(),
- &Merge(ref _x, ref _y, ref _t) => unimplemented!(),
- &Field(ref r, x) => match normalize(r) {
+ Record(ref kts) => Record(map_record_value(kts, normalize)),
+ RecordLit(ref kvs) => RecordLit(map_record_value(kvs, normalize)),
+ Union(ref kts) => Union(map_record_value(kts, normalize)),
+ UnionLit(k, ref v, ref kvs) => UnionLit(k, bx(normalize(v)), map_record_value(kvs, normalize)),
+ Combine(ref _x0, ref _y0) => unimplemented!(),
+ Merge(ref _x, ref _y, ref _t) => unimplemented!(),
+ Field(ref r, x) => match normalize(r) {
RecordLit(kvs) => match kvs.get(x) {
Some(r2) => normalize(r2),
None => Field(bx(RecordLit(map_record_value(&kvs, normalize))), x),
},
r2 => Field(bx(r2), x),
},
- &Note(_, ref e) => normalize(e),
- &Embed(ref a) => Embed(a.clone()),
+ Note(_, ref e) => normalize(e),
+ Embed(ref a) => Embed(a.clone()),
}
}
diff --git a/src/lexer.rs b/src/lexer.rs
index 2a7e44b..bc96040 100644
--- a/src/lexer.rs
+++ b/src/lexer.rs
@@ -328,7 +328,7 @@ impl<'input> Iterator for Lexer<'input> {
use nom::IResult::*;
self.skip_comments_and_whitespace();
let input = self.current_input();
- if input.len() == 0 {
+ if input.is_empty() {
return None;
}
match token(input) {
diff --git a/src/main.rs b/src/main.rs
index d4b541b..9f7e2e1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,7 +24,7 @@ const ERROR_STYLE: term_painter::Color = term_painter::Color::Red;
const BOLD: term_painter::Attr = term_painter::Attr::Bold;
fn print_error(message: &str, source: &str, start: usize, end: usize) {
- let line_number = bytecount::count(source[..start].as_bytes(), '\n' as u8);
+ let line_number = bytecount::count(source[..start].as_bytes(), b'\n');
let line_start = source[..start].rfind('\n').map(|i| i + 1).unwrap_or(0);
let line_end = source[end..].find('\n').unwrap_or(0) + end;
let context_prefix = &source[line_start..start];
@@ -76,7 +76,7 @@ fn main() {
}
Err(lalrpop_util::ParseError::UnrecognizedToken { token: Some((start, t, end)), expected: e }) => {
print_error(&format!("Unrecognized token {:?}", t), &buffer, start, end);
- if e.len() > 0 {
+ if !e.is_empty() {
println!("Expected {:?}", e);
}
return;
@@ -93,7 +93,7 @@ fn main() {
let type_expr = match typecheck::type_of(&expr) {
Err(e) => {
- let explain = ::std::env::args().find(|s| s == "--explain").is_some();
+ let explain = ::std::env::args().any(|s| s == "--explain");
if !explain {
term_painter::Color::BrightBlack.with(|| {
println!("Use \"dhall --explain\" for detailed errors");
diff --git a/src/typecheck.rs b/src/typecheck.rs
index 39caa7e..576b059 100644
--- a/src/typecheck.rs
+++ b/src/typecheck.rs
@@ -24,8 +24,8 @@ fn axiom<'i, S: Clone>(c: core::Const) -> Result<core::Const, TypeError<'i, S>>
fn rule(a: core::Const, b: core::Const) -> Result<core::Const, ()> {
match (a, b) {
(Type, Kind) => Err(()),
- (Type, Type) => Ok(Type),
(Kind, Kind) => Ok(Kind),
+ (Type, Type) |
(Kind, Type) => Ok(Type),
}
}
@@ -52,10 +52,10 @@ fn prop_equal<S, T>(eL0: &Expr<S, X>, eR0: &Expr<T, X>) -> bool
T: Clone + ::std::fmt::Debug
{
match (el, er) {
- (&Const(Type), &Const(Type)) => true,
+ (&Const(Type), &Const(Type)) |
(&Const(Kind), &Const(Kind)) => true,
(&Var(ref vL), &Var(ref vR)) => match_vars(vL, vR, &*ctx),
- (&Pi(ref xL, ref tL, ref bL), &Pi(ref xR, ref tR, ref bR)) => {
+ (&Pi(xL, ref tL, ref bL), &Pi(xR, ref tR, ref bR)) => {
//ctx <- State.get
let eq1 = go(ctx, tL, tR);
if eq1 {
@@ -164,15 +164,15 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
-> Result<Expr<'i, S, X>, TypeError<'i, S>>
where S: Clone + ::std::fmt::Debug + 'i
{
- match e {
- &Const(c) => axiom(c).map(Const), //.map(Cow::Owned),
- &Var(V(ref x, n)) => {
+ match *e {
+ Const(c) => axiom(c).map(Const), //.map(Cow::Owned),
+ Var(V(x, n)) => {
ctx.lookup(x, n)
.cloned()
//.map(Cow::Borrowed)
- .ok_or_else(|| TypeError::new(ctx, &e, UnboundVariable))
+ .ok_or_else(|| TypeError::new(ctx, e, UnboundVariable))
}
- &Lam(ref x, ref tA, ref b) => {
+ Lam(x, ref tA, ref b) => {
let ctx2 = ctx.insert(x, (**tA).clone()).map(|e| core::shift(1, V(x, 0), e));
let tB = type_with(&ctx2, b)?;
let p = Pi(x, tA.clone(), bx(tB));
@@ -180,7 +180,7 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
//Ok(Cow::Owned(p))
Ok(p)
}
- &Pi(ref x, ref tA, ref tB) => {
+ Pi(x, ref tA, ref tB) => {
let tA2 = normalize::<S, S, X>(&type_with(ctx, tA)?);
let kA = match tA2 {
Const(k) => k,
@@ -199,7 +199,7 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
Ok(k) => Ok(Const(k)),
}
}
- &App(ref f, ref a) => {
+ App(ref f, ref a) => {
let tf = normalize(&type_with(ctx, f)?);
let (x, tA, tB) = match tf {
Pi(x, tA, tB) => (x, tA, tB),
@@ -218,14 +218,14 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
Err(TypeError::new(ctx, e, TypeMismatch((**f).clone(), nf_A, (**a).clone(), nf_A2)))
}
}
- &Let(ref f, ref mt, ref r, ref b) => {
+ Let(f, ref mt, ref r, ref b) => {
let tR = type_with(ctx, r)?;
let ttR = normalize::<S, S, X>(&type_with(ctx, &tR)?);
let kR = match ttR {
Const(k) => k,
// Don't bother to provide a `let`-specific version of this error
// message because this should never happen anyway
- _ => return Err(TypeError::new(ctx, &e, InvalidInputType(tR))),
+ _ => return Err(TypeError::new(ctx, e, InvalidInputType(tR))),
};
let ctx2 = ctx.insert(f, tR.clone());
@@ -235,24 +235,24 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
Const(k) => k,
// Don't bother to provide a `let`-specific version of this error
// message because this should never happen anyway
- _ => return Err(TypeError::new(ctx, &e, InvalidOutputType(tB))),
+ _ => return Err(TypeError::new(ctx, e, InvalidOutputType(tB))),
};
if let Err(()) = rule(kR, kB) {
- return Err(TypeError::new(ctx, &e, NoDependentLet(tR, tB)));
+ return Err(TypeError::new(ctx, e, NoDependentLet(tR, tB)));
}
- if let &Some(ref t) = mt {
+ if let Some(ref t) = *mt {
let nf_t = normalize(t);
let nf_tR = normalize(&tR);
if !prop_equal(&nf_tR, &nf_t) {
- return Err(TypeError::new(ctx, &e, AnnotMismatch((**r).clone(), nf_t, nf_tR)));
+ return Err(TypeError::new(ctx, e, AnnotMismatch((**r).clone(), nf_t, nf_tR)));
}
}
Ok(tB)
}
- &Annot(ref x, ref t) => {
+ Annot(ref x, ref t) => {
// This is mainly just to check that `t` is not `Kind`
let _ = type_with(ctx, t)?;
@@ -265,16 +265,16 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
Err(TypeError::new(ctx, e, AnnotMismatch((**x).clone(), nf_t, nf_t2)))
}
}
- &BuiltinType(t) => Ok(match t {
+ BuiltinType(t) => Ok(match t {
List | Optional => pi("_", Const(Type), Const(Type)),
Bool | Natural | Integer | Double | Text => Const(Type),
}),
- &BoolLit(_) => Ok(BuiltinType(Bool)),
- &BoolAnd(ref l, ref r) => op2_type(ctx, e, Bool, CantAnd, l, r),
- &BoolOr(ref l, ref r) => op2_type(ctx, e, Bool, CantOr, l, r),
- &BoolEQ(ref l, ref r) => op2_type(ctx, e, Bool, CantEQ, l, r),
- &BoolNE(ref l, ref r) => op2_type(ctx, e, Bool, CantNE, l, r),
- &BoolIf(ref x, ref y, ref z) => {
+ BoolLit(_) => Ok(BuiltinType(Bool)),
+ BoolAnd(ref l, ref r) => op2_type(ctx, e, Bool, CantAnd, l, r),
+ BoolOr(ref l, ref r) => op2_type(ctx, e, Bool, CantOr, l, r),
+ BoolEQ(ref l, ref r) => op2_type(ctx, e, Bool, CantEQ, l, r),
+ BoolNE(ref l, ref r) => op2_type(ctx, e, Bool, CantNE, l, r),
+ BoolIf(ref x, ref y, ref z) => {
let tx = normalize(&type_with(ctx, x)?);
match tx {
BuiltinType(Bool) => {}
@@ -299,28 +299,28 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
}
Ok(ty)
}
- &NaturalLit(_) => Ok(BuiltinType(Natural)),
- &BuiltinValue(NaturalFold) =>
+ NaturalLit(_) => Ok(BuiltinType(Natural)),
+ BuiltinValue(NaturalFold) =>
Ok(pi("_", Natural,
pi("natural", Const(Type),
pi("succ", pi("_", "natural", "natural"),
pi("zero", "natural", "natural"))))),
- &BuiltinValue(NaturalBuild) =>
+ BuiltinValue(NaturalBuild) =>
Ok(pi("_",
pi("natural", Const(Type),
pi("succ", pi("_", "natural", "natural"),
pi("zero", "natural", "natural"))),
Natural)),
- &BuiltinValue(NaturalIsZero) => Ok(pi("_", Natural, Bool)),
- &BuiltinValue(NaturalEven) => Ok(pi("_", Natural, Bool)),
- &BuiltinValue(NaturalOdd) => Ok(pi("_", Natural, Bool)),
- &NaturalPlus(ref l, ref r) => op2_type(ctx, e, Natural, CantAdd, l, r),
- &NaturalTimes(ref l, ref r) => op2_type(ctx, e, Natural, CantMultiply, l, r),
- &IntegerLit(_) => Ok(BuiltinType(Integer)),
- &DoubleLit(_) => Ok(BuiltinType(Double)),
- &TextLit(_) => Ok(BuiltinType(Text)),
- &TextAppend(ref l, ref r) => op2_type(ctx, e, Text, CantTextAppend, l, r),
- &ListLit(ref t, ref xs) => {
+ BuiltinValue(NaturalIsZero) |
+ BuiltinValue(NaturalEven) |
+ BuiltinValue(NaturalOdd) => Ok(pi("_", Natural, Bool)),
+ NaturalPlus(ref l, ref r) => op2_type(ctx, e, Natural, CantAdd, l, r),
+ NaturalTimes(ref l, ref r) => op2_type(ctx, e, Natural, CantMultiply, l, r),
+ IntegerLit(_) => Ok(BuiltinType(Integer)),
+ DoubleLit(_) => Ok(BuiltinType(Double)),
+ TextLit(_) => Ok(BuiltinType(Text)),
+ TextAppend(ref l, ref r) => op2_type(ctx, e, Text, CantTextAppend, l, r),
+ ListLit(ref t, ref xs) => {
let s = normalize::<_, S, _>(&type_with(ctx, t)?);
match s {
Const(Type) => {}
@@ -336,34 +336,33 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
}
Ok(App(bx(BuiltinType(List)), t.clone()))
}
- &BuiltinValue(ListBuild) =>
+ BuiltinValue(ListBuild) =>
Ok(pi("a", Const(Type),
pi("_",
pi("list", Const(Type),
pi("cons", pi("_", "a", pi("_", "list", "list")),
pi("nil", "list", "list"))),
app(List, "a")))),
- &BuiltinValue(ListFold) =>
+ BuiltinValue(ListFold) =>
Ok(pi("a", Const(Type),
pi("_", app(List, "a"),
pi("list", Const(Type),
pi("cons", pi("_", "a", pi("_", "list", "list")),
pi("nil", "list", "list")))))),
- &BuiltinValue(ListLength) =>
+ BuiltinValue(ListLength) =>
Ok(pi("a", Const(Type), pi("_", app(List, "a"), Natural))),
- &BuiltinValue(ListHead) =>
+ BuiltinValue(ListHead) |
+ BuiltinValue(ListLast) =>
Ok(pi("a", Const(Type), pi("_", app(List, "a"), app(Optional, "a")))),
- &BuiltinValue(ListLast) =>
- Ok(pi("a", Const(Type), pi("_", app(List, "a"), app(Optional, "a")))),
- &BuiltinValue(ListIndexed) => {
+ BuiltinValue(ListIndexed) => {
let mut m = BTreeMap::new();
m.insert("index", BuiltinType(Natural));
m.insert("value", Expr::from("a"));
Ok(pi("a", Const(Type), pi("_", app(List, "a"), app(List, Record(m)))))
}
- &BuiltinValue(ListReverse) =>
+ BuiltinValue(ListReverse) =>
Ok(pi("a", Const(Type), pi("_", app(List, "a"), app(List, "a")))),
- &OptionalLit(ref t, ref xs) => {
+ OptionalLit(ref t, ref xs) => {
let s = normalize::<_, S, _>(&type_with(ctx, t)?);
match s {
Const(Type) => {}
@@ -383,13 +382,13 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
}
Ok(App(bx(BuiltinType(Optional)), t.clone()))
}
- &BuiltinValue(OptionalFold) =>
+ BuiltinValue(OptionalFold) =>
Ok(pi("a", Const(Type),
pi("_", app(Optional, "a"),
pi("optional", Const(Type),
pi("just", pi("_", "a", "optional"),
pi("nothing", "optional", "optional")))))),
- &Record(ref kts) => {
+ Record(ref kts) => {
for (k, t) in kts {
let s = normalize::<S, S, X>(&type_with(ctx, t)?);
match s {
@@ -399,7 +398,7 @@ pub fn type_with<'i, S>(ctx: &Context<'i, Expr<'i, S, X>>,
}
Ok(Const(Type))
}
- &RecordLit(ref kvs) => {
+ RecordLit(ref kvs) => {
let kts = kvs.iter().map(|(&k, v)| {
let t = type_with(ctx, v)?;
let s = normalize::<S, S, X>(&type_with(ctx, &t)?);
@@ -492,10 +491,10 @@ type_with ctx e@(Merge kvsX kvsY t) = do
mapM_ process (Data.Map.toList ktsY)
return t
*/
- &Field(ref r, x) => {
+ Field(ref r, x) => {
let t = normalize(&type_with(ctx, r)?);
- match &t {
- &Record(ref kts) =>
+ match t {
+ Record(ref kts) =>
kts.get(x).cloned().ok_or_else(|| TypeError::new(ctx, e, MissingField(x.to_owned(), t.clone()))),
_ => Err(TypeError::new(ctx, e, NotARecord(x.to_owned(), (**r).clone(), t.clone()))),
}
@@ -506,7 +505,7 @@ type_with ctx (Note s e' ) = case type_with ctx e' of
Left (TypeError ctx2 e'' m) -> Left (TypeError ctx2 (Note s e'') m)
Right r -> Right r
*/
- &Embed(p) => match p {},
+ Embed(p) => match p {},
_ => panic!("Unimplemented typecheck case: {:?}", e),
}
}
@@ -587,12 +586,12 @@ impl<'i, S: Clone> TypeError<'i, S> {
impl<'i, S: fmt::Debug> ::std::error::Error for TypeMessage<'i, S> {
fn description(&self) -> &str {
- match self {
- &UnboundVariable => "Unbound variable",
- &InvalidInputType(_) => "Invalid function input",
- &InvalidOutputType(_) => "Invalid function output",
- &NotAFunction(_, _) => "Not a function",
- &TypeMismatch(_, _, _, _) => "Wrong type of function argument",
+ match *self {
+ UnboundVariable => "Unbound variable",
+ InvalidInputType(_) => "Invalid function input",
+ InvalidOutputType(_) => "Invalid function output",
+ NotAFunction(_, _) => "Not a function",
+ TypeMismatch(_, _, _, _) => "Wrong type of function argument",
_ => "Unhandled error",
}
}
@@ -600,9 +599,9 @@ impl<'i, S: fmt::Debug> ::std::error::Error for TypeMessage<'i, S> {
impl<'i, S> fmt::Display for TypeMessage<'i, S> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
- match self {
- &UnboundVariable => f.write_str(include_str!("errors/UnboundVariable.txt")),
- &TypeMismatch(ref e0, ref e1, ref e2, ref e3) => {
+ match *self {
+ UnboundVariable => f.write_str(include_str!("errors/UnboundVariable.txt")),
+ TypeMismatch(ref e0, ref e1, ref e2, ref e3) => {
let template = include_str!("errors/TypeMismatch.txt");
let s = template
.replace("$txt0", &format!("{}", e0))