diff --git a/Cargo.lock b/Cargo.lock index 90caef9987..8f31623d24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,9 +2,9 @@ # It is not intended for manual editing. [[package]] name = "ab_glyph" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a685fe66654266f321a8b572660953f4df36a2135706503a4c89981d76e1a2" +checksum = "65b1f87418ab9d7e1ee2a783aa167767ebeb316d0a9fb10c347aec28a5008acb" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -18,9 +18,9 @@ checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff" [[package]] name = "addr2line" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" dependencies = [ "gimli", ] @@ -94,12 +94,6 @@ dependencies = [ "pretty_assertions", ] -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - [[package]] name = "arraystring" version = "0.3.0" @@ -149,24 +143,18 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.55" +version = "0.3.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +checksum = "9d117600f438b1707d4e4ae15d3595657288f8235a0eb593e80ecc98ab34e1bc" dependencies = [ "addr2line", "cfg-if 1.0.0", "libc", "miniz_oxide", - "object", + "object 0.23.0", "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - [[package]] name = "bit-set" version = "0.5.2" @@ -197,17 +185,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "blake2b_simd" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" -dependencies = [ - "arrayref", - "arrayvec", - "constant_time_eq", -] - [[package]] name = "block" version = "0.1.6" @@ -237,9 +214,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" dependencies = [ "lazy_static", "memchr", @@ -249,9 +226,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "099e596ef14349721d9016f6b80dd3419ea1bf289ab9b44df8e4dfd3a005d5d9" [[package]] name = "byte-tools" @@ -261,9 +238,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac" +checksum = "5a4bad0c5981acc24bc09e532f35160f952e35422603f0563cd7a73c2c2e65a0" dependencies = [ "bytemuck_derive", ] @@ -275,15 +252,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e215f8c2f9f79cb53c8335e687ffd07d5bfcb6fe5fc80723762d0be46e7cc54" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" [[package]] name = "bytes" @@ -379,8 +356,8 @@ dependencies = [ "heck", "proc-macro-error", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -402,15 +379,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "cloudabi" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" -dependencies = [ - "bitflags", -] - [[package]] name = "cocoa" version = "0.20.2" @@ -454,15 +422,15 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" [[package]] name = "const_format" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f84a8cfc8f74c1deb4bd7b2a41a669cab38327679491a30e19266f349ceaa0" +checksum = "c0412fd9e3c921f868af82a0097da41c250087e513786858b9e6b6055f8ed300" dependencies = [ "const_format_proc_macros", ] @@ -474,16 +442,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8df496e1bbc93814d728a8036ff054cd95830afe9cf2275c9326688c02eff936" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "unicode-xid 0.2.1", ] -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "copyless" version = "0.1.5" @@ -584,16 +546,16 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap 2.33.3", "criterion-plot", "csv", - "itertools", + "itertools 0.10.0", "lazy_static", "num-traits", "oorandom", @@ -615,7 +577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" dependencies = [ "cast", - "itertools", + "itertools 0.9.0", ] [[package]] @@ -771,13 +733,13 @@ dependencies = [ [[package]] name = "derivative" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -796,19 +758,20 @@ dependencies = [ ] [[package]] -name = "dirs" -version = "3.0.1" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "dirs-sys", + "cfg-if 1.0.0", + "dirs-sys-next", ] [[package]] -name = "dirs-sys" -version = "0.3.5" +name = "dirs-sys-next" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", @@ -915,9 +878,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -986,9 +949,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3b0c040a1fe6529d30b3c5944b280c7f0dcb2930d2c3062bca967b602583d0" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" dependencies = [ "futures-channel", "futures-core", @@ -1001,9 +964,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" dependencies = [ "futures-core", "futures-sink", @@ -1011,15 +974,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" [[package]] name = "futures-executor" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa2b2b68b880003057c1dd49f1ed937e38f22fcf6c212188a121f08cf40a65" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" dependencies = [ "futures-core", "futures-task", @@ -1028,42 +991,42 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611834ce18aaa1bd13c4b374f5d653e1027cf99b6b502584ff8c9a64413b30bb" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" [[package]] name = "futures-macro" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "futures-sink" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" [[package]] name = "futures-task" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" dependencies = [ "once_cell", ] [[package]] name = "futures-util" -version = "0.3.8" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" dependencies = [ "futures-channel", "futures-core", @@ -1072,7 +1035,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project", + "pin-project-lite 0.2.4", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1099,24 +1062,24 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] name = "getrandom" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.10.1+wasi-snapshot-preview1", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] @@ -1273,23 +1236,23 @@ checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" [[package]] name = "glyph_brush" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afd3e2cfd503a5218dd56172a8bf7c8655a4a7cf745737c606a6edfeea1b343f" +checksum = "3e3f00b8574a76fb6c50890c48da03946ca50e4372a2778737922666a2238221" dependencies = [ "glyph_brush_draw_cache", "glyph_brush_layout", "log", - "ordered-float", + "ordered-float 2.1.1", "rustc-hash", "twox-hash", ] [[package]] name = "glyph_brush_draw_cache" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cef969a091be5565c2c10b31fd2f115cbeed9f783a27c96ae240ff8ceee067c" +checksum = "ac2c82074cafb68b9e459c50c655f7eedcb92d6ee7166813802934bc6fc29fa3" dependencies = [ "ab_glyph", "crossbeam-channel 0.5.0", @@ -1312,15 +1275,15 @@ dependencies = [ [[package]] name = "half" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" [[package]] name = "handlebars" -version = "3.5.1" +version = "3.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2764f9796c0ddca4b82c07f25dd2cb3db30b9a8f47940e78e1c883d9e95c3db9" +checksum = "964d0e99a61fe9b1b347389b77ebf8b7e1587b70293676aaca7d27e59b9073b2" dependencies = [ "log", "pest", @@ -1338,18 +1301,18 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "heck" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] @@ -1393,9 +1356,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" dependencies = [ "autocfg 1.0.1", "hashbrown", @@ -1419,8 +1382,8 @@ checksum = "ce046d161f000fffde5f432a0d034d0341dc152643b2598ed5bfce44c4f3a8f0" dependencies = [ "proc-macro-hack", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", "unindent", ] @@ -1444,8 +1407,8 @@ version = "0.2.0" source = "git+https://github.com/rtfeldman/inkwell?tag=llvm10-0.release3#57e9f00d98fc99486e737c314e56a59498c5dbbb" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1456,9 +1419,9 @@ checksum = "3094308123a0e9fd59659ce45e22de9f53fc1d2ac6e1feb9fef988e4f76cad77" [[package]] name = "inplace_it" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd01a2a73f2f399df96b22dc88ea687ef4d76226284e7531ae3c7ee1dc5cb534" +checksum = "90953f308a79fe6d62a4643e51f848fbfddcd05975a38e69fdf4ab86a7baf7ca" [[package]] name = "instant" @@ -1488,10 +1451,19 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "0.4.6" +name = "itertools" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" +checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "jni-sys" @@ -1510,9 +1482,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] @@ -1547,15 +1519,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" [[package]] name = "libloading" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" +checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ "cfg-if 1.0.0", "winapi 0.3.9", @@ -1609,11 +1581,11 @@ dependencies = [ [[package]] name = "log" -version = "0.4.11" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -1827,9 +1799,9 @@ checksum = "2b2820aca934aba5ed91c79acc72b6a44048ceacc5d36c035ed4e051f12d887d" [[package]] name = "net2" -version = "0.2.36" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", @@ -1920,8 +1892,8 @@ checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -1975,6 +1947,12 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "object" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" + [[package]] name = "once_cell" version = "1.5.2" @@ -1995,18 +1973,27 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "ordered-float" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3741934be594d77de1c8461ebcbbe866f585ea616a9753aa78f2bdc69f0e4579" +checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-float" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "766f840da25490628d8e63e529cd21c014f6600c6b8517add12a6fa6167a6218" dependencies = [ "num-traits", ] [[package]] name = "owned_ttf_parser" -version = "0.8.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb477c7fd2a3a6e04e1dc6ca2e4e9b04f2df702021dc5a5d1cf078c587dc59f7" +checksum = "948b27637ba56144c62d3415929ef18986b3a383137ebcbe97d9362a968bf997" dependencies = [ "ttf-parser", ] @@ -2039,7 +2026,7 @@ checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ "instant", "lock_api 0.4.2", - "parking_lot_core 0.8.0", + "parking_lot_core 0.8.2", ] [[package]] @@ -2049,26 +2036,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if 0.1.10", - "cloudabi 0.0.3", + "cloudabi", "libc", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", "winapi 0.3.9", ] [[package]] name = "parking_lot_core" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" dependencies = [ "backtrace", - "cfg-if 0.1.10", - "cloudabi 0.1.0", + "cfg-if 1.0.0", "instant", "libc", "petgraph", - "redox_syscall", + "redox_syscall 0.1.57", "smallvec", "thread-id", "winapi 0.3.9", @@ -2108,8 +2094,8 @@ dependencies = [ "pest", "pest_meta", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -2133,26 +2119,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "pin-project" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" -dependencies = [ - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", -] - [[package]] name = "pin-project-lite" version = "0.1.11" @@ -2161,9 +2127,9 @@ checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" [[package]] name = "pin-project-lite" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -2179,16 +2145,32 @@ checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "plotters" -version = "0.2.15" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" dependencies = [ - "js-sys", "num-traits", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "ppv-lite86" version = "0.2.10" @@ -2222,8 +2204,8 @@ checksum = "18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7" dependencies = [ "proc-macro-error-attr", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", "version_check", ] @@ -2234,8 +2216,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69de" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", "syn-mid", "version_check", ] @@ -2248,9 +2230,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" @@ -2327,9 +2309,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2 1.0.24", ] @@ -2359,7 +2341,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.16", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", @@ -2368,9 +2350,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18519b42a40024d661e1714153e9ad0c3de27cd495760ceb09710920f1098b1e" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", "rand_chacha 0.3.0", @@ -2429,7 +2411,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.15", + "getrandom 0.1.16", ] [[package]] @@ -2438,7 +2420,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" dependencies = [ - "getrandom 0.2.1", + "getrandom 0.2.2", ] [[package]] @@ -2494,7 +2476,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ - "cloudabi 0.0.3", + "cloudabi", "fuchsia-cprng", "libc", "rand_core 0.4.2", @@ -2532,9 +2514,9 @@ dependencies = [ [[package]] name = "range-alloc" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a871f1e45a3a3f0c73fb60343c811238bb5143a81642e27c2ac7aac27ff01a63" +checksum = "63e935c45e09cc6dcf00d2f0b2d630a58f4095320223d47fc68918722f0538b6" [[package]] name = "raw-window-handle" @@ -2586,21 +2568,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] -name = "redox_users" -version = "0.3.5" +name = "redox_syscall" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" dependencies = [ - "getrandom 0.1.15", - "redox_syscall", - "rust-argon2", + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom 0.2.2", + "redox_syscall 0.2.4", ] [[package]] name = "regex" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" dependencies = [ "aho-corasick", "memchr", @@ -2619,9 +2609,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.21" +version = "0.6.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" +checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" [[package]] name = "remove_dir_all" @@ -2662,7 +2652,6 @@ dependencies = [ "roc_solve", "roc_types", "roc_unify", - "roc_uniq", "target-lexicon", "tempfile", ] @@ -2741,7 +2730,6 @@ dependencies = [ "roc_solve", "roc_types", "roc_unify", - "roc_uniq", "rustyline", "rustyline-derive", "serde", @@ -2779,7 +2767,6 @@ dependencies = [ "roc_parse", "roc_region", "roc_types", - "roc_uniq", ] [[package]] @@ -2801,7 +2788,7 @@ dependencies = [ "indoc", "inkwell", "inlinable_string", - "itertools", + "itertools 0.9.0", "libc", "log", "maplit", @@ -2811,7 +2798,7 @@ dependencies = [ "pretty_assertions", "quickcheck", "quickcheck_macros", - "rand 0.8.2", + "rand 0.8.3", "roc_builtins", "roc_can", "roc_collections", @@ -2828,7 +2815,6 @@ dependencies = [ "roc_solve", "roc_types", "roc_unify", - "roc_uniq", "ropey", "snafu", "target-lexicon", @@ -2893,7 +2879,6 @@ dependencies = [ "roc_std", "roc_types", "roc_unify", - "roc_uniq", "target-lexicon", "tokio", ] @@ -2907,11 +2892,11 @@ dependencies = [ "im-rc", "indoc", "inlinable_string", - "itertools", + "itertools 0.9.0", "libc", "libloading", "maplit", - "object", + "object 0.22.0", "pretty_assertions", "quickcheck", "quickcheck_macros", @@ -2931,7 +2916,6 @@ dependencies = [ "roc_std", "roc_types", "roc_unify", - "roc_uniq", "target-lexicon", "tempfile", "tokio", @@ -3136,30 +3120,6 @@ dependencies = [ "roc_types", ] -[[package]] -name = "roc_uniq" -version = "0.1.0" -dependencies = [ - "bumpalo", - "im", - "im-rc", - "indoc", - "maplit", - "pretty_assertions", - "quickcheck", - "quickcheck_macros", - "roc_builtins", - "roc_can", - "roc_collections", - "roc_constrain", - "roc_module", - "roc_parse", - "roc_problem", - "roc_region", - "roc_solve", - "roc_types", -] - [[package]] name = "ropey" version = "1.2.0" @@ -3169,18 +3129,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "rust-argon2" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" -dependencies = [ - "base64", - "blake2b_simd", - "constant_time_eq", - "crossbeam-utils 0.8.1", -] - [[package]] name = "rustc-demangle" version = "0.1.18" @@ -3218,19 +3166,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f61411055101f7b60ecf1041d87fb74205fb20b0c7a723f07ef39174cf6b4c0" dependencies = [ "approx 0.3.2", - "ordered-float", + "ordered-float 1.1.1", "stb_truetype", ] [[package]] name = "rustyline" -version = "7.0.0" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a5f54deba50e65ee4cf786dbc37e8b3c63bdccccbcf9d3a8a9fd0c1bb7e1984" +checksum = "8227301bfc717136f0ecbd3d064ba8199e44497a0bdd46bb01ede4387cfd2cec" dependencies = [ "bitflags", "cfg-if 1.0.0", - "dirs", + "dirs-next", "fs2", "libc", "log", @@ -3249,8 +3197,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db9dfbf470021de34cfaf6983067f460ea19164934a7c2d4b92eec0968eb95f1" dependencies = [ - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -3297,18 +3245,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.117" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" +checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae" dependencies = [ "serde_derive", ] [[package]] name = "serde-xml-rs" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efe415925cf3d0bbb2fc47d09b56ce03eef51c5d56846468a39bcc293c7a846c" +checksum = "f0bf1ba0696ccf0872866277143ff1fd14d22eec235d2b23702f95e6660f7dfa" dependencies = [ "log", "serde", @@ -3328,20 +3276,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.117" +version = "1.0.123" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" +checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "serde_json" -version = "1.0.60" +version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1500e84d27fe482ed1dc791a56eddc2f230046a040fa908c08bda1d9fb615779" +checksum = "ea1c6153794552ea7cf7cf63b1231a25de00ec90db326ba6264440fa08e31486" dependencies = [ "itoa", "ryu", @@ -3366,8 +3314,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -3384,9 +3332,9 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ "libc", ] @@ -3409,9 +3357,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acad6f34eb9e8a259d3283d1e8c1d34d7415943d4895f65cc73813c7396fc85" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "smithay-client-toolkit" @@ -3448,9 +3396,9 @@ dependencies = [ [[package]] name = "smithay-clipboard" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab88b219728cad0697a6c9e75da50bf5220ba01b3485e33e407931539a8ebc91" +checksum = "06384dfaf645908220d976ae24ed39f6cf92efecb0225ea0a948e403014de527" dependencies = [ "smithay-client-toolkit 0.12.2", "wayland-client 0.28.3", @@ -3474,27 +3422,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1508efa03c362e23817f96cde18abed596a25219a8b2c66e8db33c03543d315b" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] name = "socket2" -version = "0.3.17" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] [[package]] name = "spirv_cross" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea964c42ce40326fe96111918abe71fa45076da1ea85769f3f1ab1cda9a1d496" +checksum = "0ebd49af36be83ecd6290b57147e2a0e26145b832634b17146d934b197ca3713" dependencies = [ "cc", "js-sys", @@ -3563,24 +3510,24 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.53" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" +checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "unicode-xid 0.2.1", ] [[package]] name = "syn-mid" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42823f0ff906a3eb8109610e825221b07fb1456d45c7d01cf18cb581b23ecfb" +checksum = "baa8e7560a164edb1621a55d18a0c59abf49d360f47aa7b821061dd7eea7fac9" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -3590,8 +3537,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", "unicode-xid 0.2.1", ] @@ -3603,14 +3550,14 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "tempfile" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "rand 0.7.3", - "redox_syscall", + "rand 0.8.3", + "redox_syscall 0.2.4", "remove_dir_all", "winapi 0.3.9", ] @@ -3635,22 +3582,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", ] [[package]] @@ -3660,17 +3607,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1" dependencies = [ "libc", - "redox_syscall", + "redox_syscall 0.1.57", "winapi 0.3.9", ] [[package]] name = "thread_local" -version = "1.0.1" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -3681,9 +3628,9 @@ checksum = "7572415bd688d401c52f6e36f4c8e805b9ae1622619303b9fa835d531db0acae" [[package]] name = "tinytemplate" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3dc76004a03cec1c5932bca4cdc2e39aaa798e3f82363dd94f9adf6098c12f" +checksum = "a2ada8616fad06a2d0c455adc530de4ef57605a8120cc65da9653e0e9623ca74" dependencies = [ "serde", "serde_json", @@ -3691,9 +3638,9 @@ dependencies = [ [[package]] name = "tokio" -version = "0.2.23" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ "bytes", "fnv", @@ -3712,21 +3659,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "tracing" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +checksum = "f7d40a22fd029e33300d8d89a5cc8ffce18bb7c587662f54629e94c9de5487f3" dependencies = [ "cfg-if 1.0.0", - "pin-project-lite 0.2.0", + "pin-project-lite 0.2.4", "tracing-core", ] @@ -3741,9 +3688,9 @@ dependencies = [ [[package]] name = "ttf-parser" -version = "0.8.3" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7622061403fd00f0820df288e5a580e87d3ce15a1c4313c59fd1ffb77129903f" +checksum = "f3e7994fc4aed0ee366a4b0d01562c8a7cd5a5017088bceb6921b0c8c538f34e" [[package]] name = "twox-hash" @@ -3897,15 +3844,15 @@ checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" -version = "0.10.1+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -3913,24 +3860,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", "log", "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3940,32 +3887,32 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ - "quote 1.0.7", + "quote 1.0.8", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.53", + "quote 1.0.8", + "syn 1.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "wasmparser" @@ -4081,7 +4028,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7010ba5767b3fcd350decc59055390b4ebe6bd1b9279a9feb1f1888987f1133d" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.7", + "quote 1.0.8", "xml-rs", ] @@ -4108,9 +4055,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", @@ -4374,6 +4321,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d498dbd1fd7beb83c86709ae1c33ca50942889473473d287d56ce4770a18edfb" dependencies = [ "proc-macro2 1.0.24", - "syn 1.0.53", + "syn 1.0.60", "synstructure", ] diff --git a/Cargo.toml b/Cargo.toml index 2d986f0009..9c25dd9e56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ members = [ "compiler/can", "compiler/problem", "compiler/types", - "compiler/uniq", "compiler/builtins", "compiler/constrain", "compiler/unify", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index e0bb9f0a1c..b420d22a37 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -40,7 +40,6 @@ roc_problem = { path = "../compiler/problem" } roc_types = { path = "../compiler/types" } roc_builtins = { path = "../compiler/builtins" } roc_constrain = { path = "../compiler/constrain" } -roc_uniq = { path = "../compiler/uniq" } roc_unify = { path = "../compiler/unify" } roc_solve = { path = "../compiler/solve" } roc_mono = { path = "../compiler/mono" } diff --git a/compiler/build/Cargo.toml b/compiler/build/Cargo.toml index 4b48dd2d26..99e10bf0f1 100644 --- a/compiler/build/Cargo.toml +++ b/compiler/build/Cargo.toml @@ -15,7 +15,6 @@ roc_problem = { path = "../problem" } roc_types = { path = "../types" } roc_builtins = { path = "../builtins" } roc_constrain = { path = "../constrain" } -roc_uniq = { path = "../uniq" } roc_unify = { path = "../unify" } roc_solve = { path = "../solve" } roc_mono = { path = "../mono" } diff --git a/compiler/can/tests/helpers/mod.rs b/compiler/can/tests/helpers/mod.rs index 402866e85c..3d7c7e0b2c 100644 --- a/compiler/can/tests/helpers/mod.rs +++ b/compiler/can/tests/helpers/mod.rs @@ -10,7 +10,7 @@ use roc_collections::all::MutMap; use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds}; use roc_parse::ast::{self, Attempting}; use roc_parse::blankspace::space0_before; -use roc_parse::parser::{loc, Bag, Parser, State}; +use roc_parse::parser::{loc, Bag, Parser, State, SyntaxError}; use roc_problem::can::Problem; use roc_region::all::{Located, Region}; use roc_types::subs::{VarStore, Variable}; @@ -21,7 +21,10 @@ pub fn test_home() -> ModuleId { } #[allow(dead_code)] -pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Bag<'a>> { +pub fn parse_with<'a>( + arena: &'a Bump, + input: &'a str, +) -> Result, Bag<'a, SyntaxError<'a>>> { parse_loc_with(arena, input).map(|loc_expr| loc_expr.value) } @@ -29,7 +32,7 @@ pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, pub fn parse_loc_with<'a>( arena: &'a Bump, input: &'a str, -) -> Result>, Bag<'a>> { +) -> Result>, Bag<'a, SyntaxError<'a>>> { let state = State::new_in(arena, input.trim().as_bytes(), Attempting::Module); let parser = space0_before(loc(roc_parse::expr::expr(0)), 0); let answer = parser.parse(&arena, state); diff --git a/compiler/constrain/Cargo.toml b/compiler/constrain/Cargo.toml index feb907ca3d..b703ad9164 100644 --- a/compiler/constrain/Cargo.toml +++ b/compiler/constrain/Cargo.toml @@ -13,7 +13,6 @@ roc_parse = { path = "../parse" } roc_types = { path = "../types" } roc_can = { path = "../can" } roc_builtins = { path = "../builtins" } -roc_uniq = { path = "../uniq" } [dev-dependencies] pretty_assertions = "0.5.1" diff --git a/compiler/constrain/src/lib.rs b/compiler/constrain/src/lib.rs index 0e30c75a9c..2304b8a738 100644 --- a/compiler/constrain/src/lib.rs +++ b/compiler/constrain/src/lib.rs @@ -5,4 +5,3 @@ pub mod builtins; pub mod expr; pub mod module; pub mod pattern; -pub mod uniq; diff --git a/compiler/constrain/src/module.rs b/compiler/constrain/src/module.rs index afdf6bdd39..57cd74df17 100644 --- a/compiler/constrain/src/module.rs +++ b/compiler/constrain/src/module.rs @@ -26,7 +26,8 @@ pub fn constrain_module( module: &ModuleOutput, home: ModuleId, mode: Mode, - var_store: &mut VarStore, + // TODO remove parameter + _var_store: &mut VarStore, ) -> Constraint { use Mode::*; @@ -40,7 +41,7 @@ pub fn constrain_module( match mode { Standard => constrain_decls(home, decls), - Uniqueness => crate::uniq::constrain_decls(home, decls, var_store), + Uniqueness => constrain_decls(home, decls), } } diff --git a/compiler/constrain/src/uniq.rs b/compiler/constrain/src/uniq.rs deleted file mode 100644 index 4d6552ea83..0000000000 --- a/compiler/constrain/src/uniq.rs +++ /dev/null @@ -1,2641 +0,0 @@ -use crate::builtins::{num_floatingpoint, num_integer, num_num}; -use crate::expr::{exists, Info}; -use roc_can::annotation::IntroducedVariables; -use roc_can::constraint::Constraint::{self, *}; -use roc_can::constraint::LetConstraint; -use roc_can::def::{Declaration, Def}; -use roc_can::expected::{Expected, PExpected}; -use roc_can::expr::{Expr, Field, WhenBranch}; -use roc_can::pattern::{DestructType, Pattern, RecordDestruct}; -use roc_collections::all::{ImMap, ImSet, Index, SendMap}; -use roc_module::ident::{Ident, Lowercase}; -use roc_module::symbol::{ModuleId, Symbol}; -use roc_region::all::{Located, Region}; -use roc_types::boolean_algebra::Bool; -use roc_types::subs::{VarStore, Variable}; -use roc_types::types::AnnotationSource::{self, *}; -use roc_types::types::Type::{self, *}; -use roc_types::types::{Category, PReason, Reason, RecordField}; -use roc_uniq::builtins::{attr_type, empty_list_type, list_type, str_type}; -use roc_uniq::sharing::{self, FieldAccess, Mark, Usage, VarUsage}; - -pub struct Env { - /// Whenever we encounter a user-defined type variable (a "rigid" var for short), - /// for example `u` and `a` in the annotation `identity : Attr u a -> Attr u a`, we add it to this - /// map so that expressions within that annotation can share these vars. - pub rigids: ImMap, - pub home: ModuleId, -} - -pub fn constrain_declaration( - home: ModuleId, - var_store: &mut VarStore, - region: Region, - loc_expr: &Located, - _declared_idents: &ImMap, - expected: Expected, -) -> Constraint { - // TODO this means usage is local to individual declarations. - // Should be per-module in the future! - let mut var_usage = VarUsage::default(); - - sharing::annotate_usage(&loc_expr.value, &mut var_usage); - - let mut applied_usage_constraint = ImSet::default(); - constrain_expr( - &Env { - rigids: ImMap::default(), - home, - }, - var_store, - &var_usage, - &mut applied_usage_constraint, - region, - &loc_expr.value, - expected, - ) -} - -/// Constrain top-level module declarations -#[inline(always)] -pub fn constrain_decls( - home: ModuleId, - decls: &[Declaration], - var_store: &mut VarStore, -) -> Constraint { - let mut constraint = Constraint::SaveTheEnvironment; - - // perform usage analysis on the whole file - let mut var_usage = VarUsage::default(); - - for decl in decls.iter().rev() { - // NOTE: rigids are empty because they are not shared between top-level definitions - match decl { - Declaration::Declare(def) | Declaration::Builtin(def) => { - sharing::annotate_usage(&def.loc_expr.value, &mut var_usage); - } - Declaration::DeclareRec(defs) => { - for def in defs { - sharing::annotate_usage(&def.loc_expr.value, &mut var_usage); - } - } - Declaration::InvalidCycle(_, _) => { - // any usage of a value defined in an invalid cycle will blow up - // so for the analysis usage by such values doesn't count - continue; - } - } - } - - let mut env = Env { - home, - rigids: ImMap::default(), - }; - - for decl in decls.iter().rev() { - // clear the set of rigids from the previous iteration. - // rigids are not shared between top-level definitions. - env.rigids.clear(); - - match decl { - Declaration::Declare(def) | Declaration::Builtin(def) => { - constraint = exists( - Vec::new(), - constrain_def( - &env, - var_store, - &var_usage, - &mut ImSet::default(), - def, - constraint, - ), - ); - } - Declaration::DeclareRec(defs) => { - constraint = exists( - Vec::new(), - constrain_recursive_defs( - &env, - var_store, - &var_usage, - &mut ImSet::default(), - defs, - constraint, - ), - ); - } - Declaration::InvalidCycle(_, _) => { - // invalid cycles give a canonicalization error. we skip them here. - continue; - } - } - } - - constraint -} - -pub struct PatternState { - pub headers: SendMap>, - pub vars: Vec, - pub constraints: Vec, -} - -fn constrain_pattern( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - state: &mut PatternState, - pattern: &Located, - expected: PExpected, -) { - use roc_can::pattern::Pattern::*; - use roc_types::types::PatternCategory; - - let region = pattern.region; - - match &pattern.value { - Identifier(symbol) => { - state.headers.insert( - *symbol, - Located { - region: pattern.region, - value: expected.get_type(), - }, - ); - } - - NumLiteral(inner_var, _) => { - let (inner_uvar, num_var, num_type) = unique_unbound_num(*inner_var, var_store); - state.constraints.push(exists( - vec![num_var, inner_uvar, *inner_var], - Constraint::Pattern(pattern.region, PatternCategory::Num, num_type, expected), - )); - } - - IntLiteral(inner_var, _) => { - let (a, b, c, num_type) = unique_int(var_store); - - state.constraints.push(exists( - vec![*inner_var, a, b, c], - Constraint::Pattern(pattern.region, PatternCategory::Int, num_type, expected), - )); - } - FloatLiteral(inner_var, _) => { - let (a, b, c, num_type) = unique_float(var_store); - - state.constraints.push(exists( - vec![*inner_var, a, b, c], - Constraint::Pattern(pattern.region, PatternCategory::Float, num_type, expected), - )); - } - - StrLiteral(_) => { - let uniq_var = var_store.fresh(); - state.constraints.push(exists( - vec![uniq_var], - Constraint::Pattern( - pattern.region, - PatternCategory::Str, - str_type(Bool::variable(uniq_var)), - expected, - ), - )); - } - - RecordDestructure { - whole_var, - ext_var, - destructs, - } => { - // TODO if a subpattern doesn't bind any identifiers, it doesn't count for uniqueness - let mut pattern_uniq_vars = Vec::with_capacity(destructs.len()); - - state.vars.push(*whole_var); - state.vars.push(*ext_var); - let ext_type = Type::Variable(*ext_var); - - let mut field_types: SendMap> = SendMap::default(); - for Located { - value: - RecordDestruct { - var, - label, - symbol, - typ, - }, - .. - } in destructs - { - let pat_uniq_var = var_store.fresh(); - pattern_uniq_vars.push(pat_uniq_var); - - let pat_type = attr_type(Bool::variable(pat_uniq_var), Type::Variable(*var)); - let expected = PExpected::NoExpectation(pat_type.clone()); - - if !state.headers.contains_key(&symbol) { - state - .headers - .insert(*symbol, Located::at(pattern.region, pat_type.clone())); - } - - let field_type = match typ { - DestructType::Guard(guard_var, loc_guard) => { - state.constraints.push(Constraint::Pattern( - pattern.region, - PatternCategory::PatternGuard, - Type::Variable(*guard_var), - PExpected::NoExpectation(pat_type.clone()), - )); - state.vars.push(*guard_var); - constrain_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - state, - loc_guard, - expected, - ); - - RecordField::Demanded(pat_type) - } - DestructType::Optional(expr_var, loc_expr) => { - let expr_expected = Expected::ForReason( - Reason::RecordDefaultField(label.clone()), - pat_type.clone(), - loc_expr.region, - ); - - state.constraints.push(Constraint::Pattern( - region, - PatternCategory::PatternDefault, - Type::Variable(*expr_var), - PExpected::ForReason( - PReason::OptionalField, - pat_type.clone(), - loc_expr.region, - ), - )); - - state.vars.push(*expr_var); - - let expr_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_expr.region, - &loc_expr.value, - expr_expected, - ); - state.constraints.push(expr_con); - - RecordField::Optional(pat_type) - } - DestructType::Required => { - // No extra constraints necessary. - RecordField::Demanded(pat_type) - } - }; - - field_types.insert(label.clone(), field_type); - - state.vars.push(*var); - } - - let record_uniq_type = { - let empty_var = var_store.fresh(); - state.vars.push(empty_var); - state.vars.extend(pattern_uniq_vars.clone()); - Bool::container(empty_var, pattern_uniq_vars) - }; - - let record_type = attr_type( - record_uniq_type, - Type::Record(field_types, Box::new(ext_type)), - ); - - let whole_con = Constraint::Eq( - Type::Variable(*whole_var), - Expected::NoExpectation(record_type), - Category::Storage(std::file!(), std::line!()), - region, - ); - - let record_con = Constraint::Pattern( - region, - PatternCategory::Record, - Type::Variable(*whole_var), - expected, - ); - - state.constraints.push(whole_con); - state.constraints.push(record_con); - } - - AppliedTag { - whole_var, - ext_var, - tag_name, - arguments, - } => { - // TODO if a subpattern doesn't bind any identifiers, it doesn't count for uniqueness - let mut argument_types = Vec::with_capacity(arguments.len()); - let mut pattern_uniq_vars = Vec::with_capacity(arguments.len()); - - for (pattern_var, loc_pattern) in arguments { - state.vars.push(*pattern_var); - - let pat_uniq_var = var_store.fresh(); - pattern_uniq_vars.push(pat_uniq_var); - - let pattern_type = - attr_type(Bool::variable(pat_uniq_var), Type::Variable(*pattern_var)); - argument_types.push(pattern_type.clone()); - - let expected = PExpected::NoExpectation(pattern_type); - constrain_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - state, - loc_pattern, - expected, - ); - } - - let tag_union_uniq_type = { - let empty_var = var_store.fresh(); - state.vars.push(empty_var); - state.vars.extend(pattern_uniq_vars.clone()); - Bool::container(empty_var, pattern_uniq_vars) - }; - let union_type = attr_type( - tag_union_uniq_type, - Type::TagUnion( - vec![(tag_name.clone(), argument_types)], - Box::new(Type::Variable(*ext_var)), - ), - ); - - let whole_con = Constraint::Eq( - Type::Variable(*whole_var), - Expected::NoExpectation(union_type), - Category::Storage(std::file!(), std::line!()), - region, - ); - - let tag_con = Constraint::Pattern( - region, - PatternCategory::Ctor(tag_name.clone()), - Type::Variable(*whole_var), - expected, - ); - - state.vars.push(*whole_var); - state.vars.push(*ext_var); - - state.constraints.push(whole_con); - state.constraints.push(tag_con); - } - - Underscore | Shadowed(_, _) | MalformedPattern(_, _) | UnsupportedPattern(_) => { - // no constraints - } - } -} - -fn unique_unbound_num(inner_var: Variable, var_store: &mut VarStore) -> (Variable, Variable, Type) { - let num_uvar = var_store.fresh(); - let inner_uvar = var_store.fresh(); - - let val_type = Type::Variable(inner_var); - let val_utype = attr_type(Bool::variable(inner_uvar), val_type); - - let num_utype = num_num(val_utype); - let num_type = attr_type(Bool::variable(num_uvar), num_utype); - - (inner_uvar, num_uvar, num_type) -} - -fn unique_int(var_store: &mut VarStore) -> (Variable, Variable, Variable, Type) { - let num_uvar1 = var_store.fresh(); - let num_uvar2 = var_store.fresh(); - let num_uvar3 = var_store.fresh(); - let num_uvar4 = var_store.fresh(); - - let integer = num_integer(Type::Variable(num_uvar4)); - let attr_int = attr_type(Bool::variable(num_uvar2), integer); - let num = num_num(attr_int); - let attr_num = attr_type(Bool::variable(num_uvar3), num); - - (num_uvar1, num_uvar2, num_uvar3, attr_num) -} - -fn unique_float(var_store: &mut VarStore) -> (Variable, Variable, Variable, Type) { - let num_uvar1 = var_store.fresh(); - let num_uvar2 = var_store.fresh(); - let num_uvar3 = var_store.fresh(); - let num_uvar4 = var_store.fresh(); - - let fp = num_floatingpoint(Type::Variable(num_uvar4)); - let attr_fp = attr_type(Bool::variable(num_uvar2), fp); - let num = num_num(attr_fp); - let attr_num = attr_type(Bool::variable(num_uvar3), num); - - (num_uvar1, num_uvar2, num_uvar3, attr_num) -} - -pub fn constrain_expr( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - region: Region, - expr: &Expr, - expected: Expected, -) -> Constraint { - pub use roc_can::expr::Expr::*; - - match expr { - Num(inner_var, _) => { - let var = var_store.fresh(); - let (inner_uvar, num_var, num_type) = unique_unbound_num(*inner_var, var_store); - - exists( - vec![var, *inner_var, inner_uvar, num_var], - And(vec![ - Eq( - Type::Variable(var), - Expected::ForReason(Reason::NumLiteral, num_type, region), - Category::Num, - region, - ), - Eq(Type::Variable(var), expected, Category::Num, region), - ]), - ) - } - Int(var, _, _) => { - let (a, b, c, num_type) = unique_int(var_store); - - exists( - vec![*var, a, b, c], - And(vec![ - Eq( - Type::Variable(*var), - Expected::ForReason(Reason::IntLiteral, num_type, region), - Category::Int, - region, - ), - Eq(Type::Variable(*var), expected, Category::Int, region), - ]), - ) - } - Float(var, _, _) => { - let (a, b, c, num_type) = unique_float(var_store); - - exists( - vec![*var, a, b, c], - And(vec![ - Eq( - Type::Variable(*var), - Expected::ForReason(Reason::FloatLiteral, num_type, region), - Category::Float, - region, - ), - Eq(Type::Variable(*var), expected, Category::Float, region), - ]), - ) - } - Str(_) => { - let uniq_type = var_store.fresh(); - let inferred = str_type(Bool::variable(uniq_type)); - - exists( - vec![uniq_type], - Eq(inferred, expected, Category::Str, region), - ) - } - EmptyRecord => { - let uniq_type = var_store.fresh(); - - exists( - vec![uniq_type], - Eq( - attr_type(Bool::variable(uniq_type), EmptyRec), - expected, - Category::Record, - region, - ), - ) - } - Record { - record_var, fields, .. - } => { - // NOTE: canonicalization guarantees at least one field - // zero fields generates an EmptyRecord - let mut field_types = SendMap::default(); - let mut field_vars = Vec::with_capacity(fields.len()); - field_vars.push(*record_var); - - // Constraints need capacity for each field + 1 for the record itself + 1 for ext - let mut constraints = Vec::with_capacity(2 + fields.len()); - - for (label, ref field) in fields.iter() { - let field_var = var_store.fresh(); - let field_type = Variable(field_var); - let field_expected = Expected::NoExpectation(field_type.clone()); - let loc_expr = &*field.loc_expr; - let field_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_expr.region, - &loc_expr.value, - field_expected, - ); - - field_vars.push(field_var); - field_types.insert(label.clone(), RecordField::Required(field_type)); - - constraints.push(field_con); - } - - let record_uniq_var = var_store.fresh(); - field_vars.push(record_uniq_var); - let record_type = attr_type( - Bool::variable(record_uniq_var), - Type::Record( - field_types, - // TODO can we avoid doing Box::new on every single one of these? - // For example, could we have a single lazy_static global Box they - // could all share? - Box::new(Type::EmptyRec), - ), - ); - let record_con = Eq(record_type, expected.clone(), Category::Record, region); - let ext_con = Eq( - Type::Variable(*record_var), - expected, - Category::Record, - region, - ); - - constraints.push(record_con); - constraints.push(ext_con); - - exists(field_vars, And(constraints)) - } - Tag { - variant_var, - ext_var, - name, - arguments, - } => { - let mut vars = Vec::with_capacity(arguments.len()); - let mut types = Vec::with_capacity(arguments.len()); - let mut arg_cons = Vec::with_capacity(arguments.len()); - - for (var, loc_expr) in arguments { - let arg_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_expr.region, - &loc_expr.value, - Expected::NoExpectation(Type::Variable(*var)), - ); - - arg_cons.push(arg_con); - vars.push(*var); - types.push(Type::Variable(*var)); - } - - let uniq_var = var_store.fresh(); - - let union_type = attr_type( - Bool::variable(uniq_var), - Type::TagUnion( - vec![(name.clone(), types)], - Box::new(Type::Variable(*ext_var)), - ), - ); - - let union_con = Eq( - union_type, - expected.clone(), - Category::TagApply { - tag_name: name.clone(), - args_count: arguments.len(), - }, - region, - ); - let ast_con = Eq( - Type::Variable(*variant_var), - expected, - Category::TagApply { - tag_name: name.clone(), - args_count: arguments.len(), - }, - region, - ); - - vars.push(uniq_var); - vars.push(*variant_var); - vars.push(*ext_var); - arg_cons.push(union_con); - arg_cons.push(ast_con); - - exists(vars, And(arg_cons)) - } - List { - list_var, - elem_var, - loc_elems, - } => { - let uniq_var = var_store.fresh(); - if loc_elems.is_empty() { - let inferred = empty_list_type(Bool::variable(uniq_var), *elem_var); - exists( - vec![*elem_var, uniq_var], - Eq(inferred, expected, Category::List, region), - ) - } else { - // constrain `expected ~ List a` and that all elements `~ a`. - let entry_type = Type::Variable(*elem_var); - let mut constraints = Vec::with_capacity(1 + loc_elems.len()); - - for (index, loc_elem) in loc_elems.iter().enumerate() { - let elem_expected = Expected::ForReason( - Reason::ElemInList { - index: Index::zero_based(index), - }, - entry_type.clone(), - region, - ); - let constraint = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_elem.region, - &loc_elem.value, - elem_expected, - ); - - constraints.push(constraint); - } - - let inferred = list_type(Bool::variable(uniq_var), entry_type); - constraints.push(Eq(inferred, expected.clone(), Category::List, region)); - - let stored = Type::Variable(*list_var); - constraints.push(Eq( - stored, - expected, - Category::Storage(std::file!(), std::line!()), - region, - )); - - exists(vec![*elem_var, *list_var, uniq_var], And(constraints)) - } - } - Var(symbol) => { - let usage = var_usage.get_usage(*symbol); - - constrain_var( - var_store, - applied_usage_constraint, - *symbol, - usage, - region, - expected, - ) - } - Closure { - function_type: fn_var, - return_type: ret_var, - closure_type: closure_var, - closure_ext_var, - recursive: recursion, - arguments, - loc_body: boxed, - captured_symbols, - name, - .. - } => { - use roc_can::expr::Recursive; - - let loc_body_expr = &**boxed; - let mut state = PatternState { - headers: SendMap::default(), - vars: Vec::with_capacity(arguments.len()), - constraints: Vec::with_capacity(1), - }; - let mut vars = Vec::with_capacity(state.vars.capacity() + 1); - let mut pattern_types = Vec::with_capacity(state.vars.capacity()); - let ret_var = *ret_var; - let ret_type = Type::Variable(ret_var); - let closure_var = *closure_var; - let closure_ext_var = *closure_ext_var; - - vars.push(ret_var); - vars.push(closure_var); - vars.push(closure_ext_var); - vars.push(*fn_var); - - for (pattern_var, loc_pattern) in arguments { - let pattern_type = Type::Variable(*pattern_var); - let pattern_expected = PExpected::NoExpectation(pattern_type.clone()); - - pattern_types.push(pattern_type); - - constrain_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - &mut state, - loc_pattern, - pattern_expected, - ); - - vars.push(*pattern_var); - } - - let fn_uniq_type; - if let Recursive::NotRecursive = recursion { - let fn_uniq_var = var_store.fresh(); - vars.push(fn_uniq_var); - fn_uniq_type = Bool::variable(fn_uniq_var); - } else { - // recursive definitions MUST be Shared - fn_uniq_type = Bool::shared() - } - - let body_type = Expected::NoExpectation(ret_type.clone()); - let ret_constraint = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_body_expr.region, - &loc_body_expr.value, - body_type, - ); - - let defs_constraint = And(state.constraints); - - let closure_constraint = constrain_closure_size( - *name, - region, - captured_symbols, - closure_var, - closure_ext_var, - &mut vars, - ); - - let fn_type = attr_type( - fn_uniq_type, - Type::Function( - pattern_types, - Box::new(Type::Variable(closure_var)), - Box::new(ret_type), - ), - ); - - exists( - vars, - And(vec![ - Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: state.vars, - def_types: state.headers, - defs_constraint, - ret_constraint, - })), - // "the closure's type is equal to expected type" - Eq(fn_type.clone(), expected, Category::Lambda, region), - // "fn_var is equal to the closure's type" - fn_var is used in code gen - Eq( - Type::Variable(*fn_var), - Expected::NoExpectation(fn_type), - Category::Lambda, - region, - ), - closure_constraint, - ]), - ) - } - - Call(boxed, loc_args, _) => { - let (fn_var, fn_expr, closure_var, ret_var) = &**boxed; - let fn_type = Variable(*fn_var); - let ret_type = Variable(*ret_var); - let closure_type = Variable(*closure_var); - let fn_expected = Expected::NoExpectation(fn_type.clone()); - let fn_region = fn_expr.region; - - let opt_symbol = if let Var(symbol) = fn_expr.value { - Some(symbol) - } else { - None - }; - - let mut vars = Vec::with_capacity(2 + loc_args.len()); - - vars.push(*fn_var); - vars.push(*ret_var); - vars.push(*closure_var); - - // Canonicalize the function expression and its arguments - let fn_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - fn_region, - &fn_expr.value, - fn_expected, - ); - - let fn_reason = Reason::FnCall { - name: opt_symbol, - arity: loc_args.len() as u8, - }; - - let mut arg_types = Vec::with_capacity(loc_args.len()); - let mut arg_cons = Vec::with_capacity(loc_args.len()); - - for (index, (arg_var, loc_arg)) in loc_args.iter().enumerate() { - let region = loc_arg.region; - let arg_type = Variable(*arg_var); - - let reason = Reason::FnArg { - name: opt_symbol, - arg_index: Index::zero_based(index), - }; - - let expected_arg = Expected::ForReason(reason, arg_type.clone(), region); - let arg_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_arg.region, - &loc_arg.value, - expected_arg, - ); - - vars.push(*arg_var); - arg_types.push(arg_type); - arg_cons.push(arg_con); - } - - let expected_uniq_type = var_store.fresh(); - vars.push(expected_uniq_type); - let expected_fn_type = Expected::ForReason( - fn_reason, - attr_type( - Bool::variable(expected_uniq_type), - Function( - arg_types, - Box::new(closure_type), - Box::new(ret_type.clone()), - ), - ), - region, - ); - - exists( - vars, - And(vec![ - fn_con, - Eq( - fn_type, - expected_fn_type, - Category::CallResult(opt_symbol), - fn_region, - ), - And(arg_cons), - Eq(ret_type, expected, Category::CallResult(opt_symbol), region), - ]), - ) - } - RunLowLevel { op, args, ret_var } => { - // This is a modified version of what we do for function calls. - - let ret_type = Variable(*ret_var); - let mut vars = Vec::with_capacity(1 + args.len()); - - vars.push(*ret_var); - - // Canonicalize the function expression and its arguments - - let mut arg_types = Vec::with_capacity(args.len()); - let mut arg_cons = Vec::with_capacity(args.len()); - - for (index, (arg_var, arg_expr)) in args.iter().enumerate() { - let arg_type = Variable(*arg_var); - - let reason = Reason::LowLevelOpArg { - op: *op, - arg_index: Index::zero_based(index), - }; - - let expected_arg = Expected::ForReason(reason, arg_type.clone(), region); - let arg_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - Region::zero(), - arg_expr, - expected_arg, - ); - - vars.push(*arg_var); - arg_types.push(arg_type); - arg_cons.push(arg_con); - } - - let expected_uniq_type = var_store.fresh(); - vars.push(expected_uniq_type); - - exists( - vars, - And(vec![ - And(arg_cons), - Eq(ret_type, expected, Category::LowLevelOpResult(*op), region), - ]), - ) - } - ForeignCall { - foreign_symbol, - args, - ret_var, - } => { - // This is a modified version of what we do for function calls. - - let ret_type = Variable(*ret_var); - let mut vars = Vec::with_capacity(1 + args.len()); - - vars.push(*ret_var); - - // Canonicalize the function expression and its arguments - - let mut arg_types = Vec::with_capacity(args.len()); - let mut arg_cons = Vec::with_capacity(args.len()); - - for (index, (arg_var, arg_expr)) in args.iter().enumerate() { - let arg_type = Variable(*arg_var); - - let reason = Reason::ForeignCallArg { - foreign_symbol: foreign_symbol.clone(), - arg_index: Index::zero_based(index), - }; - - let expected_arg = Expected::ForReason(reason, arg_type.clone(), region); - let arg_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - Region::zero(), - arg_expr, - expected_arg, - ); - - vars.push(*arg_var); - arg_types.push(arg_type); - arg_cons.push(arg_con); - } - - let expected_uniq_type = var_store.fresh(); - vars.push(expected_uniq_type); - - let category = Category::ForeignCall; - - exists( - vars, - And(vec![ - And(arg_cons), - Eq(ret_type, expected, category, region), - ]), - ) - } - LetRec(defs, loc_ret, var) => { - // NOTE doesn't currently unregister bound symbols - // may be a problem when symbols are not globally unique - let body_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_ret.region, - &loc_ret.value, - expected.clone(), - ); - - exists( - vec![*var], - And(vec![ - constrain_recursive_defs( - env, - var_store, - var_usage, - applied_usage_constraint, - defs, - body_con, - ), - // Record the type of tne entire def-expression in the variable. - // Code gen will need that later! - Eq( - Type::Variable(*var), - expected, - Category::Storage(std::file!(), std::line!()), - loc_ret.region, - ), - ]), - ) - } - LetNonRec(def, loc_ret, var) => { - // NOTE doesn't currently unregister bound symbols - // may be a problem when symbols are not globally unique - let body_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_ret.region, - &loc_ret.value, - expected.clone(), - ); - - exists( - vec![*var], - And(vec![ - constrain_def( - env, - var_store, - var_usage, - applied_usage_constraint, - def, - body_con, - ), - // Record the type of tne entire def-expression in the variable. - // Code gen will need that later! - Eq( - Type::Variable(*var), - expected, - Category::Storage(std::file!(), std::line!()), - loc_ret.region, - ), - ]), - ) - } - If { - cond_var, - branch_var, - branches, - final_else, - } => { - // TODO use Bool alias here, so we don't allocate this type every time - let bool_type = Type::Variable(Variable::BOOL); - let mut branch_cons = Vec::with_capacity(2 * branches.len() + 2); - let mut cond_uniq_vars = Vec::with_capacity(branches.len() + 2); - - // TODO why does this cond var exist? is it for error messages? - let cond_uniq_var = var_store.fresh(); - cond_uniq_vars.push(cond_uniq_var); - let cond_var_is_bool_con = Eq( - Type::Variable(*cond_var), - Expected::ForReason( - Reason::IfCondition, - attr_type(Bool::variable(cond_uniq_var), bool_type.clone()), - region, - ), - Category::If, - Region::zero(), - ); - - branch_cons.push(cond_var_is_bool_con); - - match expected { - Expected::FromAnnotation(name, arity, _, tipe) => { - for (index, (loc_cond, loc_body)) in branches.iter().enumerate() { - let cond_uniq_var = var_store.fresh(); - let expect_bool = Expected::ForReason( - Reason::IfCondition, - attr_type(Bool::variable(cond_uniq_var), bool_type.clone()), - region, - ); - cond_uniq_vars.push(cond_uniq_var); - - let cond_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_cond.region, - &loc_cond.value, - expect_bool, - ); - - let then_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_body.region, - &loc_body.value, - Expected::FromAnnotation( - name.clone(), - arity, - AnnotationSource::TypedIfBranch { - index: Index::zero_based(index), - num_branches: branches.len(), - }, - tipe.clone(), - ), - ); - - branch_cons.push(cond_con); - branch_cons.push(then_con); - } - let else_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - final_else.region, - &final_else.value, - Expected::FromAnnotation( - name, - arity, - AnnotationSource::TypedIfBranch { - index: Index::zero_based(branches.len()), - num_branches: branches.len(), - }, - tipe.clone(), - ), - ); - - let ast_con = Eq( - Type::Variable(*branch_var), - Expected::NoExpectation(tipe), - Category::Storage(std::file!(), std::line!()), - region, - ); - - branch_cons.push(ast_con); - branch_cons.push(else_con); - - cond_uniq_vars.push(*cond_var); - cond_uniq_vars.push(*branch_var); - - exists(cond_uniq_vars, And(branch_cons)) - } - _ => { - for (index, (loc_cond, loc_body)) in branches.iter().enumerate() { - let cond_uniq_var = var_store.fresh(); - let expect_bool = Expected::ForReason( - Reason::IfCondition, - attr_type(Bool::variable(cond_uniq_var), bool_type.clone()), - region, - ); - cond_uniq_vars.push(cond_uniq_var); - - let cond_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_cond.region, - &loc_cond.value, - expect_bool, - ); - - let then_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_body.region, - &loc_body.value, - Expected::ForReason( - Reason::IfBranch { - index: Index::zero_based(index), - total_branches: branches.len(), - }, - Type::Variable(*branch_var), - region, - ), - ); - - branch_cons.push(cond_con); - branch_cons.push(then_con); - } - let else_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - final_else.region, - &final_else.value, - Expected::ForReason( - Reason::IfBranch { - index: Index::zero_based(branches.len()), - total_branches: branches.len(), - }, - Type::Variable(*branch_var), - region, - ), - ); - - branch_cons.push(Eq( - Type::Variable(*branch_var), - expected, - Category::If, - region, - )); - branch_cons.push(else_con); - - cond_uniq_vars.push(*cond_var); - cond_uniq_vars.push(*branch_var); - - exists(cond_uniq_vars, And(branch_cons)) - } - } - } - When { - cond_var, - expr_var, - loc_cond, - branches, - .. - } => { - let cond_var = *cond_var; - let cond_type = Variable(cond_var); - let expr_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - region, - &loc_cond.value, - Expected::NoExpectation(cond_type.clone()), - ); - - let mut constraints = Vec::with_capacity(branches.len() + 1); - constraints.push(expr_con); - - match &expected { - Expected::FromAnnotation(name, arity, _, typ) => { - constraints.push(Eq( - Type::Variable(*expr_var), - expected.clone(), - Category::When, - region, - )); - - for (index, when_branch) in branches.iter().enumerate() { - let pattern_region = - Region::across_all(when_branch.patterns.iter().map(|v| &v.region)); - - let branch_con = constrain_when_branch( - var_store, - var_usage, - applied_usage_constraint, - env, - region, - when_branch, - PExpected::ForReason( - PReason::WhenMatch { - index: Index::zero_based(index), - }, - cond_type.clone(), - pattern_region, - ), - Expected::FromAnnotation( - name.clone(), - *arity, - TypedWhenBranch { - index: Index::zero_based(index), - }, - typ.clone(), - ), - ); - - constraints.push( - // Each branch's pattern must have the same type - // as the condition expression did. - branch_con, - ); - } - } - - _ => { - let branch_type = Variable(*expr_var); - let mut branch_cons = Vec::with_capacity(branches.len()); - - for (index, when_branch) in branches.iter().enumerate() { - let pattern_region = - Region::across_all(when_branch.patterns.iter().map(|v| &v.region)); - let branch_con = constrain_when_branch( - var_store, - var_usage, - applied_usage_constraint, - env, - region, - when_branch, - PExpected::ForReason( - PReason::WhenMatch { - index: Index::zero_based(index), - }, - cond_type.clone(), - pattern_region, - ), - Expected::ForReason( - Reason::WhenBranch { - index: Index::zero_based(index), - }, - branch_type.clone(), - region, - ), - ); - - branch_cons.push(branch_con); - } - - constraints.push(And(vec![ - // Each branch's pattern must have the same type - // as the condition expression did. - And(branch_cons), - // The return type of each branch must equal - // the return type of the entire case-expression. - Eq(branch_type, expected, Category::When, region), - ])) - } - } - - exists(vec![cond_var, *expr_var], And(constraints)) - } - - Update { - record_var, - ext_var, - symbol, - updates, - } => { - let mut fields: SendMap> = SendMap::default(); - let mut vars = Vec::with_capacity(updates.len() + 2); - let mut cons = Vec::with_capacity(updates.len() + 3); - for (field_name, Field { var, loc_expr, .. }) in updates.clone() { - let (var, tipe, con) = constrain_field_update( - env, - var_store, - var_usage, - applied_usage_constraint, - var, - region, - field_name.clone(), - &loc_expr, - ); - fields.insert(field_name, RecordField::Required(tipe)); - vars.push(var); - cons.push(con); - } - - let uniq_var = var_store.fresh(); - vars.push(uniq_var); - - let fields_type = attr_type( - Bool::variable(uniq_var), - Type::Record(fields, Box::new(Type::Variable(*ext_var))), - ); - let record_type = Type::Variable(*record_var); - - // NOTE from elm compiler: fields_type is separate so that Error propagates better - let fields_con = Eq( - record_type.clone(), - Expected::NoExpectation(fields_type), - Category::Record, - region, - ); - let record_con = Eq(record_type.clone(), expected, Category::Record, region); - - vars.push(*record_var); - vars.push(*ext_var); - - let con = Lookup( - *symbol, - Expected::ForReason( - Reason::RecordUpdateKeys( - *symbol, - updates - .iter() - .map(|(key, field)| (key.clone(), field.region)) - .collect(), - ), - record_type, - region, - ), - region, - ); - - cons.push(con); - cons.push(fields_con); - cons.push(record_con); - - exists(vars, And(cons)) - } - - Access { - record_var, - ext_var, - field_var, - loc_expr, - field, - } => { - let mut field_types = SendMap::default(); - - let field_uniq_var = var_store.fresh(); - let field_uniq_type = Bool::variable(field_uniq_var); - let field_type = attr_type(field_uniq_type, Type::Variable(*field_var)); - - field_types.insert(field.clone(), RecordField::Demanded(field_type.clone())); - - let record_uniq_var = var_store.fresh(); - let record_uniq_type = Bool::container(record_uniq_var, vec![field_uniq_var]); - let record_type = attr_type( - record_uniq_type, - Type::Record(field_types, Box::new(Type::Variable(*ext_var))), - ); - - let category = Category::Access(field.clone()); - - let record_expected = Expected::NoExpectation(record_type); - let record_con = Eq( - Type::Variable(*record_var), - record_expected.clone(), - category.clone(), - region, - ); - - let inner_constraint = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_expr.region, - &loc_expr.value, - record_expected, - ); - - exists( - vec![ - *record_var, - *field_var, - *ext_var, - field_uniq_var, - record_uniq_var, - ], - And(vec![ - Eq(field_type, expected, category, region), - inner_constraint, - record_con, - ]), - ) - } - - Accessor { - function_var, - field, - record_var, - closure_var, - field_var, - ext_var, - } => { - let mut field_types = SendMap::default(); - - let field_uniq_var = var_store.fresh(); - let field_uniq_type = Bool::variable(field_uniq_var); - let field_type = attr_type(field_uniq_type, Type::Variable(*field_var)); - - field_types.insert(field.clone(), RecordField::Demanded(field_type.clone())); - - let record_uniq_var = var_store.fresh(); - let record_uniq_type = Bool::container(record_uniq_var, vec![field_uniq_var]); - let record_type = attr_type( - record_uniq_type, - Type::Record(field_types, Box::new(Type::Variable(*ext_var))), - ); - - let category = Category::Accessor(field.clone()); - - let record_expected = Expected::NoExpectation(record_type.clone()); - let record_con = Eq( - Type::Variable(*record_var), - record_expected, - category.clone(), - region, - ); - - let fn_uniq_var = var_store.fresh(); - let closure_type = Type::Variable(*closure_var); - let fn_type = attr_type( - Bool::variable(fn_uniq_var), - Type::Function( - vec![record_type], - Box::new(closure_type), - Box::new(field_type), - ), - ); - - exists( - vec![ - *record_var, - *function_var, - *closure_var, - *field_var, - *ext_var, - fn_uniq_var, - field_uniq_var, - record_uniq_var, - ], - And(vec![ - Eq(fn_type.clone(), expected, category.clone(), region), - Eq( - fn_type, - Expected::NoExpectation(Variable(*function_var)), - category, - region, - ), - record_con, - ]), - ) - } - RuntimeError(_) => True, - } -} - -fn constrain_var( - var_store: &mut VarStore, - applied_usage_constraint: &mut ImSet, - symbol_for_lookup: Symbol, - usage: Option<&Usage>, - region: Region, - expected: Expected, -) -> Constraint { - use sharing::Mark::*; - use sharing::Usage::*; - - match usage { - None | Some(Simple(Shared)) => { - // the variable is used/consumed more than once, so it must be Shared - let val_var = var_store.fresh(); - let uniq_var = var_store.fresh(); - - let val_type = Variable(val_var); - let uniq_type = Bool::variable(uniq_var); - - let attr_type = attr_type(uniq_type.clone(), val_type); - - exists( - vec![val_var, uniq_var], - And(vec![ - Lookup(symbol_for_lookup, expected.clone(), region), - Eq(attr_type, expected, Category::Uniqueness, region), - Eq( - Type::Boolean(uniq_type), - Expected::NoExpectation(Type::Boolean(Bool::shared())), - Category::Uniqueness, - region, - ), - ]), - ) - } - Some(Simple(Unique)) | Some(Simple(Seen)) => { - // no additional constraints, keep uniqueness unbound - Lookup(symbol_for_lookup, expected, region) - } - Some(Usage::RecordAccess(_, _)) - | Some(Usage::RecordUpdate(_, _)) - | Some(Usage::ApplyAccess(_, _)) - | Some(Usage::ApplyUpdate(_, _)) => { - applied_usage_constraint.insert(symbol_for_lookup); - - let mut variables = Vec::new(); - let (record_bool, inner_type) = - constrain_by_usage(&usage.expect("wut"), var_store, &mut variables); - - let record_type = attr_type(record_bool, inner_type); - - // NOTE breaking the expectation up like this REALLY matters! - let new_expected = Expected::NoExpectation(record_type.clone()); - exists( - variables, - And(vec![ - Lookup(symbol_for_lookup, new_expected, region), - Eq(record_type, expected, Category::Uniqueness, region), - ]), - ) - } - } -} - -fn constrain_by_usage( - usage: &Usage, - var_store: &mut VarStore, - introduced: &mut Vec, -) -> (Bool, Type) { - use Usage::*; - - match usage { - Simple(Mark::Shared) => { - let var = var_store.fresh(); - - introduced.push(var); - - (Bool::Shared, Type::Variable(var)) - } - Simple(Mark::Seen) | Simple(Mark::Unique) => { - let var = var_store.fresh(); - let uvar = var_store.fresh(); - - introduced.push(var); - introduced.push(uvar); - - (Bool::container(uvar, vec![]), Type::Variable(var)) - } - Usage::RecordAccess(mark, fields) => { - let (record_bool, ext_type) = constrain_by_usage(&Simple(*mark), var_store, introduced); - - constrain_by_usage_record(fields, record_bool, ext_type, introduced, var_store) - } - Usage::RecordUpdate(_, fields) => { - let record_uvar = var_store.fresh(); - introduced.push(record_uvar); - - let record_bool = Bool::variable(record_uvar); - - let ext_var = var_store.fresh(); - let ext_type = Type::Variable(ext_var); - introduced.push(ext_var); - - constrain_by_usage_record(fields, record_bool, ext_type, introduced, var_store) - } - Usage::ApplyAccess(mark, fields) => { - let (list_bool, _ext_type) = constrain_by_usage(&Simple(*mark), var_store, introduced); - - // TODO reconsier this for multi-value applies - let field_usage = fields.get(0).expect("no LIST_ELEM key"); - - let (elem_bool, elem_type) = constrain_by_usage(field_usage, var_store, introduced); - - match list_bool { - Bool::Shared => ( - Bool::Shared, - Type::Apply(Symbol::LIST_LIST, vec![attr_type(Bool::Shared, elem_type)]), - ), - Bool::Container(list_uvar, list_mvars) => { - debug_assert!(list_mvars.is_empty()); - - match elem_bool { - Bool::Shared => ( - Bool::variable(list_uvar), - Type::Apply( - Symbol::LIST_LIST, - vec![attr_type(Bool::Shared, elem_type)], - ), - ), - Bool::Container(cvar, mvars) => { - debug_assert!(mvars.is_empty()); - ( - Bool::container(list_uvar, vec![cvar]), - Type::Apply( - Symbol::LIST_LIST, - vec![attr_type(Bool::container(cvar, mvars), elem_type)], - ), - ) - } - } - } - } - } - - Usage::ApplyUpdate(_, fields) => { - let list_uvar = var_store.fresh(); - introduced.push(list_uvar); - - // TODO reconsier this for multi-value applies - let field_usage = fields.get(0).expect("no LIST_ELEM key"); - - let (elem_bool, elem_type) = constrain_by_usage(field_usage, var_store, introduced); - - match elem_bool { - Bool::Shared => ( - Bool::variable(list_uvar), - Type::Apply(Symbol::LIST_LIST, vec![attr_type(Bool::Shared, elem_type)]), - ), - Bool::Container(cvar, mvars) => { - debug_assert!(mvars.is_empty()); - ( - Bool::container(list_uvar, vec![cvar]), - Type::Apply( - Symbol::LIST_LIST, - vec![attr_type(Bool::container(cvar, mvars), elem_type)], - ), - ) - } - } - } - } -} - -fn constrain_by_usage_record( - fields: &FieldAccess, - record_bool: Bool, - ext_type: Type, - introduced: &mut Vec, - var_store: &mut VarStore, -) -> (Bool, Type) { - let mut field_types = SendMap::default(); - - match record_bool { - _ if fields.is_empty() => (record_bool, Type::Record(field_types, Box::new(ext_type))), - Bool::Shared => { - for (lowercase, nested_usage) in fields.clone().into_iter() { - let (_, nested_type) = constrain_by_usage(&nested_usage, var_store, introduced); - - let field_type = attr_type(Bool::Shared, nested_type); - - // In expressions, it's only possible to do record access on - // Required fields. - field_types.insert(lowercase.clone(), RecordField::Required(field_type)); - } - - ( - Bool::Shared, - Type::Record( - field_types, - // TODO can we avoid doing Box::new on every single one of these? - // For example, could we have a single lazy_static global Box they - // could all share? - Box::new(ext_type), - ), - ) - } - Bool::Container(record_uniq_var, mvars) => { - debug_assert!(mvars.is_empty()); - - let mut uniq_vars = Vec::with_capacity(fields.len()); - - for (lowercase, nested_usage) in fields.clone().into_iter() { - let (nested_bool, nested_type) = - constrain_by_usage(&nested_usage, var_store, introduced); - - let field_type = match nested_bool { - Bool::Container(uvar, atoms) => { - for atom in &atoms { - uniq_vars.push(*atom); - } - uniq_vars.push(uvar); - attr_type(Bool::Container(uvar, atoms), nested_type) - } - Bool::Shared => attr_type(Bool::Shared, nested_type), - }; - - // In expressions, it's only possible to do record access on - // Required fields. - field_types.insert(lowercase.clone(), RecordField::Required(field_type)); - } - - ( - Bool::container(record_uniq_var, uniq_vars), - Type::Record( - field_types, - // TODO can we avoid doing Box::new on every single one of these? - // For example, could we have a single lazy_static global Box they - // could all share? - Box::new(ext_type), - ), - ) - } - } -} - -// TODO trim down these arguments -#[allow(clippy::too_many_arguments)] -// NOTE enabling the inline pragma can blow the stack in debug mode -// #[inline(always)] -fn constrain_when_branch( - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - env: &Env, - region: Region, - when_branch: &WhenBranch, - pattern_expected: PExpected, - expr_expected: Expected, -) -> Constraint { - let ret_constraint = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - region, - &when_branch.value.value, - expr_expected, - ); - - let mut state = PatternState { - headers: SendMap::default(), - vars: Vec::with_capacity(1), - constraints: Vec::with_capacity(1), - }; - - for loc_pattern in &when_branch.patterns { - // mutates the state, so return value is not used - constrain_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - &mut state, - &loc_pattern, - pattern_expected.clone(), - ); - } - - if let Some(loc_guard) = &when_branch.guard { - let guard_uniq_var = var_store.fresh(); - - let bool_type = attr_type( - Bool::variable(guard_uniq_var), - Type::Variable(Variable::BOOL), - ); - - let guard_constraint = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_guard.region, - &loc_guard.value, - Expected::ForReason(Reason::WhenGuard, bool_type, loc_guard.region), - ); - - Constraint::Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: state.vars, - def_types: state.headers, - defs_constraint: Constraint::And(state.constraints), - ret_constraint: Constraint::Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: vec![guard_uniq_var], - def_types: SendMap::default(), - defs_constraint: guard_constraint, - ret_constraint, - })), - })) - } else { - Constraint::Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: state.vars, - def_types: state.headers, - defs_constraint: Constraint::And(state.constraints), - ret_constraint, - })) - } -} - -fn constrain_def_pattern( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - loc_pattern: &Located, - expr_type: Type, -) -> PatternState { - // Exclude the current ident from shadowable_idents; you can't shadow yourself! - // (However, still include it in scope, because you *can* recursively refer to yourself.) - let pattern_expected = PExpected::NoExpectation(expr_type); - - let mut state = PatternState { - headers: SendMap::default(), - vars: Vec::with_capacity(1), - constraints: Vec::with_capacity(1), - }; - - constrain_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - &mut state, - loc_pattern, - pattern_expected, - ); - - state -} - -/// Turn e.g. `Int` into `Attr.Attr * Int` -fn annotation_to_attr_type( - var_store: &mut VarStore, - ann: &Type, - rigids: &mut ImSet, - change_var_kind: bool, -) -> (Vec, Type) { - use roc_types::types::Type::*; - - match ann { - Variable(var) => { - if change_var_kind { - let uvar = var_store.fresh(); - rigids.insert(uvar); - ( - vec![], - attr_type(Bool::variable(uvar), Type::Variable(*var)), - ) - } else { - (vec![], Type::Variable(*var)) - } - } - - Boolean(_) | Erroneous(_) => (vec![], ann.clone()), - EmptyRec | EmptyTagUnion => { - let uniq_var = var_store.fresh(); - ( - vec![uniq_var], - attr_type(Bool::variable(uniq_var), ann.clone()), - ) - } - - Function(arguments, closure, result) => { - let uniq_var = var_store.fresh(); - let (mut arg_vars, args_lifted) = - annotation_to_attr_type_many(var_store, arguments, rigids, change_var_kind); - - // NOTE: we don't lift the closure var! - // their uniqueness will never matter (it's a phantom parameter) - // and not lifting makes code reuse possible - - let (result_vars, result_lifted) = - annotation_to_attr_type(var_store, result, rigids, change_var_kind); - - arg_vars.extend(result_vars); - arg_vars.push(uniq_var); - - match **closure { - Type::Variable(c) => arg_vars.push(c), - _ => unreachable!("closure must contain a type variable"), - } - - ( - arg_vars, - attr_type( - Bool::variable(uniq_var), - Type::Function(args_lifted, closure.clone(), Box::new(result_lifted)), - ), - ) - } - - Apply(Symbol::ATTR_ATTR, args) => { - let uniq_type = args[0].clone(); - - // A rigid behind an attr has already been lifted, don't do it again! - let (result_vars, result_lifted) = match args[1] { - Type::Variable(_) => match uniq_type { - Type::Boolean(Bool::Container(urigid, _)) => (vec![urigid], args[1].clone()), - _ => (vec![], args[1].clone()), - }, - _ => annotation_to_attr_type(var_store, &args[1], rigids, change_var_kind), - }; - - let result = Apply(Symbol::ATTR_ATTR, vec![uniq_type, result_lifted]); - - (result_vars, result) - } - - Apply(symbol, args) => { - let uniq_var = var_store.fresh(); - - let (mut arg_vars, args_lifted) = - annotation_to_attr_type_many(var_store, args, rigids, change_var_kind); - let result = attr_type(Bool::variable(uniq_var), Type::Apply(*symbol, args_lifted)); - - arg_vars.push(uniq_var); - - (arg_vars, result) - } - - Record(fields, ext_type) => { - let uniq_var = var_store.fresh(); - let mut vars = Vec::with_capacity(fields.len()); - let mut lifted_fields = SendMap::default(); - - for (label, field) in fields.clone() { - use RecordField::*; - - let lifted_field = match field { - Demanded(tipe) => { - let (new_vars, lifted_field) = - annotation_to_attr_type(var_store, &tipe, rigids, change_var_kind); - - vars.extend(new_vars); - - Demanded(lifted_field) - } - Required(tipe) => { - let (new_vars, lifted_field) = - annotation_to_attr_type(var_store, &tipe, rigids, change_var_kind); - - vars.extend(new_vars); - - Required(lifted_field) - } - Optional(tipe) => { - let (new_vars, lifted_field) = - annotation_to_attr_type(var_store, &tipe, rigids, change_var_kind); - - vars.extend(new_vars); - - Optional(lifted_field) - } - }; - - lifted_fields.insert(label, lifted_field); - } - - vars.push(uniq_var); - - ( - vars, - attr_type( - Bool::variable(uniq_var), - Type::Record(lifted_fields, ext_type.clone()), - ), - ) - } - - TagUnion(tags, ext_type) => { - let uniq_var = var_store.fresh(); - let mut vars = Vec::with_capacity(tags.len()); - let mut lifted_tags = Vec::with_capacity(tags.len()); - - for (tag, fields) in tags { - let (new_vars, lifted_fields) = - annotation_to_attr_type_many(var_store, fields, rigids, change_var_kind); - vars.extend(new_vars); - lifted_tags.push((tag.clone(), lifted_fields)); - } - - vars.push(uniq_var); - - ( - vars, - attr_type( - Bool::variable(uniq_var), - Type::TagUnion(lifted_tags, ext_type.clone()), - ), - ) - } - RecursiveTagUnion(rec_var, tags, ext_type) => { - // In the case of - // - // [ Cons a (List a), Nil ] as List a - // - // We need to lift it to - // - // Attr u ([ Cons a (Attr u (List a)), Nil ] as List a) - // - // So the `u` of the whole recursive tag union is the same as the one used in the recursion - - let uniq_var = var_store.fresh(); - let mut vars = Vec::with_capacity(tags.len()); - let mut lifted_tags = Vec::with_capacity(tags.len()); - - let mut substitutions = ImMap::default(); - substitutions.insert( - *rec_var, - attr_type(Bool::variable(uniq_var), Type::Variable(*rec_var)), - ); - - for (tag, fields) in tags { - let (new_vars, mut lifted_fields) = - annotation_to_attr_type_many(var_store, fields, rigids, change_var_kind); - vars.extend(new_vars); - - for f in lifted_fields.iter_mut() { - f.substitute(&substitutions); - } - - lifted_tags.push((tag.clone(), lifted_fields)); - } - - vars.push(uniq_var); - - let result = attr_type( - Bool::variable(uniq_var), - Type::RecursiveTagUnion(*rec_var, lifted_tags, ext_type.clone()), - ); - - (vars, result) - } - - Alias(symbol, fields, actual) => { - let (mut actual_vars, lifted_actual) = - annotation_to_attr_type(var_store, actual, rigids, change_var_kind); - - if let Type::Apply(attr_symbol, args) = lifted_actual { - debug_assert!(attr_symbol == Symbol::ATTR_ATTR); - - let uniq_type = args[0].clone(); - let actual_type = args[1].clone(); - - let mut new_fields = Vec::with_capacity(fields.len()); - for (name, tipe) in fields { - let (lifted_vars, lifted) = - annotation_to_attr_type(var_store, tipe, rigids, change_var_kind); - - actual_vars.extend(lifted_vars); - - new_fields.push((name.clone(), lifted)); - } - - let alias = Type::Alias(*symbol, new_fields, Box::new(actual_type)); - - ( - actual_vars, - crate::builtins::builtin_type(Symbol::ATTR_ATTR, vec![uniq_type, alias]), - ) - } else { - panic!("lifted type is not Attr") - } - } - HostExposedAlias { - name: symbol, - arguments: fields, - actual_var, - actual, - } => { - let (mut actual_vars, lifted_actual) = - annotation_to_attr_type(var_store, actual, rigids, change_var_kind); - - if let Type::Apply(attr_symbol, args) = lifted_actual { - debug_assert!(attr_symbol == Symbol::ATTR_ATTR); - - let uniq_type = args[0].clone(); - let actual_type = args[1].clone(); - - let mut new_fields = Vec::with_capacity(fields.len()); - for (name, tipe) in fields { - let (lifted_vars, lifted) = - annotation_to_attr_type(var_store, tipe, rigids, change_var_kind); - - actual_vars.extend(lifted_vars); - - new_fields.push((name.clone(), lifted)); - } - - let alias = Type::HostExposedAlias { - name: *symbol, - arguments: new_fields, - actual_var: *actual_var, - actual: Box::new(actual_type), - }; - - ( - actual_vars, - crate::builtins::builtin_type(Symbol::ATTR_ATTR, vec![uniq_type, alias]), - ) - } else { - panic!("lifted type is not Attr") - } - } - } -} - -fn annotation_to_attr_type_many( - var_store: &mut VarStore, - anns: &[Type], - rigids: &mut ImSet, - change_var_kind: bool, -) -> (Vec, Vec) { - anns.iter() - .fold((Vec::new(), Vec::new()), |(mut vars, mut types), value| { - let (new_vars, tipe) = - annotation_to_attr_type(var_store, value, rigids, change_var_kind); - vars.extend(new_vars); - types.push(tipe); - - (vars, types) - }) -} - -fn constrain_def( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - def: &Def, - body_con: Constraint, -) -> Constraint { - let expr_var = def.expr_var; - let expr_type = Type::Variable(expr_var); - - let mut pattern_state = constrain_def_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - &def.loc_pattern, - expr_type.clone(), - ); - - pattern_state.vars.push(expr_var); - - let mut new_rigids = Vec::new(); - - let expr_con = match &def.annotation { - Some(annotation) => { - let arity = annotation.signature.arity(); - let mut ftv = env.rigids.clone(); - - let signature = instantiate_rigids( - var_store, - &annotation.signature, - &annotation.introduced_variables, - &mut new_rigids, - &mut ftv, - &def.loc_pattern, - &mut pattern_state.headers, - ); - - let annotation_expected = Expected::FromAnnotation( - def.loc_pattern.clone(), - arity, - AnnotationSource::TypedBody { - region: annotation.region, - }, - signature, - ); - - pattern_state.constraints.push(Eq( - expr_type, - annotation_expected.clone(), - Category::Storage(std::file!(), std::line!()), - Region::zero(), - )); - - constrain_expr( - &Env { - rigids: ftv, - home: env.home, - }, - var_store, - var_usage, - applied_usage_constraint, - def.loc_expr.region, - &def.loc_expr.value, - annotation_expected, - ) - } - None => constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - def.loc_expr.region, - &def.loc_expr.value, - Expected::NoExpectation(expr_type), - ), - }; - - Let(Box::new(LetConstraint { - rigid_vars: new_rigids, - flex_vars: pattern_state.vars, - def_types: pattern_state.headers, - defs_constraint: Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), // always empty - flex_vars: Vec::new(), // empty, because our functions have no arguments - def_types: SendMap::default(), // empty, because our functions have no arguments! - defs_constraint: And(pattern_state.constraints), - ret_constraint: expr_con, - })), - ret_constraint: body_con, - })) -} - -fn constrain_closure_size( - name: Symbol, - region: Region, - captured_symbols: &[(Symbol, Variable)], - closure_var: Variable, - closure_ext_var: Variable, - variables: &mut Vec, -) -> Constraint { - debug_assert!(variables.iter().any(|s| *s == closure_var)); - debug_assert!(variables.iter().any(|s| *s == closure_ext_var)); - - let mut tag_arguments = Vec::with_capacity(captured_symbols.len()); - let mut captured_symbols_constraints = Vec::with_capacity(captured_symbols.len()); - - for (symbol, var) in captured_symbols { - // make sure the variable is registered - variables.push(*var); - - // this symbol is captured, so it must be part of the closure type - tag_arguments.push(Type::Variable(*var)); - - // make the variable equal to the looked-up type of symbol - captured_symbols_constraints.push(Constraint::Lookup( - *symbol, - Expected::NoExpectation(Type::Variable(*var)), - Region::zero(), - )); - } - - let tag_name = roc_module::ident::TagName::Closure(name); - let closure_type = Type::TagUnion( - vec![(tag_name, tag_arguments)], - Box::new(Type::Variable(closure_ext_var)), - ); - - let finalizer = Eq( - Type::Variable(closure_var), - Expected::NoExpectation(closure_type), - Category::ClosureSize, - region, - ); - - captured_symbols_constraints.push(finalizer); - - Constraint::And(captured_symbols_constraints) -} - -fn instantiate_rigids( - var_store: &mut VarStore, - annotation: &Type, - introduced_vars: &IntroducedVariables, - new_rigids: &mut Vec, - ftv: &mut ImMap, - loc_pattern: &Located, - headers: &mut SendMap>, -) -> Type { - let unlifed_annotation = annotation.clone(); - let mut annotation = annotation.clone(); - - let mut rigid_substitution: ImMap = ImMap::default(); - - for (name, var) in introduced_vars.var_by_name.iter() { - if let Some((existing_rigid, existing_uvar)) = ftv.get(&name) { - rigid_substitution.insert( - *var, - attr_type( - Bool::variable(*existing_uvar), - Type::Variable(*existing_rigid), - ), - ); - } else { - // possible use this rigid in nested def's - let uvar = var_store.fresh(); - ftv.insert(name.clone(), (*var, uvar)); - - new_rigids.push(*var); - } - } - - // Instantiate rigid variables - if !rigid_substitution.is_empty() { - annotation.substitute(&rigid_substitution); - } - - let mut new_uniqueness_rigids = ImSet::default(); - let (mut uniq_vars, annotation) = - annotation_to_attr_type(var_store, &annotation, &mut new_uniqueness_rigids, true); - - if let Pattern::Identifier(symbol) = loc_pattern.value { - headers.insert(symbol, Located::at(loc_pattern.region, annotation.clone())); - } else if let Some(new_headers) = crate::pattern::headers_from_annotation( - &loc_pattern.value, - &Located::at(loc_pattern.region, unlifed_annotation), - ) { - for (k, v) in new_headers { - let (new_uniq_vars, attr_annotation) = - annotation_to_attr_type(var_store, &v.value, &mut new_uniqueness_rigids, true); - - uniq_vars.extend(new_uniq_vars); - - headers.insert(k, Located::at(loc_pattern.region, attr_annotation)); - } - } - - new_rigids.extend(uniq_vars); - new_rigids.extend(introduced_vars.wildcards.iter().cloned()); - new_rigids.extend(new_uniqueness_rigids); - - annotation -} - -fn constrain_recursive_defs( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - defs: &[Def], - body_con: Constraint, -) -> Constraint { - rec_defs_help( - env, - var_store, - var_usage, - applied_usage_constraint, - defs, - body_con, - Info::with_capacity(defs.len()), - Info::with_capacity(defs.len()), - ) -} - -#[allow(clippy::too_many_arguments)] -pub fn rec_defs_help( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - defs: &[Def], - body_con: Constraint, - mut rigid_info: Info, - mut flex_info: Info, -) -> Constraint { - for def in defs { - let expr_var = def.expr_var; - let expr_type = Type::Variable(expr_var); - - let pattern_expected = PExpected::NoExpectation(expr_type.clone()); - - let mut pattern_state = PatternState { - headers: SendMap::default(), - vars: flex_info.vars.clone(), - constraints: Vec::with_capacity(1), - }; - - pattern_state.vars.push(expr_var); - - constrain_pattern( - env, - var_store, - var_usage, - applied_usage_constraint, - &mut pattern_state, - &def.loc_pattern, - pattern_expected, - ); - - // TODO see where aliases should go - let mut new_rigids = Vec::new(); - match &def.annotation { - None => { - let expr_con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - def.loc_expr.region, - &def.loc_expr.value, - Expected::NoExpectation(expr_type), - ); - - // TODO investigate if this let can be safely removed - let def_con = Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: Vec::new(), // empty because Roc function defs have no args - def_types: SendMap::default(), // empty because Roc function defs have no args - defs_constraint: True, // I think this is correct, once again because there are no args - ret_constraint: expr_con, - })); - - flex_info.vars = pattern_state.vars; - flex_info.constraints.push(def_con); - flex_info.def_types.extend(pattern_state.headers); - } - - Some(annotation) => { - let arity = annotation.signature.arity(); - let mut ftv = env.rigids.clone(); - let signature = instantiate_rigids( - var_store, - &annotation.signature, - &annotation.introduced_variables, - &mut new_rigids, - &mut ftv, - &def.loc_pattern, - &mut pattern_state.headers, - ); - let annotation_expected = Expected::FromAnnotation( - def.loc_pattern.clone(), - arity, - AnnotationSource::TypedBody { - region: annotation.region, - }, - signature.clone(), - ); - let expr_con = constrain_expr( - &Env { - rigids: ftv, - home: env.home, - }, - var_store, - var_usage, - applied_usage_constraint, - def.loc_expr.region, - &def.loc_expr.value, - annotation_expected.clone(), - ); - - // ensure expected type unifies with annotated type - let storage_con = Eq( - expr_type, - annotation_expected, - Category::Storage(std::file!(), std::line!()), - def.loc_expr.region, - ); - - // TODO investigate if this let can be safely removed - let def_con = Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: Vec::new(), // empty because Roc function defs have no args - def_types: SendMap::default(), // empty because Roc function defs have no args - defs_constraint: storage_con, - ret_constraint: expr_con, - })); - - rigid_info.vars.extend(&new_rigids); - rigid_info.constraints.push(Let(Box::new(LetConstraint { - rigid_vars: new_rigids, - flex_vars: pattern_state.vars, - def_types: SendMap::default(), // no headers introduced (at this level) - defs_constraint: def_con, - ret_constraint: True, - }))); - rigid_info.def_types.extend(pattern_state.headers); - } - } - } - - Let(Box::new(LetConstraint { - rigid_vars: rigid_info.vars, - flex_vars: Vec::new(), - def_types: rigid_info.def_types, - defs_constraint: True, - ret_constraint: Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: flex_info.vars, - def_types: flex_info.def_types.clone(), - defs_constraint: Let(Box::new(LetConstraint { - rigid_vars: Vec::new(), - flex_vars: Vec::new(), - def_types: flex_info.def_types, - defs_constraint: True, - ret_constraint: And(flex_info.constraints), - })), - ret_constraint: And(vec![And(rigid_info.constraints), body_con]), - })), - })) -} - -#[allow(clippy::too_many_arguments)] -#[inline(always)] -fn constrain_field_update( - env: &Env, - var_store: &mut VarStore, - var_usage: &VarUsage, - applied_usage_constraint: &mut ImSet, - var: Variable, - region: Region, - field: Lowercase, - loc_expr: &Located, -) -> (Variable, Type, Constraint) { - let field_type = Type::Variable(var); - let reason = Reason::RecordUpdateValue(field); - let expected = Expected::ForReason(reason, field_type.clone(), region); - let con = constrain_expr( - env, - var_store, - var_usage, - applied_usage_constraint, - loc_expr.region, - &loc_expr.value, - expected, - ); - - (var, field_type, con) -} diff --git a/compiler/fmt/tests/test_fmt.rs b/compiler/fmt/tests/test_fmt.rs index 3b2d6e20fc..8e7cb1fbea 100644 --- a/compiler/fmt/tests/test_fmt.rs +++ b/compiler/fmt/tests/test_fmt.rs @@ -17,9 +17,12 @@ mod test_fmt { use roc_parse::ast::{Attempting, Expr}; use roc_parse::blankspace::space0_before; use roc_parse::module::{self, module_defs}; - use roc_parse::parser::{Bag, Parser, State}; + use roc_parse::parser::{Bag, Parser, State, SyntaxError}; - fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Bag<'a>> { + fn parse_with<'a>( + arena: &'a Bump, + input: &'a str, + ) -> Result, Bag<'a, SyntaxError<'a>>> { let state = State::new_in(arena, input.trim().as_bytes(), Attempting::Module); let parser = space0_before(loc!(roc_parse::expr::expr(0)), 0); let answer = parser.parse(&arena, state); diff --git a/compiler/gen/Cargo.toml b/compiler/gen/Cargo.toml index 41420c9056..6480257d05 100644 --- a/compiler/gen/Cargo.toml +++ b/compiler/gen/Cargo.toml @@ -13,7 +13,6 @@ roc_problem = { path = "../problem" } roc_types = { path = "../types" } roc_builtins = { path = "../builtins" } roc_constrain = { path = "../constrain" } -roc_uniq = { path = "../uniq" } roc_unify = { path = "../unify" } roc_solve = { path = "../solve" } roc_mono = { path = "../mono" } diff --git a/compiler/gen_dev/Cargo.toml b/compiler/gen_dev/Cargo.toml index f7c41ebbe0..0717943159 100644 --- a/compiler/gen_dev/Cargo.toml +++ b/compiler/gen_dev/Cargo.toml @@ -14,7 +14,6 @@ roc_problem = { path = "../problem" } roc_types = { path = "../types" } roc_builtins = { path = "../builtins" } roc_constrain = { path = "../constrain" } -roc_uniq = { path = "../uniq" } roc_unify = { path = "../unify" } roc_solve = { path = "../solve" } roc_mono = { path = "../mono" } diff --git a/compiler/load/tests/helpers/mod.rs b/compiler/load/tests/helpers/mod.rs index 9d0c580249..ec8feb6b8c 100644 --- a/compiler/load/tests/helpers/mod.rs +++ b/compiler/load/tests/helpers/mod.rs @@ -15,7 +15,7 @@ use roc_module::ident::Ident; use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol}; use roc_parse::ast::{self, Attempting}; use roc_parse::blankspace::space0_before; -use roc_parse::parser::{loc, Bag, Parser, State}; +use roc_parse::parser::{loc, Bag, Parser, State, SyntaxError}; use roc_problem::can::Problem; use roc_region::all::{Located, Region}; use roc_solve::solve; @@ -62,7 +62,10 @@ where } #[allow(dead_code)] -pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Bag<'a>> { +pub fn parse_with<'a>( + arena: &'a Bump, + input: &'a str, +) -> Result, Bag<'a, SyntaxError<'a>>> { parse_loc_with(arena, input).map(|loc_expr| loc_expr.value) } @@ -70,7 +73,7 @@ pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, pub fn parse_loc_with<'a>( arena: &'a Bump, input: &'a str, -) -> Result>, Bag<'a>> { +) -> Result>, Bag<'a, SyntaxError<'a>>> { let state = State::new_in(arena, input.trim().as_bytes(), Attempting::Module); let parser = space0_before(loc(roc_parse::expr::expr(0)), 0); let answer = parser.parse(&arena, state); @@ -85,85 +88,6 @@ pub fn can_expr(expr_str: &str) -> CanExprOut { can_expr_with(&Bump::new(), test_home(), expr_str) } -#[allow(dead_code)] -pub fn uniq_expr( - expr_str: &str, -) -> ( - Located, - Output, - Vec, - Subs, - Variable, - Constraint, - ModuleId, - Interns, -) { - let declared_idents: &ImMap = &ImMap::default(); - - uniq_expr_with(&Bump::new(), expr_str, declared_idents) -} - -#[allow(dead_code)] -pub fn uniq_expr_with( - arena: &Bump, - expr_str: &str, - declared_idents: &ImMap, -) -> ( - Located, - Output, - Vec, - Subs, - Variable, - Constraint, - ModuleId, - Interns, -) { - let home = test_home(); - let CanExprOut { - loc_expr, - output, - problems, - var_store: mut old_var_store, - var, - interns, - .. - } = can_expr_with(arena, home, expr_str); - - // double check - let mut var_store = VarStore::new(old_var_store.fresh()); - - let expected2 = Expected::NoExpectation(Type::Variable(var)); - let constraint = roc_constrain::uniq::constrain_declaration( - home, - &mut var_store, - Region::zero(), - &loc_expr, - declared_idents, - expected2, - ); - - let stdlib = uniq_stdlib(); - - let types = stdlib.types; - let imports: Vec<_> = types - .into_iter() - .map(|(symbol, (solved_type, region))| Import { - loc_symbol: Located::at(region, symbol), - solved_type, - }) - .collect(); - - // load builtin values - let (_introduced_rigids, constraint) = - constrain_imported_values(imports, constraint, &mut var_store); - - let subs2 = Subs::new(var_store.into()); - - ( - loc_expr, output, problems, subs2, var, constraint, home, interns, - ) -} - pub struct CanExprOut { pub loc_expr: Located, pub output: Output, diff --git a/compiler/mono/tests/helpers/mod.rs b/compiler/mono/tests/helpers/mod.rs index be24114e88..ede19c36f2 100644 --- a/compiler/mono/tests/helpers/mod.rs +++ b/compiler/mono/tests/helpers/mod.rs @@ -15,7 +15,7 @@ use roc_module::ident::Ident; use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol}; use roc_parse::ast::{self, Attempting}; use roc_parse::blankspace::space0_before; -use roc_parse::parser::{loc, Bag, Parser, State}; +use roc_parse::parser::{loc, Bag, Parser, State, SyntaxError}; use roc_problem::can::Problem; use roc_region::all::{Located, Region}; use roc_solve::solve; @@ -47,7 +47,10 @@ pub fn infer_expr( } #[allow(dead_code)] -pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Bag<'a>> { +pub fn parse_with<'a>( + arena: &'a Bump, + input: &'a str, +) -> Result, Bag<'a, SyntaxError<'a>>> { parse_loc_with(arena, input).map(|loc_expr| loc_expr.value) } @@ -55,7 +58,7 @@ pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, pub fn parse_loc_with<'a>( arena: &'a Bump, input: &'a str, -) -> Result>, Bag<'a>> { +) -> Result>, Bag<'a, SyntaxError<'a>>> { let state = State::new_in(arena, input.as_bytes(), Attempting::Module); let parser = space0_before(loc(roc_parse::expr::expr(0)), 0); let answer = parser.parse(&arena, state); @@ -70,87 +73,6 @@ pub fn can_expr(expr_str: &str) -> CanExprOut { can_expr_with(&Bump::new(), test_home(), expr_str) } -#[allow(dead_code)] -pub fn uniq_expr( - expr_str: &str, -) -> ( - Located, - Output, - Vec, - Subs, - Variable, - Constraint, - ModuleId, - Interns, -) { - let declared_idents: &ImMap = &ImMap::default(); - - uniq_expr_with(&Bump::new(), expr_str, declared_idents) -} - -#[allow(dead_code)] -pub fn uniq_expr_with( - arena: &Bump, - expr_str: &str, - declared_idents: &ImMap, -) -> ( - Located, - Output, - Vec, - Subs, - Variable, - Constraint, - ModuleId, - Interns, -) { - let home = test_home(); - let CanExprOut { - loc_expr, - output, - problems, - var_store: mut old_var_store, - var, - interns, - .. - } = can_expr_with(arena, home, expr_str); - - // double check - let mut var_store = VarStore::new(old_var_store.fresh()); - - let expected2 = Expected::NoExpectation(Type::Variable(var)); - let constraint = roc_constrain::uniq::constrain_declaration( - home, - &mut var_store, - Region::zero(), - &loc_expr, - declared_idents, - expected2, - ); - - let stdlib = uniq_stdlib(); - - let types = stdlib.types; - let imports: Vec<_> = types - .into_iter() - .map(|(symbol, (solved_type, region))| Import { - loc_symbol: Located::at(region, symbol), - solved_type, - }) - .collect(); - - // load builtin values - - // TODO what to do with those rigids? - let (_introduced_rigids, constraint) = - constrain_imported_values(imports, constraint, &mut var_store); - - let subs2 = Subs::new(var_store.into()); - - ( - loc_expr, output, problems, subs2, var, constraint, home, interns, - ) -} - pub struct CanExprOut { pub loc_expr: Located, pub output: Output, diff --git a/compiler/parse/src/parser.rs b/compiler/parse/src/parser.rs index 3ca41e08f2..1b6d61fafc 100644 --- a/compiler/parse/src/parser.rs +++ b/compiler/parse/src/parser.rs @@ -258,7 +258,7 @@ impl Progress { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum SyntaxError<'a> { Unexpected(Region), OutdentedTooFar, @@ -278,7 +278,7 @@ pub enum SyntaxError<'a> { type Row = u32; type Col = u16; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum Type<'a> { TRecord(TRecord<'a>, Row, Col), /// @@ -288,7 +288,7 @@ pub enum Type<'a> { TIndentStart(Row, Col), } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum TRecord<'a> { Open(Row, Col), End(Row, Col), diff --git a/compiler/reporting/tests/helpers/mod.rs b/compiler/reporting/tests/helpers/mod.rs index 60a0c05091..fd7400eca3 100644 --- a/compiler/reporting/tests/helpers/mod.rs +++ b/compiler/reporting/tests/helpers/mod.rs @@ -13,7 +13,7 @@ use roc_constrain::module::{constrain_imported_values, Import}; use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds}; use roc_parse::ast::{self, Attempting}; use roc_parse::blankspace::space0_before; -use roc_parse::parser::{loc, Bag, Parser, State}; +use roc_parse::parser::{loc, Bag, Parser, State, SyntaxError}; use roc_problem::can::Problem; use roc_region::all::Located; use roc_solve::solve; @@ -101,7 +101,10 @@ pub struct CanExprOut { } #[allow(dead_code)] -pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Bag<'a>> { +pub fn parse_with<'a>( + arena: &'a Bump, + input: &'a str, +) -> Result, Bag<'a, SyntaxError<'a>>> { parse_loc_with(arena, input).map(|loc_expr| loc_expr.value) } @@ -109,7 +112,7 @@ pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, pub fn parse_loc_with<'a>( arena: &'a Bump, input: &'a str, -) -> Result>, Bag<'a>> { +) -> Result>, Bag<'a, SyntaxError<'a>>> { let state = State::new_in(arena, input.trim().as_bytes(), Attempting::Module); let parser = space0_before(loc(roc_parse::expr::expr(0)), 0); let answer = parser.parse(&arena, state); @@ -121,7 +124,7 @@ pub fn parse_loc_with<'a>( #[derive(Debug)] pub struct ParseErrOut<'a> { - pub fail: Bag<'a>, + pub fail: Bag<'a, SyntaxError<'a>>, pub home: ModuleId, pub interns: Interns, } diff --git a/compiler/solve/tests/helpers/mod.rs b/compiler/solve/tests/helpers/mod.rs index 0ab9310383..5d8e05519e 100644 --- a/compiler/solve/tests/helpers/mod.rs +++ b/compiler/solve/tests/helpers/mod.rs @@ -15,7 +15,7 @@ use roc_module::ident::Ident; use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds, Symbol}; use roc_parse::ast::{self, Attempting}; use roc_parse::blankspace::space0_before; -use roc_parse::parser::{loc, Bag, Parser, State}; +use roc_parse::parser::{loc, Bag, Parser, State, SyntaxError}; use roc_problem::can::Problem; use roc_region::all::{Located, Region}; use roc_solve::solve; @@ -87,7 +87,10 @@ where } #[allow(dead_code)] -pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, Bag<'a>> { +pub fn parse_with<'a>( + arena: &'a Bump, + input: &'a str, +) -> Result, Bag<'a, SyntaxError<'a>>> { parse_loc_with(arena, input).map(|loc_expr| loc_expr.value) } @@ -95,7 +98,7 @@ pub fn parse_with<'a>(arena: &'a Bump, input: &'a str) -> Result, pub fn parse_loc_with<'a>( arena: &'a Bump, input: &'a str, -) -> Result>, Bag<'a>> { +) -> Result>, Bag<'a, SyntaxError<'a>>> { let state = State::new_in(arena, input.trim().as_bytes(), Attempting::Module); let parser = space0_before(loc(roc_parse::expr::expr(0)), 0); let answer = parser.parse(&arena, state); @@ -110,87 +113,6 @@ pub fn can_expr(expr_str: &str) -> CanExprOut { can_expr_with(&Bump::new(), test_home(), expr_str) } -#[allow(dead_code)] -pub fn uniq_expr( - expr_str: &str, -) -> ( - Located, - Output, - Vec, - Subs, - Variable, - Constraint, - ModuleId, - Interns, -) { - let declared_idents: &ImMap = &ImMap::default(); - - uniq_expr_with(&Bump::new(), expr_str, declared_idents) -} - -#[allow(dead_code)] -pub fn uniq_expr_with( - arena: &Bump, - expr_str: &str, - declared_idents: &ImMap, -) -> ( - Located, - Output, - Vec, - Subs, - Variable, - Constraint, - ModuleId, - Interns, -) { - let home = test_home(); - let CanExprOut { - loc_expr, - output, - problems, - var_store: mut old_var_store, - var, - interns, - .. - } = can_expr_with(arena, home, expr_str); - - // double check - let mut var_store = VarStore::new(old_var_store.fresh()); - - let expected2 = Expected::NoExpectation(Type::Variable(var)); - let constraint = roc_constrain::uniq::constrain_declaration( - home, - &mut var_store, - Region::zero(), - &loc_expr, - declared_idents, - expected2, - ); - - let stdlib = uniq_stdlib(); - - let types = stdlib.types; - let imports: Vec<_> = types - .into_iter() - .map(|(symbol, (solved_type, region))| Import { - loc_symbol: Located::at(region, symbol), - solved_type, - }) - .collect(); - - // load builtin values - - // TODO what to do with those rigids? - let (_introduced_rigids, constraint) = - constrain_imported_values(imports, constraint, &mut var_store); - - let subs2 = Subs::new(var_store.into()); - - ( - loc_expr, output, problems, subs2, var, constraint, home, interns, - ) -} - pub struct CanExprOut { pub loc_expr: Located, pub output: Output, diff --git a/editor/Cargo.toml b/editor/Cargo.toml index 1270d358d6..d1b3b2a2d0 100644 --- a/editor/Cargo.toml +++ b/editor/Cargo.toml @@ -17,7 +17,6 @@ roc_problem = { path = "../compiler/problem" } roc_types = { path = "../compiler/types" } roc_builtins = { path = "../compiler/builtins" } roc_constrain = { path = "../compiler/constrain" } -roc_uniq = { path = "../compiler/uniq" } roc_unify = { path = "../compiler/unify" } roc_solve = { path = "../compiler/solve" } roc_mono = { path = "../compiler/mono" }