diff options
24 files changed, 366 insertions, 142 deletions
diff --git a/Cargo.lock b/Cargo.lock index 2557b5e59..83e41940b 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -187,16 +187,6 @@ dependencies = [ | |||
187 | ] | 187 | ] |
188 | 188 | ||
189 | [[package]] | 189 | [[package]] |
190 | name = "chrono" | ||
191 | version = "0.4.10" | ||
192 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
193 | dependencies = [ | ||
194 | "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", | ||
195 | "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
196 | "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", | ||
197 | ] | ||
198 | |||
199 | [[package]] | ||
200 | name = "clicolors-control" | 190 | name = "clicolors-control" |
201 | version = "1.0.1" | 191 | version = "1.0.1" |
202 | source = "registry+https://github.com/rust-lang/crates.io-index" | 192 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -324,6 +314,15 @@ version = "0.3.6" | |||
324 | source = "registry+https://github.com/rust-lang/crates.io-index" | 314 | source = "registry+https://github.com/rust-lang/crates.io-index" |
325 | 315 | ||
326 | [[package]] | 316 | [[package]] |
317 | name = "env_logger" | ||
318 | version = "0.7.1" | ||
319 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
320 | dependencies = [ | ||
321 | "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
322 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
323 | ] | ||
324 | |||
325 | [[package]] | ||
327 | name = "filetime" | 326 | name = "filetime" |
328 | version = "0.2.8" | 327 | version = "0.2.8" |
329 | source = "registry+https://github.com/rust-lang/crates.io-index" | 328 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -340,18 +339,6 @@ version = "0.1.9" | |||
340 | source = "registry+https://github.com/rust-lang/crates.io-index" | 339 | source = "registry+https://github.com/rust-lang/crates.io-index" |
341 | 340 | ||
342 | [[package]] | 341 | [[package]] |
343 | name = "flexi_logger" | ||
344 | version = "0.14.5" | ||
345 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
346 | dependencies = [ | ||
347 | "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
348 | "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
349 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
350 | "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
351 | "yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
352 | ] | ||
353 | |||
354 | [[package]] | ||
355 | name = "fnv" | 342 | name = "fnv" |
356 | version = "1.0.6" | 343 | version = "1.0.6" |
357 | source = "registry+https://github.com/rust-lang/crates.io-index" | 344 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -421,11 +408,6 @@ dependencies = [ | |||
421 | ] | 408 | ] |
422 | 409 | ||
423 | [[package]] | 410 | [[package]] |
424 | name = "glob" | ||
425 | version = "0.3.0" | ||
426 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
427 | |||
428 | [[package]] | ||
429 | name = "globset" | 411 | name = "globset" |
430 | version = "0.4.4" | 412 | version = "0.4.4" |
431 | source = "registry+https://github.com/rust-lang/crates.io-index" | 413 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -454,6 +436,14 @@ dependencies = [ | |||
454 | ] | 436 | ] |
455 | 437 | ||
456 | [[package]] | 438 | [[package]] |
439 | name = "humantime" | ||
440 | version = "1.3.0" | ||
441 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
442 | dependencies = [ | ||
443 | "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
444 | ] | ||
445 | |||
446 | [[package]] | ||
457 | name = "idna" | 447 | name = "idna" |
458 | version = "0.2.0" | 448 | version = "0.2.0" |
459 | source = "registry+https://github.com/rust-lang/crates.io-index" | 449 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -723,15 +713,6 @@ dependencies = [ | |||
723 | ] | 713 | ] |
724 | 714 | ||
725 | [[package]] | 715 | [[package]] |
726 | name = "num-integer" | ||
727 | version = "0.1.41" | ||
728 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
729 | dependencies = [ | ||
730 | "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", | ||
731 | "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", | ||
732 | ] | ||
733 | |||
734 | [[package]] | ||
735 | name = "num-traits" | 716 | name = "num-traits" |
736 | version = "0.2.10" | 717 | version = "0.2.10" |
737 | source = "registry+https://github.com/rust-lang/crates.io-index" | 718 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -928,7 +909,7 @@ dependencies = [ | |||
928 | name = "ra_cli" | 909 | name = "ra_cli" |
929 | version = "0.1.0" | 910 | version = "0.1.0" |
930 | dependencies = [ | 911 | dependencies = [ |
931 | "flexi_logger 0.14.5 (registry+https://github.com/rust-lang/crates.io-index)", | 912 | "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
932 | "pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 913 | "pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
933 | "ra_batch 0.1.0", | 914 | "ra_batch 0.1.0", |
934 | "ra_db 0.1.0", | 915 | "ra_db 0.1.0", |
@@ -1060,7 +1041,7 @@ name = "ra_lsp_server" | |||
1060 | version = "0.1.0" | 1041 | version = "0.1.0" |
1061 | dependencies = [ | 1042 | dependencies = [ |
1062 | "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1043 | "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1063 | "flexi_logger 0.14.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1044 | "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1064 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1045 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1065 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1046 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1066 | "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1047 | "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1648,16 +1629,6 @@ dependencies = [ | |||
1648 | ] | 1629 | ] |
1649 | 1630 | ||
1650 | [[package]] | 1631 | [[package]] |
1651 | name = "time" | ||
1652 | version = "0.1.42" | ||
1653 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1654 | dependencies = [ | ||
1655 | "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1656 | "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1657 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1658 | ] | ||
1659 | |||
1660 | [[package]] | ||
1661 | name = "unicase" | 1632 | name = "unicase" |
1662 | version = "2.6.0" | 1633 | version = "2.6.0" |
1663 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1634 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1798,11 +1769,6 @@ dependencies = [ | |||
1798 | "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1769 | "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1799 | ] | 1770 | ] |
1800 | 1771 | ||
1801 | [[package]] | ||
1802 | name = "yansi" | ||
1803 | version = "0.5.0" | ||
1804 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1805 | |||
1806 | [metadata] | 1772 | [metadata] |
1807 | "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" | 1773 | "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" |
1808 | "checksum anyhow 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b412394828b7ca486b362f300b762d8e43dafd6f0d727b63f1cd2ade207c6cef" | 1774 | "checksum anyhow 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b412394828b7ca486b362f300b762d8e43dafd6f0d727b63f1cd2ade207c6cef" |
@@ -1827,7 +1793,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1827 | "checksum chalk-macros 0.1.1 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" | 1793 | "checksum chalk-macros 0.1.1 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" |
1828 | "checksum chalk-rust-ir 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" | 1794 | "checksum chalk-rust-ir 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" |
1829 | "checksum chalk-solve 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" | 1795 | "checksum chalk-solve 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" |
1830 | "checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" | ||
1831 | "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" | 1796 | "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" |
1832 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 1797 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
1833 | "checksum console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f" | 1798 | "checksum console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f" |
@@ -1843,9 +1808,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1843 | "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" | 1808 | "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" |
1844 | "checksum ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" | 1809 | "checksum ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" |
1845 | "checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" | 1810 | "checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" |
1811 | "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" | ||
1846 | "checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" | 1812 | "checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" |
1847 | "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" | 1813 | "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" |
1848 | "checksum flexi_logger 0.14.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a13ea6b8a4debecf47bf3966d56db0e21366bc3a3649ba159e1a9e6fdd36a4f4" | ||
1849 | "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" | 1814 | "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" |
1850 | "checksum format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7aea5a5909a74969507051a3b17adc84737e31a5f910559892aedce026f4d53" | 1815 | "checksum format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7aea5a5909a74969507051a3b17adc84737e31a5f910559892aedce026f4d53" |
1851 | "checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" | 1816 | "checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" |
@@ -1856,10 +1821,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1856 | "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" | 1821 | "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" |
1857 | "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" | 1822 | "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" |
1858 | "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" | 1823 | "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" |
1859 | "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" | ||
1860 | "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" | 1824 | "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" |
1861 | "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" | 1825 | "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" |
1862 | "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" | 1826 | "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" |
1827 | "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" | ||
1863 | "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" | 1828 | "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" |
1864 | "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" | 1829 | "checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" |
1865 | "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" | 1830 | "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" |
@@ -1891,7 +1856,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1891 | "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" | 1856 | "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" |
1892 | "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" | 1857 | "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" |
1893 | "checksum notify 4.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "199628fc33b21bc767baa057490b00b382ecbae030803a7b36292422d15b778b" | 1858 | "checksum notify 4.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "199628fc33b21bc767baa057490b00b382ecbae030803a7b36292422d15b778b" |
1894 | "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" | ||
1895 | "checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" | 1859 | "checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" |
1896 | "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" | 1860 | "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" |
1897 | "checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" | 1861 | "checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" |
@@ -1964,7 +1928,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1964 | "checksum thin-dst 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c52fd98a9e4913c466d83381a59245691875d2f3e04611fca57f964bd8aa96e1" | 1928 | "checksum thin-dst 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c52fd98a9e4913c466d83381a59245691875d2f3e04611fca57f964bd8aa96e1" |
1965 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" | 1929 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" |
1966 | "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" | 1930 | "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" |
1967 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" | ||
1968 | "checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" | 1931 | "checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" |
1969 | "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" | 1932 | "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" |
1970 | "checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" | 1933 | "checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" |
@@ -1983,4 +1946,3 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1983 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | 1946 | "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
1984 | "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" | 1947 | "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" |
1985 | "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" | 1948 | "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" |
1986 | "checksum yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" | ||
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml index c7e0d0f0f..21a37c7bf 100644 --- a/crates/ra_cli/Cargo.toml +++ b/crates/ra_cli/Cargo.toml | |||
@@ -7,7 +7,7 @@ publish = false | |||
7 | 7 | ||
8 | [dependencies] | 8 | [dependencies] |
9 | pico-args = "0.3.0" | 9 | pico-args = "0.3.0" |
10 | flexi_logger = "0.14.0" | 10 | env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } |
11 | 11 | ||
12 | ra_syntax = { path = "../ra_syntax" } | 12 | ra_syntax = { path = "../ra_syntax" } |
13 | ra_ide = { path = "../ra_ide" } | 13 | ra_ide = { path = "../ra_ide" } |
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index fe847e611..3808590ab 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -7,7 +7,6 @@ mod progress_report; | |||
7 | 7 | ||
8 | use std::{error::Error, fmt::Write, io::Read}; | 8 | use std::{error::Error, fmt::Write, io::Read}; |
9 | 9 | ||
10 | use flexi_logger::Logger; | ||
11 | use pico_args::Arguments; | 10 | use pico_args::Arguments; |
12 | use ra_ide::{file_structure, Analysis}; | 11 | use ra_ide::{file_structure, Analysis}; |
13 | use ra_prof::profile; | 12 | use ra_prof::profile; |
@@ -32,7 +31,7 @@ impl Verbosity { | |||
32 | } | 31 | } |
33 | 32 | ||
34 | fn main() -> Result<()> { | 33 | fn main() -> Result<()> { |
35 | Logger::with_env_or_str("error").start()?; | 34 | env_logger::try_init()?; |
36 | 35 | ||
37 | let subcommand = match std::env::args_os().nth(1) { | 36 | let subcommand = match std::env::args_os().nth(1) { |
38 | None => { | 37 | None => { |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 331736cb2..be1eaa523 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -429,10 +429,19 @@ where | |||
429 | let index = self.collect_expr_opt(e.index()); | 429 | let index = self.collect_expr_opt(e.index()); |
430 | self.alloc_expr(Expr::Index { base, index }, syntax_ptr) | 430 | self.alloc_expr(Expr::Index { base, index }, syntax_ptr) |
431 | } | 431 | } |
432 | ast::Expr::RangeExpr(e) => { | ||
433 | let lhs = e.start().map(|lhs| self.collect_expr(lhs)); | ||
434 | let rhs = e.end().map(|rhs| self.collect_expr(rhs)); | ||
435 | match e.op_kind() { | ||
436 | Some(range_type) => { | ||
437 | self.alloc_expr(Expr::Range { lhs, rhs, range_type }, syntax_ptr) | ||
438 | } | ||
439 | None => self.alloc_expr(Expr::Missing, syntax_ptr), | ||
440 | } | ||
441 | } | ||
432 | 442 | ||
433 | // FIXME implement HIR for these: | 443 | // FIXME implement HIR for these: |
434 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | 444 | ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), |
435 | ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), | ||
436 | ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { | 445 | ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { |
437 | Some((mark, expansion)) => { | 446 | Some((mark, expansion)) => { |
438 | let id = self.collect_expr(expansion); | 447 | let id = self.collect_expr(expansion); |
diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index 04c1d8f69..6fad80a8d 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | use hir_expand::name::Name; | 15 | use hir_expand::name::Name; |
16 | use ra_arena::{impl_arena_id, RawId}; | 16 | use ra_arena::{impl_arena_id, RawId}; |
17 | use ra_syntax::ast::RangeOp; | ||
17 | 18 | ||
18 | use crate::{ | 19 | use crate::{ |
19 | builtin_type::{BuiltinFloat, BuiltinInt}, | 20 | builtin_type::{BuiltinFloat, BuiltinInt}, |
@@ -130,6 +131,11 @@ pub enum Expr { | |||
130 | rhs: ExprId, | 131 | rhs: ExprId, |
131 | op: Option<BinaryOp>, | 132 | op: Option<BinaryOp>, |
132 | }, | 133 | }, |
134 | Range { | ||
135 | lhs: Option<ExprId>, | ||
136 | rhs: Option<ExprId>, | ||
137 | range_type: RangeOp, | ||
138 | }, | ||
133 | Index { | 139 | Index { |
134 | base: ExprId, | 140 | base: ExprId, |
135 | index: ExprId, | 141 | index: ExprId, |
@@ -288,6 +294,14 @@ impl Expr { | |||
288 | f(*lhs); | 294 | f(*lhs); |
289 | f(*rhs); | 295 | f(*rhs); |
290 | } | 296 | } |
297 | Expr::Range { lhs, rhs, .. } => { | ||
298 | if let Some(lhs) = rhs { | ||
299 | f(*lhs); | ||
300 | } | ||
301 | if let Some(rhs) = lhs { | ||
302 | f(*rhs); | ||
303 | } | ||
304 | } | ||
291 | Expr::Index { base, index } => { | 305 | Expr::Index { base, index } => { |
292 | f(*base); | 306 | f(*base); |
293 | f(*index); | 307 | f(*index); |
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs index 10688df4d..ff252fe44 100644 --- a/crates/ra_hir_def/src/path.rs +++ b/crates/ra_hir_def/src/path.rs | |||
@@ -409,6 +409,36 @@ pub mod known { | |||
409 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::TRY_TYPE]) | 409 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::TRY_TYPE]) |
410 | } | 410 | } |
411 | 411 | ||
412 | pub fn std_ops_range() -> Path { | ||
413 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_TYPE]) | ||
414 | } | ||
415 | |||
416 | pub fn std_ops_range_from() -> Path { | ||
417 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_FROM_TYPE]) | ||
418 | } | ||
419 | |||
420 | pub fn std_ops_range_full() -> Path { | ||
421 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_FULL_TYPE]) | ||
422 | } | ||
423 | |||
424 | pub fn std_ops_range_inclusive() -> Path { | ||
425 | Path::from_simple_segments( | ||
426 | PathKind::Abs, | ||
427 | vec![name::STD, name::OPS, name::RANGE_INCLUSIVE_TYPE], | ||
428 | ) | ||
429 | } | ||
430 | |||
431 | pub fn std_ops_range_to() -> Path { | ||
432 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_TO_TYPE]) | ||
433 | } | ||
434 | |||
435 | pub fn std_ops_range_to_inclusive() -> Path { | ||
436 | Path::from_simple_segments( | ||
437 | PathKind::Abs, | ||
438 | vec![name::STD, name::OPS, name::RANGE_TO_INCLUSIVE_TYPE], | ||
439 | ) | ||
440 | } | ||
441 | |||
412 | pub fn std_result_result() -> Path { | 442 | pub fn std_result_result() -> Path { |
413 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::RESULT, name::RESULT_TYPE]) | 443 | Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::RESULT, name::RESULT_TYPE]) |
414 | } | 444 | } |
diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs index 7824489d7..05ba37070 100644 --- a/crates/ra_hir_expand/src/name.rs +++ b/crates/ra_hir_expand/src/name.rs | |||
@@ -140,6 +140,12 @@ pub const RESULT_TYPE: Name = Name::new_inline_ascii(6, b"Result"); | |||
140 | pub const OUTPUT_TYPE: Name = Name::new_inline_ascii(6, b"Output"); | 140 | pub const OUTPUT_TYPE: Name = Name::new_inline_ascii(6, b"Output"); |
141 | pub const TARGET_TYPE: Name = Name::new_inline_ascii(6, b"Target"); | 141 | pub const TARGET_TYPE: Name = Name::new_inline_ascii(6, b"Target"); |
142 | pub const BOX_TYPE: Name = Name::new_inline_ascii(3, b"Box"); | 142 | pub const BOX_TYPE: Name = Name::new_inline_ascii(3, b"Box"); |
143 | pub const RANGE_FROM_TYPE: Name = Name::new_inline_ascii(9, b"RangeFrom"); | ||
144 | pub const RANGE_FULL_TYPE: Name = Name::new_inline_ascii(9, b"RangeFull"); | ||
145 | pub const RANGE_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(14, b"RangeInclusive"); | ||
146 | pub const RANGE_TO_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(16, b"RangeToInclusive"); | ||
147 | pub const RANGE_TO_TYPE: Name = Name::new_inline_ascii(7, b"RangeTo"); | ||
148 | pub const RANGE_TYPE: Name = Name::new_inline_ascii(5, b"Range"); | ||
143 | 149 | ||
144 | // Builtin Macros | 150 | // Builtin Macros |
145 | pub const FILE_MACRO: Name = Name::new_inline_ascii(4, b"file"); | 151 | pub const FILE_MACRO: Name = Name::new_inline_ascii(4, b"file"); |
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index 9ce154593..222a36a9f 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs | |||
@@ -11,7 +11,7 @@ use ra_db::{salsa, CrateId}; | |||
11 | use crate::{ | 11 | use crate::{ |
12 | method_resolution::CrateImplBlocks, | 12 | method_resolution::CrateImplBlocks, |
13 | traits::{AssocTyValue, Impl}, | 13 | traits::{AssocTyValue, Impl}, |
14 | CallableDef, FnSig, GenericPredicate, ImplTy, InferenceResult, Substs, Ty, TyDefId, TypeCtor, | 14 | CallableDef, FnSig, GenericPredicate, InferenceResult, Substs, TraitRef, Ty, TyDefId, TypeCtor, |
15 | ValueTyDefId, | 15 | ValueTyDefId, |
16 | }; | 16 | }; |
17 | 17 | ||
@@ -22,13 +22,18 @@ pub trait HirDatabase: DefDatabase { | |||
22 | fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; | 22 | fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; |
23 | 23 | ||
24 | #[salsa::invoke(crate::lower::ty_query)] | 24 | #[salsa::invoke(crate::lower::ty_query)] |
25 | #[salsa::cycle(crate::lower::ty_recover)] | ||
25 | fn ty(&self, def: TyDefId) -> Ty; | 26 | fn ty(&self, def: TyDefId) -> Ty; |
26 | 27 | ||
27 | #[salsa::invoke(crate::lower::value_ty_query)] | 28 | #[salsa::invoke(crate::lower::value_ty_query)] |
28 | fn value_ty(&self, def: ValueTyDefId) -> Ty; | 29 | fn value_ty(&self, def: ValueTyDefId) -> Ty; |
29 | 30 | ||
30 | #[salsa::invoke(crate::lower::impl_ty_query)] | 31 | #[salsa::invoke(crate::lower::impl_self_ty_query)] |
31 | fn impl_ty(&self, def: ImplId) -> ImplTy; | 32 | #[salsa::cycle(crate::lower::impl_self_ty_recover)] |
33 | fn impl_self_ty(&self, def: ImplId) -> Ty; | ||
34 | |||
35 | #[salsa::invoke(crate::lower::impl_trait_query)] | ||
36 | fn impl_trait(&self, def: ImplId) -> Option<TraitRef>; | ||
32 | 37 | ||
33 | #[salsa::invoke(crate::lower::field_types_query)] | 38 | #[salsa::invoke(crate::lower::field_types_query)] |
34 | fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>; | 39 | fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>; |
@@ -37,6 +42,7 @@ pub trait HirDatabase: DefDatabase { | |||
37 | fn callable_item_signature(&self, def: CallableDef) -> FnSig; | 42 | fn callable_item_signature(&self, def: CallableDef) -> FnSig; |
38 | 43 | ||
39 | #[salsa::invoke(crate::lower::generic_predicates_for_param_query)] | 44 | #[salsa::invoke(crate::lower::generic_predicates_for_param_query)] |
45 | #[salsa::cycle(crate::lower::generic_predicates_for_param_recover)] | ||
40 | fn generic_predicates_for_param( | 46 | fn generic_predicates_for_param( |
41 | &self, | 47 | &self, |
42 | def: GenericDefId, | 48 | def: GenericDefId, |
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index f6283ab6d..fe259371f 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -577,6 +577,42 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
577 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | 577 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; |
578 | Some(struct_.into()) | 578 | Some(struct_.into()) |
579 | } | 579 | } |
580 | |||
581 | fn resolve_range_full(&self) -> Option<AdtId> { | ||
582 | let path = known::std_ops_range_full(); | ||
583 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | ||
584 | Some(struct_.into()) | ||
585 | } | ||
586 | |||
587 | fn resolve_range(&self) -> Option<AdtId> { | ||
588 | let path = known::std_ops_range(); | ||
589 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | ||
590 | Some(struct_.into()) | ||
591 | } | ||
592 | |||
593 | fn resolve_range_inclusive(&self) -> Option<AdtId> { | ||
594 | let path = known::std_ops_range_inclusive(); | ||
595 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | ||
596 | Some(struct_.into()) | ||
597 | } | ||
598 | |||
599 | fn resolve_range_from(&self) -> Option<AdtId> { | ||
600 | let path = known::std_ops_range_from(); | ||
601 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | ||
602 | Some(struct_.into()) | ||
603 | } | ||
604 | |||
605 | fn resolve_range_to(&self) -> Option<AdtId> { | ||
606 | let path = known::std_ops_range_to(); | ||
607 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | ||
608 | Some(struct_.into()) | ||
609 | } | ||
610 | |||
611 | fn resolve_range_to_inclusive(&self) -> Option<AdtId> { | ||
612 | let path = known::std_ops_range_to_inclusive(); | ||
613 | let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; | ||
614 | Some(struct_.into()) | ||
615 | } | ||
580 | } | 616 | } |
581 | 617 | ||
582 | /// The ID of a type variable. | 618 | /// The ID of a type variable. |
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 719a0f395..064993d34 100644 --- a/crates/ra_hir_ty/src/infer/coerce.rs +++ b/crates/ra_hir_ty/src/infer/coerce.rs | |||
@@ -8,7 +8,7 @@ use hir_def::{lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutabilit | |||
8 | use rustc_hash::FxHashMap; | 8 | use rustc_hash::FxHashMap; |
9 | use test_utils::tested_by; | 9 | use test_utils::tested_by; |
10 | 10 | ||
11 | use crate::{autoderef, db::HirDatabase, ImplTy, Substs, Ty, TypeCtor, TypeWalk}; | 11 | use crate::{autoderef, db::HirDatabase, Substs, Ty, TypeCtor, TypeWalk}; |
12 | 12 | ||
13 | use super::{InEnvironment, InferTy, InferenceContext, TypeVarValue}; | 13 | use super::{InEnvironment, InferTy, InferenceContext, TypeVarValue}; |
14 | 14 | ||
@@ -54,10 +54,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
54 | impls | 54 | impls |
55 | .iter() | 55 | .iter() |
56 | .filter_map(|&impl_id| { | 56 | .filter_map(|&impl_id| { |
57 | let trait_ref = match db.impl_ty(impl_id) { | 57 | let trait_ref = db.impl_trait(impl_id)?; |
58 | ImplTy::TraitRef(it) => it, | ||
59 | ImplTy::Inherent(_) => return None, | ||
60 | }; | ||
61 | 58 | ||
62 | // `CoerseUnsized` has one generic parameter for the target type. | 59 | // `CoerseUnsized` has one generic parameter for the target type. |
63 | let cur_from_ty = trait_ref.substs.0.get(0)?; | 60 | let cur_from_ty = trait_ref.substs.0.get(0)?; |
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 2f9ca4bbb..4014f4732 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -12,6 +12,7 @@ use hir_def::{ | |||
12 | AdtId, ContainerId, Lookup, StructFieldId, | 12 | AdtId, ContainerId, Lookup, StructFieldId, |
13 | }; | 13 | }; |
14 | use hir_expand::name::{self, Name}; | 14 | use hir_expand::name::{self, Name}; |
15 | use ra_syntax::ast::RangeOp; | ||
15 | 16 | ||
16 | use crate::{ | 17 | use crate::{ |
17 | autoderef, db::HirDatabase, method_resolution, op, traits::InEnvironment, utils::variant_data, | 18 | autoderef, db::HirDatabase, method_resolution, op, traits::InEnvironment, utils::variant_data, |
@@ -415,6 +416,44 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
415 | } | 416 | } |
416 | _ => Ty::Unknown, | 417 | _ => Ty::Unknown, |
417 | }, | 418 | }, |
419 | Expr::Range { lhs, rhs, range_type } => { | ||
420 | let lhs_ty = lhs.map(|e| self.infer_expr(e, &Expectation::none())); | ||
421 | let rhs_expect = lhs_ty | ||
422 | .as_ref() | ||
423 | .map_or_else(Expectation::none, |ty| Expectation::has_type(ty.clone())); | ||
424 | let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect)); | ||
425 | match (range_type, lhs_ty, rhs_ty) { | ||
426 | (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { | ||
427 | Some(adt) => Ty::simple(TypeCtor::Adt(adt)), | ||
428 | None => Ty::Unknown, | ||
429 | }, | ||
430 | (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { | ||
431 | Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty), | ||
432 | None => Ty::Unknown, | ||
433 | }, | ||
434 | (RangeOp::Inclusive, None, Some(ty)) => { | ||
435 | match self.resolve_range_to_inclusive() { | ||
436 | Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty), | ||
437 | None => Ty::Unknown, | ||
438 | } | ||
439 | } | ||
440 | (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() { | ||
441 | Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty), | ||
442 | None => Ty::Unknown, | ||
443 | }, | ||
444 | (RangeOp::Inclusive, Some(_), Some(ty)) => { | ||
445 | match self.resolve_range_inclusive() { | ||
446 | Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty), | ||
447 | None => Ty::Unknown, | ||
448 | } | ||
449 | } | ||
450 | (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() { | ||
451 | Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty), | ||
452 | None => Ty::Unknown, | ||
453 | }, | ||
454 | (RangeOp::Inclusive, _, None) => Ty::Unknown, | ||
455 | } | ||
456 | } | ||
418 | Expr::Index { base, index } => { | 457 | Expr::Index { base, index } => { |
419 | let _base_ty = self.infer_expr(*base, &Expectation::none()); | 458 | let _base_ty = self.infer_expr(*base, &Expectation::none()); |
420 | let _index_ty = self.infer_expr(*index, &Expectation::none()); | 459 | let _index_ty = self.infer_expr(*index, &Expectation::none()); |
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs index 14be66836..bbf146418 100644 --- a/crates/ra_hir_ty/src/infer/path.rs +++ b/crates/ra_hir_ty/src/infer/path.rs | |||
@@ -244,7 +244,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
244 | ContainerId::ImplId(it) => it, | 244 | ContainerId::ImplId(it) => it, |
245 | _ => return None, | 245 | _ => return None, |
246 | }; | 246 | }; |
247 | let self_ty = self.db.impl_ty(impl_id).self_type().clone(); | 247 | let self_ty = self.db.impl_self_ty(impl_id).clone(); |
248 | let self_ty_substs = self_ty.substs()?; | 248 | let self_ty_substs = self_ty.substs()?; |
249 | let actual_substs = actual_def_ty.substs()?; | 249 | let actual_substs = actual_def_ty.substs()?; |
250 | 250 | ||
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index b45c8f82f..3c1f738df 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -486,21 +486,6 @@ impl TypeWalk for TraitRef { | |||
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | #[derive(Clone, PartialEq, Eq, Debug)] | ||
490 | pub enum ImplTy { | ||
491 | Inherent(Ty), | ||
492 | TraitRef(TraitRef), | ||
493 | } | ||
494 | |||
495 | impl ImplTy { | ||
496 | pub(crate) fn self_type(&self) -> &Ty { | ||
497 | match self { | ||
498 | ImplTy::Inherent(it) => it, | ||
499 | ImplTy::TraitRef(tr) => &tr.substs[0], | ||
500 | } | ||
501 | } | ||
502 | } | ||
503 | |||
504 | /// Like `generics::WherePredicate`, but with resolved types: A condition on the | 489 | /// Like `generics::WherePredicate`, but with resolved types: A condition on the |
505 | /// parameters of a generic item. | 490 | /// parameters of a generic item. |
506 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 491 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index 091c60f4f..32569ac66 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs | |||
@@ -27,8 +27,8 @@ use crate::{ | |||
27 | all_super_traits, associated_type_by_name_including_super_traits, make_mut_slice, | 27 | all_super_traits, associated_type_by_name_including_super_traits, make_mut_slice, |
28 | variant_data, | 28 | variant_data, |
29 | }, | 29 | }, |
30 | FnSig, GenericPredicate, ImplTy, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, | 30 | FnSig, GenericPredicate, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, TraitRef, |
31 | TraitRef, Ty, TypeCtor, TypeWalk, | 31 | Ty, TypeCtor, TypeWalk, |
32 | }; | 32 | }; |
33 | 33 | ||
34 | impl Ty { | 34 | impl Ty { |
@@ -179,7 +179,7 @@ impl Ty { | |||
179 | let name = resolved_segment.name.clone(); | 179 | let name = resolved_segment.name.clone(); |
180 | Ty::Param { idx, name } | 180 | Ty::Param { idx, name } |
181 | } | 181 | } |
182 | TypeNs::SelfType(impl_id) => db.impl_ty(impl_id).self_type().clone(), | 182 | TypeNs::SelfType(impl_id) => db.impl_self_ty(impl_id).clone(), |
183 | TypeNs::AdtSelfType(adt) => db.ty(adt.into()), | 183 | TypeNs::AdtSelfType(adt) => db.ty(adt.into()), |
184 | 184 | ||
185 | TypeNs::AdtId(it) => Ty::from_hir_path_inner(db, resolver, resolved_segment, it.into()), | 185 | TypeNs::AdtId(it) => Ty::from_hir_path_inner(db, resolver, resolved_segment, it.into()), |
@@ -532,6 +532,15 @@ pub(crate) fn generic_predicates_for_param_query( | |||
532 | .collect() | 532 | .collect() |
533 | } | 533 | } |
534 | 534 | ||
535 | pub(crate) fn generic_predicates_for_param_recover( | ||
536 | _db: &impl HirDatabase, | ||
537 | _cycle: &[String], | ||
538 | _def: &GenericDefId, | ||
539 | _param_idx: &u32, | ||
540 | ) -> Arc<[GenericPredicate]> { | ||
541 | Arc::new([]) | ||
542 | } | ||
543 | |||
535 | impl TraitEnvironment { | 544 | impl TraitEnvironment { |
536 | pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc<TraitEnvironment> { | 545 | pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc<TraitEnvironment> { |
537 | let predicates = resolver | 546 | let predicates = resolver |
@@ -733,6 +742,11 @@ pub(crate) fn ty_query(db: &impl HirDatabase, def: TyDefId) -> Ty { | |||
733 | TyDefId::TypeAliasId(it) => type_for_type_alias(db, it), | 742 | TyDefId::TypeAliasId(it) => type_for_type_alias(db, it), |
734 | } | 743 | } |
735 | } | 744 | } |
745 | |||
746 | pub(crate) fn ty_recover(_db: &impl HirDatabase, _cycle: &[String], _def: &TyDefId) -> Ty { | ||
747 | Ty::Unknown | ||
748 | } | ||
749 | |||
736 | pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty { | 750 | pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty { |
737 | match def { | 751 | match def { |
738 | ValueTyDefId::FunctionId(it) => type_for_fn(db, it), | 752 | ValueTyDefId::FunctionId(it) => type_for_fn(db, it), |
@@ -743,17 +757,24 @@ pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty { | |||
743 | } | 757 | } |
744 | } | 758 | } |
745 | 759 | ||
746 | pub(crate) fn impl_ty_query(db: &impl HirDatabase, impl_id: ImplId) -> ImplTy { | 760 | pub(crate) fn impl_self_ty_query(db: &impl HirDatabase, impl_id: ImplId) -> Ty { |
747 | let impl_data = db.impl_data(impl_id); | 761 | let impl_data = db.impl_data(impl_id); |
748 | let resolver = impl_id.resolver(db); | 762 | let resolver = impl_id.resolver(db); |
749 | let self_ty = Ty::from_hir(db, &resolver, &impl_data.target_type); | 763 | Ty::from_hir(db, &resolver, &impl_data.target_type) |
750 | match impl_data.target_trait.as_ref() { | 764 | } |
751 | Some(trait_ref) => { | 765 | |
752 | match TraitRef::from_hir(db, &resolver, trait_ref, Some(self_ty.clone())) { | 766 | pub(crate) fn impl_self_ty_recover( |
753 | Some(it) => ImplTy::TraitRef(it), | 767 | _db: &impl HirDatabase, |
754 | None => ImplTy::Inherent(self_ty), | 768 | _cycle: &[String], |
755 | } | 769 | _impl_id: &ImplId, |
756 | } | 770 | ) -> Ty { |
757 | None => ImplTy::Inherent(self_ty), | 771 | Ty::Unknown |
758 | } | 772 | } |
773 | |||
774 | pub(crate) fn impl_trait_query(db: &impl HirDatabase, impl_id: ImplId) -> Option<TraitRef> { | ||
775 | let impl_data = db.impl_data(impl_id); | ||
776 | let resolver = impl_id.resolver(db); | ||
777 | let self_ty = db.impl_self_ty(impl_id); | ||
778 | let target_trait = impl_data.target_trait.as_ref()?; | ||
779 | TraitRef::from_hir(db, &resolver, target_trait, Some(self_ty.clone())) | ||
759 | } | 780 | } |
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs index ee1936b0e..2bded3dbd 100644 --- a/crates/ra_hir_ty/src/method_resolution.rs +++ b/crates/ra_hir_ty/src/method_resolution.rs | |||
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | db::HirDatabase, | 19 | db::HirDatabase, |
20 | primitive::{FloatBitness, Uncertain}, | 20 | primitive::{FloatBitness, Uncertain}, |
21 | utils::all_super_traits, | 21 | utils::all_super_traits, |
22 | Canonical, ImplTy, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor, | 22 | Canonical, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | /// This is used as a key for indexing impls. | 25 | /// This is used as a key for indexing impls. |
@@ -58,11 +58,12 @@ impl CrateImplBlocks { | |||
58 | let crate_def_map = db.crate_def_map(krate); | 58 | let crate_def_map = db.crate_def_map(krate); |
59 | for (_module_id, module_data) in crate_def_map.modules.iter() { | 59 | for (_module_id, module_data) in crate_def_map.modules.iter() { |
60 | for &impl_id in module_data.impls.iter() { | 60 | for &impl_id in module_data.impls.iter() { |
61 | match db.impl_ty(impl_id) { | 61 | match db.impl_trait(impl_id) { |
62 | ImplTy::TraitRef(tr) => { | 62 | Some(tr) => { |
63 | res.impls_by_trait.entry(tr.trait_).or_default().push(impl_id); | 63 | res.impls_by_trait.entry(tr.trait_).or_default().push(impl_id); |
64 | } | 64 | } |
65 | ImplTy::Inherent(self_ty) => { | 65 | None => { |
66 | let self_ty = db.impl_self_ty(impl_id); | ||
66 | if let Some(self_ty_fp) = TyFingerprint::for_impl(&self_ty) { | 67 | if let Some(self_ty_fp) = TyFingerprint::for_impl(&self_ty) { |
67 | res.impls.entry(self_ty_fp).or_default().push(impl_id); | 68 | res.impls.entry(self_ty_fp).or_default().push(impl_id); |
68 | } | 69 | } |
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index 3766ab981..a3cc5cf95 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs | |||
@@ -222,6 +222,56 @@ mod collections { | |||
222 | } | 222 | } |
223 | 223 | ||
224 | #[test] | 224 | #[test] |
225 | fn infer_ranges() { | ||
226 | let (db, pos) = TestDB::with_position( | ||
227 | r#" | ||
228 | //- /main.rs crate:main deps:std | ||
229 | fn test() { | ||
230 | let a = ..; | ||
231 | let b = 1..; | ||
232 | let c = ..2u32; | ||
233 | let d = 1..2usize; | ||
234 | let e = ..=10; | ||
235 | let f = 'a'..='z'; | ||
236 | |||
237 | let t = (a, b, c, d, e, f); | ||
238 | t<|>; | ||
239 | } | ||
240 | |||
241 | //- /std.rs crate:std | ||
242 | #[prelude_import] use prelude::*; | ||
243 | mod prelude {} | ||
244 | |||
245 | pub mod ops { | ||
246 | pub struct Range<Idx> { | ||
247 | pub start: Idx, | ||
248 | pub end: Idx, | ||
249 | } | ||
250 | pub struct RangeFrom<Idx> { | ||
251 | pub start: Idx, | ||
252 | } | ||
253 | struct RangeFull; | ||
254 | pub struct RangeInclusive<Idx> { | ||
255 | start: Idx, | ||
256 | end: Idx, | ||
257 | is_empty: u8, | ||
258 | } | ||
259 | pub struct RangeTo<Idx> { | ||
260 | pub end: Idx, | ||
261 | } | ||
262 | pub struct RangeToInclusive<Idx> { | ||
263 | pub end: Idx, | ||
264 | } | ||
265 | } | ||
266 | "#, | ||
267 | ); | ||
268 | assert_eq!( | ||
269 | "(RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>)", | ||
270 | type_at_pos(&db, pos), | ||
271 | ); | ||
272 | } | ||
273 | |||
274 | #[test] | ||
225 | fn infer_while_let() { | 275 | fn infer_while_let() { |
226 | let (db, pos) = TestDB::with_position( | 276 | let (db, pos) = TestDB::with_position( |
227 | r#" | 277 | r#" |
@@ -2104,7 +2154,6 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) { | |||
2104 | } | 2154 | } |
2105 | 2155 | ||
2106 | #[test] | 2156 | #[test] |
2107 | #[should_panic] // we currently can't handle this | ||
2108 | fn recursive_type_alias() { | 2157 | fn recursive_type_alias() { |
2109 | assert_snapshot!( | 2158 | assert_snapshot!( |
2110 | infer(r#" | 2159 | infer(r#" |
@@ -2113,7 +2162,10 @@ type Foo = Foo; | |||
2113 | type Bar = A<Bar>; | 2162 | type Bar = A<Bar>; |
2114 | fn test(x: Foo) {} | 2163 | fn test(x: Foo) {} |
2115 | "#), | 2164 | "#), |
2116 | @"" | 2165 | @r###" |
2166 | [59; 60) 'x': {unknown} | ||
2167 | [67; 69) '{}': () | ||
2168 | "### | ||
2117 | ) | 2169 | ) |
2118 | } | 2170 | } |
2119 | 2171 | ||
@@ -4662,10 +4714,48 @@ fn test<T, U>() where T::Item: Trait2, T: Trait<U::Item>, U: Trait<()> { | |||
4662 | } | 4714 | } |
4663 | 4715 | ||
4664 | #[test] | 4716 | #[test] |
4665 | // FIXME this is currently a Salsa panic; it would be nicer if it just returned | 4717 | fn trait_impl_self_ty() { |
4666 | // in Unknown, and we should be able to do that once Salsa allows us to handle | 4718 | let t = type_at( |
4667 | // the cycle. But at least it doesn't overflow for now. | 4719 | r#" |
4668 | #[should_panic] | 4720 | //- /main.rs |
4721 | trait Trait<T> { | ||
4722 | fn foo(&self); | ||
4723 | } | ||
4724 | |||
4725 | struct S; | ||
4726 | |||
4727 | impl Trait<Self> for S {} | ||
4728 | |||
4729 | fn test() { | ||
4730 | S.foo()<|>; | ||
4731 | } | ||
4732 | "#, | ||
4733 | ); | ||
4734 | assert_eq!(t, "()"); | ||
4735 | } | ||
4736 | |||
4737 | #[test] | ||
4738 | fn trait_impl_self_ty_cycle() { | ||
4739 | let t = type_at( | ||
4740 | r#" | ||
4741 | //- /main.rs | ||
4742 | trait Trait { | ||
4743 | fn foo(&self); | ||
4744 | } | ||
4745 | |||
4746 | struct S<T>; | ||
4747 | |||
4748 | impl Trait for S<Self> {} | ||
4749 | |||
4750 | fn test() { | ||
4751 | S.foo()<|>; | ||
4752 | } | ||
4753 | "#, | ||
4754 | ); | ||
4755 | assert_eq!(t, "{unknown}"); | ||
4756 | } | ||
4757 | |||
4758 | #[test] | ||
4669 | fn unselected_projection_in_trait_env_cycle_1() { | 4759 | fn unselected_projection_in_trait_env_cycle_1() { |
4670 | let t = type_at( | 4760 | let t = type_at( |
4671 | r#" | 4761 | r#" |
@@ -4686,10 +4776,6 @@ fn test<T: Trait>() where T: Trait2<T::Item> { | |||
4686 | } | 4776 | } |
4687 | 4777 | ||
4688 | #[test] | 4778 | #[test] |
4689 | // FIXME this is currently a Salsa panic; it would be nicer if it just returned | ||
4690 | // in Unknown, and we should be able to do that once Salsa allows us to handle | ||
4691 | // the cycle. But at least it doesn't overflow for now. | ||
4692 | #[should_panic] | ||
4693 | fn unselected_projection_in_trait_env_cycle_2() { | 4779 | fn unselected_projection_in_trait_env_cycle_2() { |
4694 | let t = type_at( | 4780 | let t = type_at( |
4695 | r#" | 4781 | r#" |
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 35de37e6b..104346ada 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -20,8 +20,8 @@ use ra_db::salsa::{InternId, InternKey}; | |||
20 | 20 | ||
21 | use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation}; | 21 | use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation}; |
22 | use crate::{ | 22 | use crate::{ |
23 | db::HirDatabase, display::HirDisplay, ApplicationTy, GenericPredicate, ImplTy, ProjectionTy, | 23 | db::HirDatabase, display::HirDisplay, ApplicationTy, GenericPredicate, ProjectionTy, Substs, |
24 | Substs, TraitRef, Ty, TypeCtor, TypeWalk, | 24 | TraitRef, Ty, TypeCtor, TypeWalk, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | /// This represents a trait whose name we could not resolve. | 27 | /// This represents a trait whose name we could not resolve. |
@@ -630,10 +630,7 @@ fn impl_block_datum( | |||
630 | chalk_id: chalk_ir::ImplId, | 630 | chalk_id: chalk_ir::ImplId, |
631 | impl_id: ImplId, | 631 | impl_id: ImplId, |
632 | ) -> Option<Arc<ImplDatum<ChalkIr>>> { | 632 | ) -> Option<Arc<ImplDatum<ChalkIr>>> { |
633 | let trait_ref = match db.impl_ty(impl_id) { | 633 | let trait_ref = db.impl_trait(impl_id)?; |
634 | ImplTy::TraitRef(it) => it, | ||
635 | ImplTy::Inherent(_) => return None, | ||
636 | }; | ||
637 | let impl_data = db.impl_data(impl_id); | 634 | let impl_data = db.impl_data(impl_id); |
638 | 635 | ||
639 | let generic_params = db.generic_params(impl_id.into()); | 636 | let generic_params = db.generic_params(impl_id.into()); |
@@ -787,11 +784,7 @@ fn type_alias_associated_ty_value( | |||
787 | _ => panic!("assoc ty value should be in impl"), | 784 | _ => panic!("assoc ty value should be in impl"), |
788 | }; | 785 | }; |
789 | 786 | ||
790 | let trait_ref = match db.impl_ty(impl_id) { | 787 | let trait_ref = db.impl_trait(impl_id).expect("assoc ty value should not exist"); // we don't return any assoc ty values if the impl'd trait can't be resolved |
791 | ImplTy::TraitRef(it) => it, | ||
792 | // we don't return any assoc ty values if the impl'd trait can't be resolved | ||
793 | ImplTy::Inherent(_) => panic!("assoc ty value should not exist"), | ||
794 | }; | ||
795 | 788 | ||
796 | let assoc_ty = db | 789 | let assoc_ty = db |
797 | .trait_data(trait_ref.trait_) | 790 | .trait_data(trait_ref.trait_) |
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index ea6b354c2..b804d5f6d 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use hir::ModuleSource; | 3 | use hir::ModuleSource; |
4 | use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt}; | 4 | use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt}; |
5 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNode}; | 5 | use ra_syntax::{algo::find_node_at_offset, ast, tokenize, AstNode, SyntaxKind, SyntaxNode}; |
6 | use ra_text_edit::TextEdit; | 6 | use ra_text_edit::TextEdit; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
@@ -17,6 +17,13 @@ pub(crate) fn rename( | |||
17 | position: FilePosition, | 17 | position: FilePosition, |
18 | new_name: &str, | 18 | new_name: &str, |
19 | ) -> Option<RangeInfo<SourceChange>> { | 19 | ) -> Option<RangeInfo<SourceChange>> { |
20 | let tokens = tokenize(new_name); | ||
21 | if tokens.len() != 1 | ||
22 | || (tokens[0].kind != SyntaxKind::IDENT && tokens[0].kind != SyntaxKind::UNDERSCORE) | ||
23 | { | ||
24 | return None; | ||
25 | } | ||
26 | |||
20 | let parse = db.parse(position.file_id); | 27 | let parse = db.parse(position.file_id); |
21 | if let Some((ast_name, ast_module)) = | 28 | if let Some((ast_name, ast_module)) = |
22 | find_name_and_module_at_offset(parse.tree().syntax(), position) | 29 | find_name_and_module_at_offset(parse.tree().syntax(), position) |
@@ -124,6 +131,49 @@ mod tests { | |||
124 | }; | 131 | }; |
125 | 132 | ||
126 | #[test] | 133 | #[test] |
134 | fn test_rename_to_underscore() { | ||
135 | test_rename( | ||
136 | r#" | ||
137 | fn main() { | ||
138 | let i<|> = 1; | ||
139 | }"#, | ||
140 | "_", | ||
141 | r#" | ||
142 | fn main() { | ||
143 | let _ = 1; | ||
144 | }"#, | ||
145 | ); | ||
146 | } | ||
147 | |||
148 | #[test] | ||
149 | fn test_rename_to_raw_identifier() { | ||
150 | test_rename( | ||
151 | r#" | ||
152 | fn main() { | ||
153 | let i<|> = 1; | ||
154 | }"#, | ||
155 | "r#fn", | ||
156 | r#" | ||
157 | fn main() { | ||
158 | let r#fn = 1; | ||
159 | }"#, | ||
160 | ); | ||
161 | } | ||
162 | |||
163 | #[test] | ||
164 | fn test_rename_to_invalid_identifier() { | ||
165 | let (analysis, position) = single_file_with_position( | ||
166 | " | ||
167 | fn main() { | ||
168 | let i<|> = 1; | ||
169 | }", | ||
170 | ); | ||
171 | let new_name = "invalid!"; | ||
172 | let source_change = analysis.rename(position, new_name).unwrap(); | ||
173 | assert!(source_change.is_none()); | ||
174 | } | ||
175 | |||
176 | #[test] | ||
127 | fn test_rename_for_local() { | 177 | fn test_rename_for_local() { |
128 | test_rename( | 178 | test_rename( |
129 | r#" | 179 | r#" |
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml index 21aef842c..41672eaff 100644 --- a/crates/ra_lsp_server/Cargo.toml +++ b/crates/ra_lsp_server/Cargo.toml | |||
@@ -13,7 +13,6 @@ relative-path = "1.0.0" | |||
13 | serde_json = "1.0.34" | 13 | serde_json = "1.0.34" |
14 | serde = { version = "1.0.83", features = ["derive"] } | 14 | serde = { version = "1.0.83", features = ["derive"] } |
15 | crossbeam-channel = "0.4" | 15 | crossbeam-channel = "0.4" |
16 | flexi_logger = "0.14.0" | ||
17 | log = "0.4.3" | 16 | log = "0.4.3" |
18 | lsp-types = { version = "0.61.0", features = ["proposed"] } | 17 | lsp-types = { version = "0.61.0", features = ["proposed"] } |
19 | rustc-hash = "1.0" | 18 | rustc-hash = "1.0" |
@@ -27,6 +26,7 @@ lsp-server = "0.3.0" | |||
27 | ra_project_model = { path = "../ra_project_model" } | 26 | ra_project_model = { path = "../ra_project_model" } |
28 | ra_prof = { path = "../ra_prof" } | 27 | ra_prof = { path = "../ra_prof" } |
29 | ra_vfs_glob = { path = "../ra_vfs_glob" } | 28 | ra_vfs_glob = { path = "../ra_vfs_glob" } |
29 | env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } | ||
30 | 30 | ||
31 | [dev-dependencies] | 31 | [dev-dependencies] |
32 | tempfile = "3" | 32 | tempfile = "3" |
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs index e13c8ca14..8076a7fa5 100644 --- a/crates/ra_lsp_server/src/main.rs +++ b/crates/ra_lsp_server/src/main.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | //! `ra_lsp_server` binary | 1 | //! `ra_lsp_server` binary |
2 | 2 | ||
3 | use flexi_logger::{Duplicate, Logger}; | ||
4 | use lsp_server::Connection; | 3 | use lsp_server::Connection; |
5 | use ra_lsp_server::{show_message, Result, ServerConfig}; | 4 | use ra_lsp_server::{show_message, Result, ServerConfig}; |
6 | use ra_prof; | 5 | use ra_prof; |
@@ -14,11 +13,7 @@ fn main() -> Result<()> { | |||
14 | fn setup_logging() -> Result<()> { | 13 | fn setup_logging() -> Result<()> { |
15 | std::env::set_var("RUST_BACKTRACE", "short"); | 14 | std::env::set_var("RUST_BACKTRACE", "short"); |
16 | 15 | ||
17 | let logger = Logger::with_env_or_str("error").duplicate_to_stderr(Duplicate::All); | 16 | env_logger::try_init()?; |
18 | match std::env::var("RA_LOG_DIR") { | ||
19 | Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, | ||
20 | _ => logger.start()?, | ||
21 | }; | ||
22 | 17 | ||
23 | ra_prof::set_filter(match std::env::var("RA_PROFILE") { | 18 | ra_prof::set_filter(match std::env::var("RA_PROFILE") { |
24 | Ok(spec) => ra_prof::Filter::from_spec(&spec), | 19 | Ok(spec) => ra_prof::Filter::from_spec(&spec), |
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index c81fa7f67..ca47ff5e1 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -480,8 +480,6 @@ pub fn handle_prepare_rename( | |||
480 | let _p = profile("handle_prepare_rename"); | 480 | let _p = profile("handle_prepare_rename"); |
481 | let position = params.try_conv_with(&world)?; | 481 | let position = params.try_conv_with(&world)?; |
482 | 482 | ||
483 | // We support renaming references like handle_rename does. | ||
484 | // In the future we may want to reject the renaming of things like keywords here too. | ||
485 | let optional_change = world.analysis().rename(position, "dummy")?; | 483 | let optional_change = world.analysis().rename(position, "dummy")?; |
486 | let range = match optional_change { | 484 | let range = match optional_change { |
487 | None => return Ok(None), | 485 | None => return Ok(None), |
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs index 2ba82ab05..29224cbe8 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/main.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs | |||
@@ -15,7 +15,6 @@ use tempfile::TempDir; | |||
15 | 15 | ||
16 | use crate::support::{project, Project}; | 16 | use crate::support::{project, Project}; |
17 | 17 | ||
18 | const LOG: &'static str = ""; | ||
19 | const PROFILE: &'static str = ""; | 18 | const PROFILE: &'static str = ""; |
20 | // const PROFILE: &'static str = "*@3>100"; | 19 | // const PROFILE: &'static str = "*@3>100"; |
21 | 20 | ||
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index 86073b57d..d5ea52fa9 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs | |||
@@ -7,7 +7,6 @@ use std::{ | |||
7 | }; | 7 | }; |
8 | 8 | ||
9 | use crossbeam_channel::{after, select, Receiver}; | 9 | use crossbeam_channel::{after, select, Receiver}; |
10 | use flexi_logger::Logger; | ||
11 | use lsp_server::{Connection, Message, Notification, Request}; | 10 | use lsp_server::{Connection, Message, Notification, Request}; |
12 | use lsp_types::{ | 11 | use lsp_types::{ |
13 | notification::{DidOpenTextDocument, Exit}, | 12 | notification::{DidOpenTextDocument, Exit}, |
@@ -53,7 +52,7 @@ impl<'a> Project<'a> { | |||
53 | let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); | 52 | let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); |
54 | static INIT: Once = Once::new(); | 53 | static INIT: Once = Once::new(); |
55 | INIT.call_once(|| { | 54 | INIT.call_once(|| { |
56 | let _ = Logger::with_env_or_str(crate::LOG).start().unwrap(); | 55 | let _ = env_logger::builder().is_test(true).try_init().unwrap(); |
57 | ra_prof::set_filter(if crate::PROFILE.is_empty() { | 56 | ra_prof::set_filter(if crate::PROFILE.is_empty() { |
58 | ra_prof::Filter::disabled() | 57 | ra_prof::Filter::disabled() |
59 | } else { | 58 | } else { |
diff --git a/docs/dev/README.md b/docs/dev/README.md index 0f64d7e5f..2f6215d6b 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -124,9 +124,8 @@ Logging is done by both rust-analyzer and VS Code, so it might be tricky to | |||
124 | figure out where logs go. | 124 | figure out where logs go. |
125 | 125 | ||
126 | Inside rust-analyzer, we use the standard `log` crate for logging, and | 126 | Inside rust-analyzer, we use the standard `log` crate for logging, and |
127 | `flexi_logger` for logging frotend. By default, log goes to stderr (the same as | 127 | `env_logger` for logging frontend. By default, log goes to stderr, but the |
128 | with `env_logger`), but the stderr itself is processed by VS Code. To mirror | 128 | stderr itself is processed by VS Code. |
129 | logs to a `./log` directory, set `RA_LOG_DIR=1` environmental variable. | ||
130 | 129 | ||
131 | To see stderr in the running VS Code instance, go to the "Output" tab of the | 130 | To see stderr in the running VS Code instance, go to the "Output" tab of the |
132 | panel and select `rust-analyzer`. This shows `eprintln!` as well. Note that | 131 | panel and select `rust-analyzer`. This shows `eprintln!` as well. Note that |