diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-15 13:35:12 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-08-15 13:35:12 +0100 |
commit | 9b024b685bf486c031cd72374c10955d6048ab63 (patch) | |
tree | a4a4761312b0ff12165e5b1a7155ccead4e09d71 | |
parent | 5ed6a13a2c81f24bd12cc74332f7e94301c73980 (diff) | |
parent | 1700541e0056691946f7274d7d2e7e6b50300313 (diff) |
Merge #1445
1445: Use the new "durability" infrastructure from salsa r=matklad a=matklad
Based on https://github.com/nikomatsakis/salsa/tree/durability
Durability allows us to skip *validation* work for sysroot and crates.io libraries, which massively speeds up some workloads
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | Cargo.lock | 64 | ||||
-rw-r--r-- | crates/ra_cli/src/analysis_bench.rs | 38 | ||||
-rw-r--r-- | crates/ra_db/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/db.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 54 | ||||
-rw-r--r-- | crates/ra_ide_api/src/change.rs | 53 | ||||
-rw-r--r-- | crates/ra_ide_api/src/db.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/lib.rs | 3 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/lib.rs | 1 |
10 files changed, 166 insertions, 68 deletions
diff --git a/Cargo.lock b/Cargo.lock index 365b77f41..572e2f424 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -298,6 +298,19 @@ dependencies = [ | |||
298 | ] | 298 | ] |
299 | 299 | ||
300 | [[package]] | 300 | [[package]] |
301 | name = "crossbeam" | ||
302 | version = "0.7.2" | ||
303 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
304 | dependencies = [ | ||
305 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
306 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", | ||
307 | "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", | ||
308 | "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
309 | "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
310 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
311 | ] | ||
312 | |||
313 | [[package]] | ||
301 | name = "crossbeam-channel" | 314 | name = "crossbeam-channel" |
302 | version = "0.3.9" | 315 | version = "0.3.9" |
303 | source = "registry+https://github.com/rust-lang/crates.io-index" | 316 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -315,6 +328,15 @@ dependencies = [ | |||
315 | ] | 328 | ] |
316 | 329 | ||
317 | [[package]] | 330 | [[package]] |
331 | name = "crossbeam-deque" | ||
332 | version = "0.7.1" | ||
333 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
334 | dependencies = [ | ||
335 | "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
336 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
337 | ] | ||
338 | |||
339 | [[package]] | ||
318 | name = "crossbeam-epoch" | 340 | name = "crossbeam-epoch" |
319 | version = "0.7.2" | 341 | version = "0.7.2" |
320 | source = "registry+https://github.com/rust-lang/crates.io-index" | 342 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -360,7 +382,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
360 | dependencies = [ | 382 | dependencies = [ |
361 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 383 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
362 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 384 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
363 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 385 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
364 | ] | 386 | ] |
365 | 387 | ||
366 | [[package]] | 388 | [[package]] |
@@ -450,7 +472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
450 | dependencies = [ | 472 | dependencies = [ |
451 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 473 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
452 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 474 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
453 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 475 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
454 | "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", | 476 | "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", |
455 | ] | 477 | ] |
456 | 478 | ||
@@ -910,7 +932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
910 | dependencies = [ | 932 | dependencies = [ |
911 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 933 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
912 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 934 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
913 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 935 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
914 | ] | 936 | ] |
915 | 937 | ||
916 | [[package]] | 938 | [[package]] |
@@ -1030,7 +1052,7 @@ dependencies = [ | |||
1030 | "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1052 | "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1031 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1053 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1032 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 1054 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1033 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 1055 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
1034 | ] | 1056 | ] |
1035 | 1057 | ||
1036 | [[package]] | 1058 | [[package]] |
@@ -1064,7 +1086,7 @@ dependencies = [ | |||
1064 | "pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1086 | "pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1065 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1087 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1066 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 1088 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1067 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 1089 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
1068 | ] | 1090 | ] |
1069 | 1091 | ||
1070 | [[package]] | 1092 | [[package]] |
@@ -1098,7 +1120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1098 | dependencies = [ | 1120 | dependencies = [ |
1099 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1121 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1100 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 1122 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1101 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 1123 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
1102 | ] | 1124 | ] |
1103 | 1125 | ||
1104 | [[package]] | 1126 | [[package]] |
@@ -1197,7 +1219,7 @@ dependencies = [ | |||
1197 | "ra_syntax 0.1.0", | 1219 | "ra_syntax 0.1.0", |
1198 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1220 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1199 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1221 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1200 | "salsa 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1222 | "salsa 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1201 | ] | 1223 | ] |
1202 | 1224 | ||
1203 | [[package]] | 1225 | [[package]] |
@@ -1658,29 +1680,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1658 | 1680 | ||
1659 | [[package]] | 1681 | [[package]] |
1660 | name = "salsa" | 1682 | name = "salsa" |
1661 | version = "0.12.3" | 1683 | version = "0.13.0" |
1662 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1684 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1663 | dependencies = [ | 1685 | dependencies = [ |
1686 | "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1664 | "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", | 1687 | "derive-new 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", |
1665 | "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1688 | "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1666 | "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1667 | "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1668 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1689 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1669 | "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1690 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1691 | "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1670 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1692 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1671 | "salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1693 | "salsa-macros 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1672 | "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", | 1694 | "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", |
1673 | ] | 1695 | ] |
1674 | 1696 | ||
1675 | [[package]] | 1697 | [[package]] |
1676 | name = "salsa-macros" | 1698 | name = "salsa-macros" |
1677 | version = "0.12.1" | 1699 | version = "0.13.0" |
1678 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1700 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1679 | dependencies = [ | 1701 | dependencies = [ |
1680 | "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1702 | "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1681 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1703 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1682 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 1704 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1683 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 1705 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
1684 | ] | 1706 | ] |
1685 | 1707 | ||
1686 | [[package]] | 1708 | [[package]] |
@@ -1725,7 +1747,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1725 | dependencies = [ | 1747 | dependencies = [ |
1726 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1748 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1727 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 1749 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1728 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 1750 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
1729 | ] | 1751 | ] |
1730 | 1752 | ||
1731 | [[package]] | 1753 | [[package]] |
@@ -1809,7 +1831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1809 | 1831 | ||
1810 | [[package]] | 1832 | [[package]] |
1811 | name = "syn" | 1833 | name = "syn" |
1812 | version = "0.15.42" | 1834 | version = "0.15.43" |
1813 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1835 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1814 | dependencies = [ | 1836 | dependencies = [ |
1815 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1837 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1824,7 +1846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1824 | dependencies = [ | 1846 | dependencies = [ |
1825 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", | 1847 | "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", |
1826 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", | 1848 | "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1827 | "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", | 1849 | "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", |
1828 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1850 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1829 | ] | 1851 | ] |
1830 | 1852 | ||
@@ -2169,8 +2191,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2169 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 2191 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
2170 | "checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" | 2192 | "checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" |
2171 | "checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035" | 2193 | "checksum cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "33f07976bb6821459632d7a18d97ccca005cb5c552f251f822c7c1781c1d7035" |
2194 | "checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" | ||
2172 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" | 2195 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" |
2173 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" | 2196 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" |
2197 | "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" | ||
2174 | "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" | 2198 | "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" |
2175 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" | 2199 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" |
2176 | "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" | 2200 | "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" |
@@ -2300,8 +2324,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2300 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 2324 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
2301 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 2325 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
2302 | "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" | 2326 | "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" |
2303 | "checksum salsa 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2891cd628406e8a0ca714b827511de1bff76f796e3382cc72a3de732ccad5aea" | 2327 | "checksum salsa 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3265a2a9bbd384bd2a9f9511c2c18fb41f62c412516052e8934517dc8ff64f1" |
2304 | "checksum salsa-macros 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b7f1e25ca2b995bdf032946174929d62156ffd57abd7ff88dc6f9bdeb5ac0c59" | 2328 | "checksum salsa-macros 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "377ce29c5660dcc5c3f66660a7e49940b8328e3d940255ef9d4c2be1f7b474a9" |
2305 | "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" | 2329 | "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" |
2306 | "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" | 2330 | "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" |
2307 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" | 2331 | "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" |
@@ -2318,7 +2342,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2318 | "checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b" | 2342 | "checksum stacker 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fb79482f57cf598af52094ec4cc3b3c42499d3ce5bd426f2ac41515b7e57404b" |
2319 | "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" | 2343 | "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" |
2320 | "checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" | 2344 | "checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" |
2321 | "checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" | 2345 | "checksum syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ee06ea4b620ab59a2267c6b48be16244a3389f8bfa0986bdd15c35b890b00af3" |
2322 | "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" | 2346 | "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" |
2323 | "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" | 2347 | "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" |
2324 | "checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" | 2348 | "checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" |
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 5e9d0c16d..9e76bcebf 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs | |||
@@ -1,10 +1,14 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | path::{Path, PathBuf}, | 2 | path::{Path, PathBuf}, |
3 | sync::Arc, | ||
3 | time::Instant, | 4 | time::Instant, |
4 | }; | 5 | }; |
5 | 6 | ||
6 | use ra_db::{salsa::Database, SourceDatabase}; | 7 | use ra_db::{ |
7 | use ra_ide_api::{Analysis, AnalysisHost, FilePosition, LineCol}; | 8 | salsa::{Database, Durability}, |
9 | FileId, SourceDatabase, | ||
10 | }; | ||
11 | use ra_ide_api::{Analysis, AnalysisChange, AnalysisHost, FilePosition, LineCol}; | ||
8 | 12 | ||
9 | use crate::Result; | 13 | use crate::Result; |
10 | 14 | ||
@@ -16,7 +20,7 @@ pub(crate) enum Op { | |||
16 | pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | 20 | pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { |
17 | let start = Instant::now(); | 21 | let start = Instant::now(); |
18 | eprint!("loading: "); | 22 | eprint!("loading: "); |
19 | let (host, roots) = ra_batch::load_cargo(path)?; | 23 | let (mut host, roots) = ra_batch::load_cargo(path)?; |
20 | let db = host.raw_database(); | 24 | let db = host.raw_database(); |
21 | eprintln!("{:?}\n", start.elapsed()); | 25 | eprintln!("{:?}\n", start.elapsed()); |
22 | 26 | ||
@@ -44,7 +48,7 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
44 | 48 | ||
45 | match op { | 49 | match op { |
46 | Op::Highlight { .. } => { | 50 | Op::Highlight { .. } => { |
47 | let res = do_work(&host, |analysis| { | 51 | let res = do_work(&mut host, file_id, |analysis| { |
48 | analysis.diagnostics(file_id).unwrap(); | 52 | analysis.diagnostics(file_id).unwrap(); |
49 | analysis.highlight_as_html(file_id, false).unwrap() | 53 | analysis.highlight_as_html(file_id, false).unwrap() |
50 | }); | 54 | }); |
@@ -59,7 +63,7 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
59 | .offset(LineCol { line, col_utf16: column }); | 63 | .offset(LineCol { line, col_utf16: column }); |
60 | let file_postion = FilePosition { file_id, offset }; | 64 | let file_postion = FilePosition { file_id, offset }; |
61 | 65 | ||
62 | let res = do_work(&host, |analysis| analysis.completions(file_postion)); | 66 | let res = do_work(&mut host, file_id, |analysis| analysis.completions(file_postion)); |
63 | if verbose { | 67 | if verbose { |
64 | println!("\n{:#?}", res); | 68 | println!("\n{:#?}", res); |
65 | } | 69 | } |
@@ -68,7 +72,7 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
68 | Ok(()) | 72 | Ok(()) |
69 | } | 73 | } |
70 | 74 | ||
71 | fn do_work<F: Fn(&Analysis) -> T, T>(host: &AnalysisHost, work: F) -> T { | 75 | fn do_work<F: Fn(&Analysis) -> T, T>(host: &mut AnalysisHost, file_id: FileId, work: F) -> T { |
72 | { | 76 | { |
73 | let start = Instant::now(); | 77 | let start = Instant::now(); |
74 | eprint!("from scratch: "); | 78 | eprint!("from scratch: "); |
@@ -84,7 +88,27 @@ fn do_work<F: Fn(&Analysis) -> T, T>(host: &AnalysisHost, work: F) -> T { | |||
84 | { | 88 | { |
85 | let start = Instant::now(); | 89 | let start = Instant::now(); |
86 | eprint!("trivial change: "); | 90 | eprint!("trivial change: "); |
87 | host.raw_database().salsa_runtime().next_revision(); | 91 | host.raw_database().salsa_runtime().synthetic_write(Durability::LOW); |
92 | work(&host.analysis()); | ||
93 | eprintln!("{:?}", start.elapsed()); | ||
94 | } | ||
95 | { | ||
96 | let start = Instant::now(); | ||
97 | eprint!("comment change: "); | ||
98 | { | ||
99 | let mut text = host.analysis().file_text(file_id).unwrap().to_string(); | ||
100 | text.push_str("\n/* Hello world */\n"); | ||
101 | let mut change = AnalysisChange::new(); | ||
102 | change.change_file(file_id, Arc::new(text)); | ||
103 | host.apply_change(change); | ||
104 | } | ||
105 | work(&host.analysis()); | ||
106 | eprintln!("{:?}", start.elapsed()); | ||
107 | } | ||
108 | { | ||
109 | let start = Instant::now(); | ||
110 | eprint!("const change: "); | ||
111 | host.raw_database().salsa_runtime().synthetic_write(Durability::HIGH); | ||
88 | let res = work(&host.analysis()); | 112 | let res = work(&host.analysis()); |
89 | eprintln!("{:?}", start.elapsed()); | 113 | eprintln!("{:?}", start.elapsed()); |
90 | res | 114 | res |
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml index 7a13c247b..2fac07bc5 100644 --- a/crates/ra_db/Cargo.toml +++ b/crates/ra_db/Cargo.toml | |||
@@ -5,7 +5,7 @@ version = "0.1.0" | |||
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | 6 | ||
7 | [dependencies] | 7 | [dependencies] |
8 | salsa = "0.12.3" | 8 | salsa = "0.13.0" |
9 | relative-path = "0.4.0" | 9 | relative-path = "0.4.0" |
10 | rustc-hash = "1.0" | 10 | rustc-hash = "1.0" |
11 | 11 | ||
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index 358365176..7b7974f5b 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use parking_lot::Mutex; | ||
4 | use ra_db::{salsa, SourceDatabase}; | 3 | use ra_db::{salsa, SourceDatabase}; |
5 | use ra_syntax::{ast, Parse, SmolStr, SyntaxNode}; | 4 | use ra_syntax::{ast, Parse, SmolStr, SyntaxNode}; |
6 | 5 | ||
@@ -147,6 +146,7 @@ pub trait DefDatabase: InternDatabase { | |||
147 | } | 146 | } |
148 | 147 | ||
149 | #[salsa::query_group(HirDatabaseStorage)] | 148 | #[salsa::query_group(HirDatabaseStorage)] |
149 | #[salsa::requires(salsa::Database)] | ||
150 | pub trait HirDatabase: DefDatabase + AstDatabase { | 150 | pub trait HirDatabase: DefDatabase + AstDatabase { |
151 | #[salsa::invoke(ExprScopes::expr_scopes_query)] | 151 | #[salsa::invoke(ExprScopes::expr_scopes_query)] |
152 | fn expr_scopes(&self, def: DefWithBody) -> Arc<ExprScopes>; | 152 | fn expr_scopes(&self, def: DefWithBody) -> Arc<ExprScopes>; |
@@ -187,11 +187,10 @@ pub trait HirDatabase: DefDatabase + AstDatabase { | |||
187 | /// This provides the Chalk trait solver instance. Because Chalk always | 187 | /// This provides the Chalk trait solver instance. Because Chalk always |
188 | /// works from a specific crate, this query is keyed on the crate; and | 188 | /// works from a specific crate, this query is keyed on the crate; and |
189 | /// because Chalk does its own internal caching, the solver is wrapped in a | 189 | /// because Chalk does its own internal caching, the solver is wrapped in a |
190 | /// Mutex and the query is marked volatile, to make sure the cached state is | 190 | /// Mutex and the query does an untracked read internally, to make sure the |
191 | /// thrown away when input facts change. | 191 | /// cached state is thrown away when input facts change. |
192 | #[salsa::invoke(crate::ty::traits::trait_solver_query)] | 192 | #[salsa::invoke(crate::ty::traits::trait_solver_query)] |
193 | #[salsa::volatile] | 193 | fn trait_solver(&self, krate: Crate) -> crate::ty::traits::TraitSolver; |
194 | fn trait_solver(&self, krate: Crate) -> Arc<Mutex<crate::ty::traits::Solver>>; | ||
195 | 194 | ||
196 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] | 195 | #[salsa::invoke(crate::ty::traits::chalk::associated_ty_data_query)] |
197 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; | 196 | fn associated_ty_data(&self, id: chalk_ir::TypeId) -> Arc<chalk_rust_ir::AssociatedTyDatum>; |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 081974e2b..018fcd096 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | #![recursion_limit = "512"] | ||
2 | |||
1 | //! HIR (previously known as descriptors) provides a high-level object oriented | 3 | //! HIR (previously known as descriptors) provides a high-level object oriented |
2 | //! access to Rust code. | 4 | //! access to Rust code. |
3 | //! | 5 | //! |
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index fde5d8a47..b634f0b79 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -4,6 +4,7 @@ use std::sync::Arc; | |||
4 | use chalk_ir::cast::Cast; | 4 | use chalk_ir::cast::Cast; |
5 | use log::debug; | 5 | use log::debug; |
6 | use parking_lot::Mutex; | 6 | use parking_lot::Mutex; |
7 | use ra_db::salsa; | ||
7 | use ra_prof::profile; | 8 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | 9 | use rustc_hash::FxHashSet; |
9 | 10 | ||
@@ -14,7 +15,34 @@ use self::chalk::{from_chalk, ToChalk}; | |||
14 | 15 | ||
15 | pub(crate) mod chalk; | 16 | pub(crate) mod chalk; |
16 | 17 | ||
17 | pub(crate) type Solver = chalk_solve::Solver; | 18 | #[derive(Debug, Clone)] |
19 | pub struct TraitSolver { | ||
20 | krate: Crate, | ||
21 | inner: Arc<Mutex<chalk_solve::Solver>>, | ||
22 | } | ||
23 | |||
24 | /// We need eq for salsa | ||
25 | impl PartialEq for TraitSolver { | ||
26 | fn eq(&self, other: &TraitSolver) -> bool { | ||
27 | Arc::ptr_eq(&self.inner, &other.inner) | ||
28 | } | ||
29 | } | ||
30 | |||
31 | impl Eq for TraitSolver {} | ||
32 | |||
33 | impl TraitSolver { | ||
34 | fn solve( | ||
35 | &self, | ||
36 | db: &impl HirDatabase, | ||
37 | goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal>>, | ||
38 | ) -> Option<chalk_solve::Solution> { | ||
39 | let context = ChalkContext { db, krate: self.krate }; | ||
40 | debug!("solve goal: {:?}", goal); | ||
41 | let solution = self.inner.lock().solve(&context, goal); | ||
42 | debug!("solve({:?}) => {:?}", goal, solution); | ||
43 | solution | ||
44 | } | ||
45 | } | ||
18 | 46 | ||
19 | /// This controls the maximum size of types Chalk considers. If we set this too | 47 | /// This controls the maximum size of types Chalk considers. If we set this too |
20 | /// high, we can run into slow edge cases; if we set it too low, Chalk won't | 48 | /// high, we can run into slow edge cases; if we set it too low, Chalk won't |
@@ -27,11 +55,15 @@ struct ChalkContext<'a, DB> { | |||
27 | krate: Crate, | 55 | krate: Crate, |
28 | } | 56 | } |
29 | 57 | ||
30 | pub(crate) fn trait_solver_query(_db: &impl HirDatabase, _krate: Crate) -> Arc<Mutex<Solver>> { | 58 | pub(crate) fn trait_solver_query( |
59 | db: &(impl HirDatabase + salsa::Database), | ||
60 | krate: Crate, | ||
61 | ) -> TraitSolver { | ||
62 | db.salsa_runtime().report_untracked_read(); | ||
31 | // krate parameter is just so we cache a unique solver per crate | 63 | // krate parameter is just so we cache a unique solver per crate |
32 | let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE }; | 64 | let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE }; |
33 | debug!("Creating new solver for crate {:?}", _krate); | 65 | debug!("Creating new solver for crate {:?}", krate); |
34 | Arc::new(Mutex::new(solver_choice.into_solver())) | 66 | TraitSolver { krate, inner: Arc::new(Mutex::new(solver_choice.into_solver())) } |
35 | } | 67 | } |
36 | 68 | ||
37 | /// Collects impls for the given trait in the whole dependency tree of `krate`. | 69 | /// Collects impls for the given trait in the whole dependency tree of `krate`. |
@@ -54,18 +86,6 @@ pub(crate) fn impls_for_trait_query( | |||
54 | impls.into_iter().collect::<Vec<_>>().into() | 86 | impls.into_iter().collect::<Vec<_>>().into() |
55 | } | 87 | } |
56 | 88 | ||
57 | fn solve( | ||
58 | db: &impl HirDatabase, | ||
59 | krate: Crate, | ||
60 | goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal>>, | ||
61 | ) -> Option<chalk_solve::Solution> { | ||
62 | let context = ChalkContext { db, krate }; | ||
63 | let solver = db.trait_solver(krate); | ||
64 | let solution = solver.lock().solve(&context, goal); | ||
65 | debug!("solve({:?}) => {:?}", goal, solution); | ||
66 | solution | ||
67 | } | ||
68 | |||
69 | /// A set of clauses that we assume to be true. E.g. if we are inside this function: | 89 | /// A set of clauses that we assume to be true. E.g. if we are inside this function: |
70 | /// ```rust | 90 | /// ```rust |
71 | /// fn foo<T: Default>(t: T) {} | 91 | /// fn foo<T: Default>(t: T) {} |
@@ -127,7 +147,7 @@ pub(crate) fn trait_solve_query( | |||
127 | // We currently don't deal with universes (I think / hope they're not yet | 147 | // We currently don't deal with universes (I think / hope they're not yet |
128 | // relevant for our use cases?) | 148 | // relevant for our use cases?) |
129 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; | 149 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; |
130 | let solution = solve(db, krate, &u_canonical); | 150 | let solution = db.trait_solver(krate).solve(db, &u_canonical); |
131 | solution.map(|solution| solution_from_chalk(db, solution)) | 151 | solution.map(|solution| solution_from_chalk(db, solution)) |
132 | } | 152 | } |
133 | 153 | ||
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs index 147d2b21d..0234c572d 100644 --- a/crates/ra_ide_api/src/change.rs +++ b/crates/ra_ide_api/src/change.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::{fmt, sync::Arc, time}; | 1 | use std::{fmt, sync::Arc, time}; |
2 | 2 | ||
3 | use ra_db::{ | 3 | use ra_db::{ |
4 | salsa::{Database, SweepStrategy}, | 4 | salsa::{Database, Durability, SweepStrategy}, |
5 | CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId, | 5 | CrateGraph, FileId, SourceDatabase, SourceRoot, SourceRootId, |
6 | }; | 6 | }; |
7 | use ra_prof::{memory_usage, profile, Bytes}; | 7 | use ra_prof::{memory_usage, profile, Bytes}; |
@@ -155,54 +155,71 @@ impl RootDatabase { | |||
155 | log::info!("apply_change {:?}", change); | 155 | log::info!("apply_change {:?}", change); |
156 | { | 156 | { |
157 | let _p = profile("RootDatabase::apply_change/cancellation"); | 157 | let _p = profile("RootDatabase::apply_change/cancellation"); |
158 | self.salsa_runtime().next_revision(); | 158 | self.salsa_runtime().synthetic_write(Durability::LOW); |
159 | } | 159 | } |
160 | if !change.new_roots.is_empty() { | 160 | if !change.new_roots.is_empty() { |
161 | let mut local_roots = Vec::clone(&self.local_roots()); | 161 | let mut local_roots = Vec::clone(&self.local_roots()); |
162 | for (root_id, is_local) in change.new_roots { | 162 | for (root_id, is_local) in change.new_roots { |
163 | let root = if is_local { SourceRoot::new() } else { SourceRoot::new_library() }; | 163 | let root = if is_local { SourceRoot::new() } else { SourceRoot::new_library() }; |
164 | self.set_source_root(root_id, Arc::new(root)); | 164 | let durability = durability(&root); |
165 | self.set_source_root_with_durability(root_id, Arc::new(root), durability); | ||
165 | if is_local { | 166 | if is_local { |
166 | local_roots.push(root_id); | 167 | local_roots.push(root_id); |
167 | } | 168 | } |
168 | } | 169 | } |
169 | self.set_local_roots(Arc::new(local_roots)); | 170 | self.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH); |
170 | } | 171 | } |
171 | 172 | ||
172 | for (root_id, root_change) in change.roots_changed { | 173 | for (root_id, root_change) in change.roots_changed { |
173 | self.apply_root_change(root_id, root_change); | 174 | self.apply_root_change(root_id, root_change); |
174 | } | 175 | } |
175 | for (file_id, text) in change.files_changed { | 176 | for (file_id, text) in change.files_changed { |
176 | self.set_file_text(file_id, text) | 177 | let source_root_id = self.file_source_root(file_id); |
178 | let source_root = self.source_root(source_root_id); | ||
179 | let durability = durability(&source_root); | ||
180 | self.set_file_text_with_durability(file_id, text, durability) | ||
177 | } | 181 | } |
178 | if !change.libraries_added.is_empty() { | 182 | if !change.libraries_added.is_empty() { |
179 | let mut libraries = Vec::clone(&self.library_roots()); | 183 | let mut libraries = Vec::clone(&self.library_roots()); |
180 | for library in change.libraries_added { | 184 | for library in change.libraries_added { |
181 | libraries.push(library.root_id); | 185 | libraries.push(library.root_id); |
182 | self.set_source_root(library.root_id, Default::default()); | 186 | self.set_source_root_with_durability( |
183 | self.set_constant_library_symbols(library.root_id, Arc::new(library.symbol_index)); | 187 | library.root_id, |
188 | Default::default(), | ||
189 | Durability::HIGH, | ||
190 | ); | ||
191 | self.set_library_symbols_with_durability( | ||
192 | library.root_id, | ||
193 | Arc::new(library.symbol_index), | ||
194 | Durability::HIGH, | ||
195 | ); | ||
184 | self.apply_root_change(library.root_id, library.root_change); | 196 | self.apply_root_change(library.root_id, library.root_change); |
185 | } | 197 | } |
186 | self.set_library_roots(Arc::new(libraries)); | 198 | self.set_library_roots_with_durability(Arc::new(libraries), Durability::HIGH); |
187 | } | 199 | } |
188 | if let Some(crate_graph) = change.crate_graph { | 200 | if let Some(crate_graph) = change.crate_graph { |
189 | self.set_crate_graph(Arc::new(crate_graph)) | 201 | self.set_crate_graph_with_durability(Arc::new(crate_graph), Durability::HIGH) |
190 | } | 202 | } |
191 | } | 203 | } |
192 | 204 | ||
193 | fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) { | 205 | fn apply_root_change(&mut self, root_id: SourceRootId, root_change: RootChange) { |
194 | let mut source_root = SourceRoot::clone(&self.source_root(root_id)); | 206 | let mut source_root = SourceRoot::clone(&self.source_root(root_id)); |
207 | let durability = durability(&source_root); | ||
195 | for add_file in root_change.added { | 208 | for add_file in root_change.added { |
196 | self.set_file_text(add_file.file_id, add_file.text); | 209 | self.set_file_text_with_durability(add_file.file_id, add_file.text, durability); |
197 | self.set_file_relative_path(add_file.file_id, add_file.path.clone()); | 210 | self.set_file_relative_path_with_durability( |
198 | self.set_file_source_root(add_file.file_id, root_id); | 211 | add_file.file_id, |
212 | add_file.path.clone(), | ||
213 | durability, | ||
214 | ); | ||
215 | self.set_file_source_root_with_durability(add_file.file_id, root_id, durability); | ||
199 | source_root.files.insert(add_file.path, add_file.file_id); | 216 | source_root.files.insert(add_file.path, add_file.file_id); |
200 | } | 217 | } |
201 | for remove_file in root_change.removed { | 218 | for remove_file in root_change.removed { |
202 | self.set_file_text(remove_file.file_id, Default::default()); | 219 | self.set_file_text_with_durability(remove_file.file_id, Default::default(), durability); |
203 | source_root.files.remove(&remove_file.path); | 220 | source_root.files.remove(&remove_file.path); |
204 | } | 221 | } |
205 | self.set_source_root(root_id, Arc::new(source_root)); | 222 | self.set_source_root_with_durability(root_id, Arc::new(source_root), durability); |
206 | } | 223 | } |
207 | 224 | ||
208 | pub(crate) fn maybe_collect_garbage(&mut self) { | 225 | pub(crate) fn maybe_collect_garbage(&mut self) { |
@@ -308,3 +325,11 @@ impl RootDatabase { | |||
308 | acc | 325 | acc |
309 | } | 326 | } |
310 | } | 327 | } |
328 | |||
329 | fn durability(source_root: &SourceRoot) -> Durability { | ||
330 | if source_root.is_library { | ||
331 | Durability::HIGH | ||
332 | } else { | ||
333 | Durability::LOW | ||
334 | } | ||
335 | } | ||
diff --git a/crates/ra_ide_api/src/db.rs b/crates/ra_ide_api/src/db.rs index 44216b045..fc8252e4b 100644 --- a/crates/ra_ide_api/src/db.rs +++ b/crates/ra_ide_api/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::{sync::Arc, time}; | 1 | use std::{sync::Arc, time}; |
2 | 2 | ||
3 | use ra_db::{ | 3 | use ra_db::{ |
4 | salsa::{self, Database}, | 4 | salsa::{self, Database, Durability}, |
5 | Canceled, CheckCanceled, FileId, SourceDatabase, | 5 | Canceled, CheckCanceled, FileId, SourceDatabase, |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -57,9 +57,9 @@ impl RootDatabase { | |||
57 | last_gc: time::Instant::now(), | 57 | last_gc: time::Instant::now(), |
58 | last_gc_check: time::Instant::now(), | 58 | last_gc_check: time::Instant::now(), |
59 | }; | 59 | }; |
60 | db.set_crate_graph(Default::default()); | 60 | db.set_crate_graph_with_durability(Default::default(), Durability::HIGH); |
61 | db.set_local_roots(Default::default()); | 61 | db.set_local_roots_with_durability(Default::default(), Durability::HIGH); |
62 | db.set_library_roots(Default::default()); | 62 | db.set_library_roots_with_durability(Default::default(), Durability::HIGH); |
63 | let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP); | 63 | let lru_capacity = lru_capacity.unwrap_or(ra_db::DEFAULT_LRU_CAP); |
64 | db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity); | 64 | db.query_mut(ra_db::ParseQuery).set_lru_capacity(lru_capacity); |
65 | db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity); | 65 | db.query_mut(hir::db::ParseMacroQuery).set_lru_capacity(lru_capacity); |
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs index edb646c11..fa4ae4379 100644 --- a/crates/ra_ide_api/src/lib.rs +++ b/crates/ra_ide_api/src/lib.rs | |||
@@ -281,6 +281,9 @@ impl AnalysisHost { | |||
281 | pub fn raw_database(&self) -> &(impl hir::db::HirDatabase + salsa::Database) { | 281 | pub fn raw_database(&self) -> &(impl hir::db::HirDatabase + salsa::Database) { |
282 | &self.db | 282 | &self.db |
283 | } | 283 | } |
284 | pub fn raw_database_mut(&mut self) -> &mut (impl hir::db::HirDatabase + salsa::Database) { | ||
285 | &mut self.db | ||
286 | } | ||
284 | } | 287 | } |
285 | 288 | ||
286 | /// Analysis is a snapshot of a world state at a moment in time. It is the main | 289 | /// Analysis is a snapshot of a world state at a moment in time. It is the main |
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs index 795f86383..ca388e472 100644 --- a/crates/ra_lsp_server/src/lib.rs +++ b/crates/ra_lsp_server/src/lib.rs | |||
@@ -1,3 +1,4 @@ | |||
1 | #![recursion_limit = "512"] | ||
1 | mod caps; | 2 | mod caps; |
2 | mod cargo_target_spec; | 3 | mod cargo_target_spec; |
3 | mod conv; | 4 | mod conv; |