diff options
-rw-r--r-- | Cargo.lock | 133 | ||||
-rw-r--r-- | crates/hir_def/src/path.rs | 2 | ||||
-rw-r--r-- | crates/hir_expand/src/hygiene.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/references.rs | 20 | ||||
-rw-r--r-- | crates/mbe/src/syntax_bridge.rs | 4 | ||||
-rw-r--r-- | crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | 8 | ||||
-rw-r--r-- | crates/profile/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/profile/src/memory_usage.rs | 7 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 6 | ||||
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 4 | ||||
-rw-r--r-- | xtask/src/install.rs | 2 | ||||
-rw-r--r-- | xtask/src/main.rs | 12 |
12 files changed, 158 insertions, 44 deletions
diff --git a/Cargo.lock b/Cargo.lock index aac473191..35713a0c4 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -26,9 +26,9 @@ dependencies = [ | |||
26 | 26 | ||
27 | [[package]] | 27 | [[package]] |
28 | name = "anyhow" | 28 | name = "anyhow" |
29 | version = "1.0.37" | 29 | version = "1.0.38" |
30 | source = "registry+https://github.com/rust-lang/crates.io-index" | 30 | source = "registry+https://github.com/rust-lang/crates.io-index" |
31 | checksum = "ee67c11feeac938fae061b232e38e0b6d94f97a9df10e6271319325ac4c56a86" | 31 | checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" |
32 | 32 | ||
33 | [[package]] | 33 | [[package]] |
34 | name = "anymap" | 34 | name = "anymap" |
@@ -118,9 +118,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" | |||
118 | 118 | ||
119 | [[package]] | 119 | [[package]] |
120 | name = "byteorder" | 120 | name = "byteorder" |
121 | version = "1.3.4" | 121 | version = "1.4.2" |
122 | source = "registry+https://github.com/rust-lang/crates.io-index" | 122 | source = "registry+https://github.com/rust-lang/crates.io-index" |
123 | checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" | 123 | checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" |
124 | 124 | ||
125 | [[package]] | 125 | [[package]] |
126 | name = "cargo-platform" | 126 | name = "cargo-platform" |
@@ -133,9 +133,9 @@ dependencies = [ | |||
133 | 133 | ||
134 | [[package]] | 134 | [[package]] |
135 | name = "cargo_metadata" | 135 | name = "cargo_metadata" |
136 | version = "0.12.2" | 136 | version = "0.12.3" |
137 | source = "registry+https://github.com/rust-lang/crates.io-index" | 137 | source = "registry+https://github.com/rust-lang/crates.io-index" |
138 | checksum = "11a47b6286279a9998588ef7050d1ebc2500c69892a557c90fe5d071c64415dc" | 138 | checksum = "7714a157da7991e23d90686b9524b9e12e0407a108647f52e9328f4b3d51ac7f" |
139 | dependencies = [ | 139 | dependencies = [ |
140 | "cargo-platform", | 140 | "cargo-platform", |
141 | "semver", | 141 | "semver", |
@@ -269,9 +269,9 @@ dependencies = [ | |||
269 | 269 | ||
270 | [[package]] | 270 | [[package]] |
271 | name = "const_fn" | 271 | name = "const_fn" |
272 | version = "0.4.4" | 272 | version = "0.4.5" |
273 | source = "registry+https://github.com/rust-lang/crates.io-index" | 273 | source = "registry+https://github.com/rust-lang/crates.io-index" |
274 | checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826" | 274 | checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" |
275 | 275 | ||
276 | [[package]] | 276 | [[package]] |
277 | name = "crc32fast" | 277 | name = "crc32fast" |
@@ -449,6 +449,12 @@ dependencies = [ | |||
449 | ] | 449 | ] |
450 | 450 | ||
451 | [[package]] | 451 | [[package]] |
452 | name = "fs_extra" | ||
453 | version = "1.2.0" | ||
454 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
455 | checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" | ||
456 | |||
457 | [[package]] | ||
452 | name = "fsevent" | 458 | name = "fsevent" |
453 | version = "2.0.2" | 459 | version = "2.0.2" |
454 | source = "registry+https://github.com/rust-lang/crates.io-index" | 460 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -518,9 +524,9 @@ dependencies = [ | |||
518 | 524 | ||
519 | [[package]] | 525 | [[package]] |
520 | name = "hermit-abi" | 526 | name = "hermit-abi" |
521 | version = "0.1.17" | 527 | version = "0.1.18" |
522 | source = "registry+https://github.com/rust-lang/crates.io-index" | 528 | source = "registry+https://github.com/rust-lang/crates.io-index" |
523 | checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" | 529 | checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" |
524 | dependencies = [ | 530 | dependencies = [ |
525 | "libc", | 531 | "libc", |
526 | ] | 532 | ] |
@@ -708,9 +714,9 @@ dependencies = [ | |||
708 | 714 | ||
709 | [[package]] | 715 | [[package]] |
710 | name = "inotify-sys" | 716 | name = "inotify-sys" |
711 | version = "0.1.4" | 717 | version = "0.1.5" |
712 | source = "registry+https://github.com/rust-lang/crates.io-index" | 718 | source = "registry+https://github.com/rust-lang/crates.io-index" |
713 | checksum = "c4563555856585ab3180a5bf0b2f9f8d301a728462afffc8195b3f5394229c55" | 719 | checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" |
714 | dependencies = [ | 720 | dependencies = [ |
715 | "libc", | 721 | "libc", |
716 | ] | 722 | ] |
@@ -758,6 +764,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
758 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" | 764 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" |
759 | 765 | ||
760 | [[package]] | 766 | [[package]] |
767 | name = "jemalloc-ctl" | ||
768 | version = "0.3.3" | ||
769 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
770 | checksum = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7" | ||
771 | dependencies = [ | ||
772 | "jemalloc-sys", | ||
773 | "libc", | ||
774 | "paste", | ||
775 | ] | ||
776 | |||
777 | [[package]] | ||
778 | name = "jemalloc-sys" | ||
779 | version = "0.3.2" | ||
780 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
781 | checksum = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" | ||
782 | dependencies = [ | ||
783 | "cc", | ||
784 | "fs_extra", | ||
785 | "libc", | ||
786 | ] | ||
787 | |||
788 | [[package]] | ||
789 | name = "jemallocator" | ||
790 | version = "0.3.2" | ||
791 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
792 | checksum = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" | ||
793 | dependencies = [ | ||
794 | "jemalloc-sys", | ||
795 | "libc", | ||
796 | ] | ||
797 | |||
798 | [[package]] | ||
761 | name = "jod-thread" | 799 | name = "jod-thread" |
762 | version = "0.1.2" | 800 | version = "0.1.2" |
763 | source = "registry+https://github.com/rust-lang/crates.io-index" | 801 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -791,15 +829,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" | |||
791 | 829 | ||
792 | [[package]] | 830 | [[package]] |
793 | name = "libc" | 831 | name = "libc" |
794 | version = "0.2.81" | 832 | version = "0.2.82" |
795 | source = "registry+https://github.com/rust-lang/crates.io-index" | 833 | source = "registry+https://github.com/rust-lang/crates.io-index" |
796 | checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" | 834 | checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" |
797 | 835 | ||
798 | [[package]] | 836 | [[package]] |
799 | name = "libloading" | 837 | name = "libloading" |
800 | version = "0.6.6" | 838 | version = "0.6.7" |
801 | source = "registry+https://github.com/rust-lang/crates.io-index" | 839 | source = "registry+https://github.com/rust-lang/crates.io-index" |
802 | checksum = "e9367bdfa836b7e3cf895867f7a570283444da90562980ec2263d6e1569b16bc" | 840 | checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" |
803 | dependencies = [ | 841 | dependencies = [ |
804 | "cfg-if 1.0.0", | 842 | "cfg-if 1.0.0", |
805 | "winapi 0.3.9", | 843 | "winapi 0.3.9", |
@@ -825,9 +863,9 @@ dependencies = [ | |||
825 | 863 | ||
826 | [[package]] | 864 | [[package]] |
827 | name = "log" | 865 | name = "log" |
828 | version = "0.4.11" | 866 | version = "0.4.13" |
829 | source = "registry+https://github.com/rust-lang/crates.io-index" | 867 | source = "registry+https://github.com/rust-lang/crates.io-index" |
830 | checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" | 868 | checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2" |
831 | dependencies = [ | 869 | dependencies = [ |
832 | "cfg-if 0.1.10", | 870 | "cfg-if 0.1.10", |
833 | ] | 871 | ] |
@@ -1105,6 +1143,25 @@ dependencies = [ | |||
1105 | ] | 1143 | ] |
1106 | 1144 | ||
1107 | [[package]] | 1145 | [[package]] |
1146 | name = "paste" | ||
1147 | version = "0.1.18" | ||
1148 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1149 | checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" | ||
1150 | dependencies = [ | ||
1151 | "paste-impl", | ||
1152 | "proc-macro-hack", | ||
1153 | ] | ||
1154 | |||
1155 | [[package]] | ||
1156 | name = "paste-impl" | ||
1157 | version = "0.1.18" | ||
1158 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1159 | checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" | ||
1160 | dependencies = [ | ||
1161 | "proc-macro-hack", | ||
1162 | ] | ||
1163 | |||
1164 | [[package]] | ||
1108 | name = "paths" | 1165 | name = "paths" |
1109 | version = "0.0.0" | 1166 | version = "0.0.0" |
1110 | 1167 | ||
@@ -1160,9 +1217,15 @@ checksum = "28b9b4df73455c861d7cbf8be42f01d3b373ed7f02e378d55fa84eafc6f638b1" | |||
1160 | 1217 | ||
1161 | [[package]] | 1218 | [[package]] |
1162 | name = "pin-project-lite" | 1219 | name = "pin-project-lite" |
1163 | version = "0.2.0" | 1220 | version = "0.2.4" |
1164 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1221 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1165 | checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" | 1222 | checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" |
1223 | |||
1224 | [[package]] | ||
1225 | name = "proc-macro-hack" | ||
1226 | version = "0.5.19" | ||
1227 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1228 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" | ||
1166 | 1229 | ||
1167 | [[package]] | 1230 | [[package]] |
1168 | name = "proc-macro2" | 1231 | name = "proc-macro2" |
@@ -1212,6 +1275,7 @@ name = "profile" | |||
1212 | version = "0.0.0" | 1275 | version = "0.0.0" |
1213 | dependencies = [ | 1276 | dependencies = [ |
1214 | "cfg-if 1.0.0", | 1277 | "cfg-if 1.0.0", |
1278 | "jemalloc-ctl", | ||
1215 | "la-arena", | 1279 | "la-arena", |
1216 | "libc", | 1280 | "libc", |
1217 | "once_cell", | 1281 | "once_cell", |
@@ -1301,9 +1365,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" | |||
1301 | 1365 | ||
1302 | [[package]] | 1366 | [[package]] |
1303 | name = "regex" | 1367 | name = "regex" |
1304 | version = "1.4.2" | 1368 | version = "1.4.3" |
1305 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1369 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1306 | checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" | 1370 | checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" |
1307 | dependencies = [ | 1371 | dependencies = [ |
1308 | "regex-syntax", | 1372 | "regex-syntax", |
1309 | ] | 1373 | ] |
@@ -1320,9 +1384,9 @@ dependencies = [ | |||
1320 | 1384 | ||
1321 | [[package]] | 1385 | [[package]] |
1322 | name = "regex-syntax" | 1386 | name = "regex-syntax" |
1323 | version = "0.6.21" | 1387 | version = "0.6.22" |
1324 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1388 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1325 | checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" | 1389 | checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" |
1326 | 1390 | ||
1327 | [[package]] | 1391 | [[package]] |
1328 | name = "rowan" | 1392 | name = "rowan" |
@@ -1354,6 +1418,7 @@ dependencies = [ | |||
1354 | "ide", | 1418 | "ide", |
1355 | "ide_db", | 1419 | "ide_db", |
1356 | "itertools 0.10.0", | 1420 | "itertools 0.10.0", |
1421 | "jemallocator", | ||
1357 | "jod-thread", | 1422 | "jod-thread", |
1358 | "log", | 1423 | "log", |
1359 | "lsp-server", | 1424 | "lsp-server", |
@@ -1485,18 +1550,18 @@ dependencies = [ | |||
1485 | 1550 | ||
1486 | [[package]] | 1551 | [[package]] |
1487 | name = "serde" | 1552 | name = "serde" |
1488 | version = "1.0.118" | 1553 | version = "1.0.119" |
1489 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1554 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1490 | checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" | 1555 | checksum = "9bdd36f49e35b61d49efd8aa7fc068fd295961fd2286d0b2ee9a4c7a14e99cc3" |
1491 | dependencies = [ | 1556 | dependencies = [ |
1492 | "serde_derive", | 1557 | "serde_derive", |
1493 | ] | 1558 | ] |
1494 | 1559 | ||
1495 | [[package]] | 1560 | [[package]] |
1496 | name = "serde_derive" | 1561 | name = "serde_derive" |
1497 | version = "1.0.118" | 1562 | version = "1.0.119" |
1498 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1563 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1499 | checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" | 1564 | checksum = "552954ce79a059ddd5fd68c271592374bd15cab2274970380c000118aeffe1cd" |
1500 | dependencies = [ | 1565 | dependencies = [ |
1501 | "proc-macro2", | 1566 | "proc-macro2", |
1502 | "quote", | 1567 | "quote", |
@@ -1552,9 +1617,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" | |||
1552 | 1617 | ||
1553 | [[package]] | 1618 | [[package]] |
1554 | name = "smallvec" | 1619 | name = "smallvec" |
1555 | version = "1.6.0" | 1620 | version = "1.6.1" |
1556 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1621 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1557 | checksum = "1a55ca5f3b68e41c979bf8c46a6f1da892ca4db8f94023ce0bd32407573b1ac0" | 1622 | checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" |
1558 | 1623 | ||
1559 | [[package]] | 1624 | [[package]] |
1560 | name = "smol_str" | 1625 | name = "smol_str" |
@@ -1594,9 +1659,9 @@ dependencies = [ | |||
1594 | 1659 | ||
1595 | [[package]] | 1660 | [[package]] |
1596 | name = "syn" | 1661 | name = "syn" |
1597 | version = "1.0.57" | 1662 | version = "1.0.58" |
1598 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1663 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1599 | checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6" | 1664 | checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" |
1600 | dependencies = [ | 1665 | dependencies = [ |
1601 | "proc-macro2", | 1666 | "proc-macro2", |
1602 | "quote", | 1667 | "quote", |
@@ -1673,9 +1738,9 @@ dependencies = [ | |||
1673 | 1738 | ||
1674 | [[package]] | 1739 | [[package]] |
1675 | name = "thread_local" | 1740 | name = "thread_local" |
1676 | version = "1.0.1" | 1741 | version = "1.1.0" |
1677 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1742 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1678 | checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" | 1743 | checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" |
1679 | dependencies = [ | 1744 | dependencies = [ |
1680 | "lazy_static", | 1745 | "lazy_static", |
1681 | ] | 1746 | ] |
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index 3dd7c3cbb..e34cd7f2f 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs | |||
@@ -87,7 +87,7 @@ impl ModPath { | |||
87 | 87 | ||
88 | /// If this path is a single identifier, like `foo`, return its name. | 88 | /// If this path is a single identifier, like `foo`, return its name. |
89 | pub fn as_ident(&self) -> Option<&Name> { | 89 | pub fn as_ident(&self) -> Option<&Name> { |
90 | if self.kind != PathKind::Plain || self.segments.len() > 1 { | 90 | if !self.is_ident() { |
91 | return None; | 91 | return None; |
92 | } | 92 | } |
93 | self.segments.first() | 93 | self.segments.first() |
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index 8db581b77..c8ea81210 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -76,6 +76,8 @@ pub struct HygieneFrame { | |||
76 | 76 | ||
77 | impl HygieneFrames { | 77 | impl HygieneFrames { |
78 | fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Self { | 78 | fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Self { |
79 | // Note that this intentionally avoids the `hygiene_frame` query to avoid blowing up memory | ||
80 | // usage. The query is only helpful for nested `HygieneFrame`s as it avoids redundant work. | ||
79 | HygieneFrames(Arc::new(HygieneFrame::new(db, file_id))) | 81 | HygieneFrames(Arc::new(HygieneFrame::new(db, file_id))) |
80 | } | 82 | } |
81 | 83 | ||
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 51a2f4327..df9c31aef 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -930,6 +930,26 @@ impl Foo { | |||
930 | ); | 930 | ); |
931 | } | 931 | } |
932 | 932 | ||
933 | #[test] | ||
934 | fn test_find_self_refs_decl() { | ||
935 | check( | ||
936 | r#" | ||
937 | struct Foo { bar: i32 } | ||
938 | |||
939 | impl Foo { | ||
940 | fn foo(self$0) { | ||
941 | self; | ||
942 | } | ||
943 | } | ||
944 | "#, | ||
945 | expect![[r#" | ||
946 | self SelfParam FileId(0) 47..51 47..51 SelfParam | ||
947 | |||
948 | FileId(0) 63..67 Other Read | ||
949 | "#]], | ||
950 | ); | ||
951 | } | ||
952 | |||
933 | fn check(ra_fixture: &str, expect: Expect) { | 953 | fn check(ra_fixture: &str, expect: Expect) { |
934 | check_with_scope(ra_fixture, None, expect) | 954 | check_with_scope(ra_fixture, None, expect) |
935 | } | 955 | } |
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index e648519f9..2a41d8167 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs | |||
@@ -51,6 +51,7 @@ pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> Option<(tt::Subtree, Toke | |||
51 | let global_offset = node.text_range().start(); | 51 | let global_offset = node.text_range().start(); |
52 | let mut c = Convertor::new(node, global_offset); | 52 | let mut c = Convertor::new(node, global_offset); |
53 | let subtree = c.go()?; | 53 | let subtree = c.go()?; |
54 | c.id_alloc.map.entries.shrink_to_fit(); | ||
54 | Some((subtree, c.id_alloc.map)) | 55 | Some((subtree, c.id_alloc.map)) |
55 | } | 56 | } |
56 | 57 | ||
@@ -593,7 +594,8 @@ impl<'a> TtTreeSink<'a> { | |||
593 | } | 594 | } |
594 | } | 595 | } |
595 | 596 | ||
596 | fn finish(self) -> (Parse<SyntaxNode>, TokenMap) { | 597 | fn finish(mut self) -> (Parse<SyntaxNode>, TokenMap) { |
598 | self.token_map.entries.shrink_to_fit(); | ||
597 | (self.inner.finish(), self.token_map) | 599 | (self.inner.finish(), self.token_map) |
598 | } | 600 | } |
599 | } | 601 | } |
diff --git a/crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt b/crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt index e6fd21610..ea34e688f 100644 --- a/crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt +++ b/crates/proc_macro_srv/src/tests/fixtures/test_serialize_proc_macro.txt | |||
@@ -59,7 +59,7 @@ SUBTREE $ | |||
59 | IDENT _serde 4294967295 | 59 | IDENT _serde 4294967295 |
60 | PUNCH : [joint] 4294967295 | 60 | PUNCH : [joint] 4294967295 |
61 | PUNCH : [alone] 4294967295 | 61 | PUNCH : [alone] 4294967295 |
62 | IDENT export 4294967295 | 62 | IDENT __private 4294967295 |
63 | PUNCH : [joint] 4294967295 | 63 | PUNCH : [joint] 4294967295 |
64 | PUNCH : [alone] 4294967295 | 64 | PUNCH : [alone] 4294967295 |
65 | IDENT Ok 4294967295 | 65 | IDENT Ok 4294967295 |
@@ -72,7 +72,7 @@ SUBTREE $ | |||
72 | IDENT _serde 4294967295 | 72 | IDENT _serde 4294967295 |
73 | PUNCH : [joint] 4294967295 | 73 | PUNCH : [joint] 4294967295 |
74 | PUNCH : [alone] 4294967295 | 74 | PUNCH : [alone] 4294967295 |
75 | IDENT export 4294967295 | 75 | IDENT __private 4294967295 |
76 | PUNCH : [joint] 4294967295 | 76 | PUNCH : [joint] 4294967295 |
77 | PUNCH : [alone] 4294967295 | 77 | PUNCH : [alone] 4294967295 |
78 | IDENT Err 4294967295 | 78 | IDENT Err 4294967295 |
@@ -85,7 +85,7 @@ SUBTREE $ | |||
85 | IDENT _serde 4294967295 | 85 | IDENT _serde 4294967295 |
86 | PUNCH : [joint] 4294967295 | 86 | PUNCH : [joint] 4294967295 |
87 | PUNCH : [alone] 4294967295 | 87 | PUNCH : [alone] 4294967295 |
88 | IDENT export 4294967295 | 88 | IDENT __private 4294967295 |
89 | PUNCH : [joint] 4294967295 | 89 | PUNCH : [joint] 4294967295 |
90 | PUNCH : [alone] 4294967295 | 90 | PUNCH : [alone] 4294967295 |
91 | IDENT Err 4294967295 | 91 | IDENT Err 4294967295 |
@@ -120,7 +120,7 @@ SUBTREE $ | |||
120 | IDENT _serde 4294967295 | 120 | IDENT _serde 4294967295 |
121 | PUNCH : [joint] 4294967295 | 121 | PUNCH : [joint] 4294967295 |
122 | PUNCH : [alone] 4294967295 | 122 | PUNCH : [alone] 4294967295 |
123 | IDENT export 4294967295 | 123 | IDENT __private 4294967295 |
124 | PUNCH : [joint] 4294967295 | 124 | PUNCH : [joint] 4294967295 |
125 | PUNCH : [alone] 4294967295 | 125 | PUNCH : [alone] 4294967295 |
126 | IDENT Result 4294967295 | 126 | IDENT Result 4294967295 |
diff --git a/crates/profile/Cargo.toml b/crates/profile/Cargo.toml index 9c7ce26be..f7231c2b8 100644 --- a/crates/profile/Cargo.toml +++ b/crates/profile/Cargo.toml | |||
@@ -14,12 +14,14 @@ once_cell = "1.3.1" | |||
14 | cfg-if = "1" | 14 | cfg-if = "1" |
15 | libc = "0.2.73" | 15 | libc = "0.2.73" |
16 | la-arena = { version = "0.2.0", path = "../../lib/arena" } | 16 | la-arena = { version = "0.2.0", path = "../../lib/arena" } |
17 | jemalloc-ctl = { version = "0.3.3", optional = true } | ||
17 | 18 | ||
18 | [target.'cfg(target_os = "linux")'.dependencies] | 19 | [target.'cfg(target_os = "linux")'.dependencies] |
19 | perf-event = "0.4" | 20 | perf-event = "0.4" |
20 | 21 | ||
21 | [features] | 22 | [features] |
22 | cpu_profiler = [] | 23 | cpu_profiler = [] |
24 | jemalloc = ["jemalloc-ctl"] | ||
23 | 25 | ||
24 | # Uncomment to enable for the whole crate graph | 26 | # Uncomment to enable for the whole crate graph |
25 | # default = [ "cpu_profiler" ] | 27 | # default = [ "cpu_profiler" ] |
diff --git a/crates/profile/src/memory_usage.rs b/crates/profile/src/memory_usage.rs index 83390212a..cb4e54447 100644 --- a/crates/profile/src/memory_usage.rs +++ b/crates/profile/src/memory_usage.rs | |||
@@ -24,7 +24,12 @@ impl std::ops::Sub for MemoryUsage { | |||
24 | impl MemoryUsage { | 24 | impl MemoryUsage { |
25 | pub fn current() -> MemoryUsage { | 25 | pub fn current() -> MemoryUsage { |
26 | cfg_if! { | 26 | cfg_if! { |
27 | if #[cfg(all(target_os = "linux", target_env = "gnu"))] { | 27 | if #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] { |
28 | jemalloc_ctl::epoch::advance().unwrap(); | ||
29 | MemoryUsage { | ||
30 | allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap() as isize), | ||
31 | } | ||
32 | } else if #[cfg(all(target_os = "linux", target_env = "gnu"))] { | ||
28 | // Note: This is incredibly slow. | 33 | // Note: This is incredibly slow. |
29 | let alloc = unsafe { libc::mallinfo() }.uordblks as isize; | 34 | let alloc = unsafe { libc::mallinfo() }.uordblks as isize; |
30 | MemoryUsage { allocated: Bytes(alloc) } | 35 | MemoryUsage { allocated: Bytes(alloc) } |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index af7b86ead..3cb45b030 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -61,8 +61,14 @@ proc_macro_srv = { path = "../proc_macro_srv", version = "0.0.0" } | |||
61 | [target.'cfg(windows)'.dependencies] | 61 | [target.'cfg(windows)'.dependencies] |
62 | winapi = "0.3.8" | 62 | winapi = "0.3.8" |
63 | 63 | ||
64 | [target.'cfg(not(target_env = "msvc"))'.dependencies] | ||
65 | jemallocator = { version = "0.3.2", optional = true } | ||
66 | |||
64 | [dev-dependencies] | 67 | [dev-dependencies] |
65 | expect-test = "1.1" | 68 | expect-test = "1.1" |
66 | test_utils = { path = "../test_utils" } | 69 | test_utils = { path = "../test_utils" } |
67 | mbe = { path = "../mbe" } | 70 | mbe = { path = "../mbe" } |
68 | tt = { path = "../tt" } | 71 | tt = { path = "../tt" } |
72 | |||
73 | [features] | ||
74 | jemalloc = ["jemallocator", "profile/jemalloc"] | ||
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index bf42654a8..2f7f94a39 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs | |||
@@ -15,6 +15,10 @@ use vfs::AbsPathBuf; | |||
15 | #[global_allocator] | 15 | #[global_allocator] |
16 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; | 16 | static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; |
17 | 17 | ||
18 | #[cfg(all(feature = "jemalloc", not(target_env = "msvc")))] | ||
19 | #[global_allocator] | ||
20 | static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
21 | |||
18 | fn main() { | 22 | fn main() { |
19 | if let Err(err) = try_main() { | 23 | if let Err(err) = try_main() { |
20 | eprintln!("{}", err); | 24 | eprintln!("{}", err); |
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 12962bcfa..202c74426 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -67,6 +67,7 @@ pub struct ServerOpt { | |||
67 | pub enum Malloc { | 67 | pub enum Malloc { |
68 | System, | 68 | System, |
69 | Mimalloc, | 69 | Mimalloc, |
70 | Jemalloc, | ||
70 | } | 71 | } |
71 | 72 | ||
72 | impl InstallCmd { | 73 | impl InstallCmd { |
@@ -176,6 +177,7 @@ fn install_server(opts: ServerOpt) -> Result<()> { | |||
176 | let features = match opts.malloc { | 177 | let features = match opts.malloc { |
177 | Malloc::System => &[][..], | 178 | Malloc::System => &[][..], |
178 | Malloc::Mimalloc => &["--features", "mimalloc"], | 179 | Malloc::Mimalloc => &["--features", "mimalloc"], |
180 | Malloc::Jemalloc => &["--features", "jemalloc"], | ||
179 | }; | 181 | }; |
180 | 182 | ||
181 | let cmd = cmd!("cargo install --path crates/rust-analyzer --locked --force {features...}"); | 183 | let cmd = cmd!("cargo install --path crates/rust-analyzer --locked --force {features...}"); |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index dec48629c..c3e5c7326 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -49,7 +49,8 @@ FLAGS: | |||
49 | --client[=CLIENT] Install only VS Code plugin. | 49 | --client[=CLIENT] Install only VS Code plugin. |
50 | CLIENT is one of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss' | 50 | CLIENT is one of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss' |
51 | --server Install only the language server | 51 | --server Install only the language server |
52 | --mimalloc Use mimalloc for server | 52 | --mimalloc Use mimalloc allocator for server |
53 | --jemalloc Use jemalloc allocator for server | ||
53 | -h, --help Prints help information | 54 | -h, --help Prints help information |
54 | " | 55 | " |
55 | ); | 56 | ); |
@@ -65,8 +66,13 @@ FLAGS: | |||
65 | return Ok(()); | 66 | return Ok(()); |
66 | } | 67 | } |
67 | 68 | ||
68 | let malloc = | 69 | let malloc = if args.contains("--mimalloc") { |
69 | if args.contains("--mimalloc") { Malloc::Mimalloc } else { Malloc::System }; | 70 | Malloc::Mimalloc |
71 | } else if args.contains("--jemalloc") { | ||
72 | Malloc::Jemalloc | ||
73 | } else { | ||
74 | Malloc::System | ||
75 | }; | ||
70 | 76 | ||
71 | let client_opt = args.opt_value_from_str("--client")?; | 77 | let client_opt = args.opt_value_from_str("--client")?; |
72 | 78 | ||