aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock54
-rw-r--r--crates/ra_hir/src/lib.rs1
-rw-r--r--crates/ra_hir/src/source_id.rs2
-rw-r--r--crates/ra_ide_api/src/snapshots/highlighting.html45
-rw-r--r--crates/ra_ide_api/src/snapshots/rainbow_highlighting.html29
-rw-r--r--crates/ra_ide_api/src/syntax_highlighting.rs82
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs2
-rw-r--r--crates/ra_prof/Cargo.toml4
-rw-r--r--crates/ra_prof/src/memory_usage.rs6
-rw-r--r--crates/ra_syntax/src/lib.rs2
-rw-r--r--crates/ra_syntax/src/ptr.rs2
-rw-r--r--editors/code/package.json9
-rw-r--r--editors/code/src/highlighting.ts1
13 files changed, 166 insertions, 73 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c29370fde..03f5be16b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -674,16 +674,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
674 674
675[[package]] 675[[package]]
676name = "jemalloc-ctl" 676name = "jemalloc-ctl"
677version = "0.2.0" 677version = "0.3.3"
678source = "registry+https://github.com/rust-lang/crates.io-index" 678source = "registry+https://github.com/rust-lang/crates.io-index"
679dependencies = [ 679dependencies = [
680 "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 680 "jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
681 "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", 681 "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
682 "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
682] 683]
683 684
684[[package]] 685[[package]]
685name = "jemalloc-sys" 686name = "jemalloc-sys"
686version = "0.1.8" 687version = "0.3.2"
687source = "registry+https://github.com/rust-lang/crates.io-index" 688source = "registry+https://github.com/rust-lang/crates.io-index"
688dependencies = [ 689dependencies = [
689 "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", 690 "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -693,10 +694,10 @@ dependencies = [
693 694
694[[package]] 695[[package]]
695name = "jemallocator" 696name = "jemallocator"
696version = "0.1.9" 697version = "0.3.2"
697source = "registry+https://github.com/rust-lang/crates.io-index" 698source = "registry+https://github.com/rust-lang/crates.io-index"
698dependencies = [ 699dependencies = [
699 "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 700 "jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
700 "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", 701 "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
701] 702]
702 703
@@ -989,6 +990,26 @@ dependencies = [
989] 990]
990 991
991[[package]] 992[[package]]
993name = "paste"
994version = "0.1.5"
995source = "registry+https://github.com/rust-lang/crates.io-index"
996dependencies = [
997 "paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
998 "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
999]
1000
1001[[package]]
1002name = "paste-impl"
1003version = "0.1.5"
1004source = "registry+https://github.com/rust-lang/crates.io-index"
1005dependencies = [
1006 "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)",
1007 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
1008 "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
1009 "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)",
1010]
1011
1012[[package]]
992name = "percent-encoding" 1013name = "percent-encoding"
993version = "1.0.1" 1014version = "1.0.1"
994source = "registry+https://github.com/rust-lang/crates.io-index" 1015source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1047,6 +1068,16 @@ version = "0.2.5"
1047source = "registry+https://github.com/rust-lang/crates.io-index" 1068source = "registry+https://github.com/rust-lang/crates.io-index"
1048 1069
1049[[package]] 1070[[package]]
1071name = "proc-macro-hack"
1072version = "0.5.8"
1073source = "registry+https://github.com/rust-lang/crates.io-index"
1074dependencies = [
1075 "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
1076 "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
1077 "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)",
1078]
1079
1080[[package]]
1050name = "proc-macro2" 1081name = "proc-macro2"
1051version = "0.4.30" 1082version = "0.4.30"
1052source = "registry+https://github.com/rust-lang/crates.io-index" 1083source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1256,8 +1287,8 @@ dependencies = [
1256 "backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", 1287 "backtrace 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)",
1257 "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 1288 "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
1258 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", 1289 "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
1259 "jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 1290 "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
1260 "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1291 "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
1261 "once_cell 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", 1292 "once_cell 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
1262] 1293]
1263 1294
@@ -2168,9 +2199,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2168"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" 2199"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
2169"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" 2200"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
2170"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" 2201"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
2171"checksum jemalloc-ctl 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e93b0f37e7d735c6b610176d5b1bde8e1621ff3f6f7ac23cdfa4e7f7d0111b5" 2202"checksum jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7"
2172"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae" 2203"checksum jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45"
2173"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3" 2204"checksum jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69"
2174"checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f" 2205"checksum join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4dc7a5290e8c2606ce2be49f456d50f69173cb96d1541e4f66e34ac8b331a98f"
2175"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 2206"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
2176"checksum lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4fd87be4a815fd373e02773983940f0d75fb26fde8c098e9e45f7af03154c0" 2207"checksum lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4fd87be4a815fd373e02773983940f0d75fb26fde8c098e9e45f7af03154c0"
@@ -2205,6 +2236,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2205"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" 2236"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
2206"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" 2237"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c"
2207"checksum parking_lot_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67812d70a819b886655846594086c00ac1f3e8b77c36ef494aa730c620b19d57" 2238"checksum parking_lot_core 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67812d70a819b886655846594086c00ac1f3e8b77c36ef494aa730c620b19d57"
2239"checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79"
2240"checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6"
2208"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" 2241"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
2209"checksum pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "933085deae3f32071f135d799d75667b63c8dc1f4537159756e3d4ceab41868c" 2242"checksum pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "933085deae3f32071f135d799d75667b63c8dc1f4537159756e3d4ceab41868c"
2210"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" 2243"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
@@ -2212,6 +2245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2212"checksum pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f249ea6de7c7b7aba92b4ff4376a994c6dbd98fd2166c89d5c4947397ecb574d" 2245"checksum pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f249ea6de7c7b7aba92b4ff4376a994c6dbd98fd2166c89d5c4947397ecb574d"
2213"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" 2246"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
2214"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" 2247"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b"
2248"checksum proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "982a35d1194084ba319d65c4a68d24ca28f5fdb5b8bc20899e4eef8641ea5178"
2215"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" 2249"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
2216"checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f" 2250"checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f"
2217"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" 2251"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 55d1298cf..081974e2b 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -68,6 +68,7 @@ pub use self::{
68 source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer}, 68 source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer},
69 source_id::{AstIdMap, ErasedFileAstId}, 69 source_id::{AstIdMap, ErasedFileAstId},
70 ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor}, 70 ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor},
71 type_ref::Mutability,
71}; 72};
72 73
73pub use self::code_model::{ 74pub use self::code_model::{
diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs
index 324b79824..6cdb90141 100644
--- a/crates/ra_hir/src/source_id.rs
+++ b/crates/ra_hir/src/source_id.rs
@@ -52,7 +52,7 @@ impl<N: AstNode> AstId<N> {
52#[derive(Debug)] 52#[derive(Debug)]
53pub(crate) struct FileAstId<N: AstNode> { 53pub(crate) struct FileAstId<N: AstNode> {
54 raw: ErasedFileAstId, 54 raw: ErasedFileAstId,
55 _ty: PhantomData<N>, 55 _ty: PhantomData<fn() -> N>,
56} 56}
57 57
58impl<N: AstNode> Clone for FileAstId<N> { 58impl<N: AstNode> Clone for FileAstId<N> {
diff --git a/crates/ra_ide_api/src/snapshots/highlighting.html b/crates/ra_ide_api/src/snapshots/highlighting.html
index d79d35bf3..709816d0d 100644
--- a/crates/ra_ide_api/src/snapshots/highlighting.html
+++ b/crates/ra_ide_api/src/snapshots/highlighting.html
@@ -1,21 +1,22 @@
1 1
2<style> 2<style>
3body { margin: 0; } 3body { margin: 0; }
4pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } 4pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
5 5
6.comment { color: #7F9F7F; } 6.comment { color: #7F9F7F; }
7.string { color: #CC9393; } 7.string { color: #CC9393; }
8.function { color: #93E0E3; } 8.function { color: #93E0E3; }
9.parameter { color: #94BFF3; } 9.parameter { color: #94BFF3; }
10.builtin { color: #DD6718; } 10.builtin { color: #DD6718; }
11.text { color: #DCDCCC; } 11.text { color: #DCDCCC; }
12.attribute { color: #BFEBBF; } 12.attribute { color: #BFEBBF; }
13.literal { color: #DFAF8F; } 13.literal { color: #DFAF8F; }
14.macro { color: #DFAF8F; } 14.macro { color: #DFAF8F; }
15 15.variable\.mut { color: #DFAF8F; }
16.keyword { color: #F0DFAF; } 16
17.keyword\.unsafe { color: #F0DFAF; font-weight: bold; } 17.keyword { color: #F0DFAF; }
18.keyword\.control { color: #DC8CC3; } 18.keyword\.unsafe { color: #F0DFAF; font-weight: bold; }
19.keyword\.control { color: #DC8CC3; }
19</style> 20</style>
20<pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span> 21<pre><code><span class="attribute">#</span><span class="attribute">[</span><span class="attribute">derive</span><span class="attribute">(</span><span class="attribute">Clone</span><span class="attribute">,</span><span class="attribute"> </span><span class="attribute">Debug</span><span class="attribute">)</span><span class="attribute">]</span>
21<span class="keyword">struct</span> <span class="type">Foo</span> { 22<span class="keyword">struct</span> <span class="type">Foo</span> {
@@ -32,9 +33,15 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4e
32<span class="keyword">fn</span> <span class="function">main</span>() { 33<span class="keyword">fn</span> <span class="function">main</span>() {
33 <span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="literal">92</span>); 34 <span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello, {}!"</span>, <span class="literal">92</span>);
34 35
35 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable" data-binding-hash="9636295041291189729" style="color: hsl(51,57%,74%);">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>(); 36 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
36 <span class="keyword.control">if</span> <span class="keyword">true</span> { 37 <span class="keyword.control">if</span> <span class="keyword">true</span> {
37 <span class="variable" data-binding-hash="8496027264380925433" style="color: hsl(18,48%,55%);">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>: <span class="literal">0</span>, <span class="field">y</span>: <span class="literal">1</span> }); 38 <span class="variable.mut">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>: <span class="literal">0</span>, <span class="field">y</span>: <span class="literal">1</span> });
38 } 39 }
39 <span class="keyword.unsafe">unsafe</span> { <span class="variable" data-binding-hash="8496027264380925433" style="color: hsl(18,48%,55%);">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); } 40 <span class="keyword.unsafe">unsafe</span> { <span class="variable.mut">vec</span>.<span class="text">set_len</span>(<span class="literal">0</span>); }
41
42 <span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">x</span> = <span class="literal">42</span>;
43 <span class="keyword">let</span> <span class="variable.mut">y</span> = &<span class="keyword">mut</span> <span class="variable.mut">x</span>;
44 <span class="keyword">let</span> <span class="variable">z</span> = &<span class="variable.mut">y</span>;
45
46 <span class="variable.mut">y</span>;
40}</code></pre> \ No newline at end of file 47}</code></pre> \ No newline at end of file
diff --git a/crates/ra_ide_api/src/snapshots/rainbow_highlighting.html b/crates/ra_ide_api/src/snapshots/rainbow_highlighting.html
index 729d129d0..ad3935b5d 100644
--- a/crates/ra_ide_api/src/snapshots/rainbow_highlighting.html
+++ b/crates/ra_ide_api/src/snapshots/rainbow_highlighting.html
@@ -1,21 +1,22 @@
1 1
2<style> 2<style>
3body { margin: 0; } 3body { margin: 0; }
4pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } 4pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
5 5
6.comment { color: #7F9F7F; } 6.comment { color: #7F9F7F; }
7.string { color: #CC9393; } 7.string { color: #CC9393; }
8.function { color: #93E0E3; } 8.function { color: #93E0E3; }
9.parameter { color: #94BFF3; } 9.parameter { color: #94BFF3; }
10.builtin { color: #DD6718; } 10.builtin { color: #DD6718; }
11.text { color: #DCDCCC; } 11.text { color: #DCDCCC; }
12.attribute { color: #BFEBBF; } 12.attribute { color: #BFEBBF; }
13.literal { color: #DFAF8F; } 13.literal { color: #DFAF8F; }
14.macro { color: #DFAF8F; } 14.macro { color: #DFAF8F; }
15.variable\.mut { color: #DFAF8F; }
15 16
16.keyword { color: #F0DFAF; } 17.keyword { color: #F0DFAF; }
17.keyword\.unsafe { color: #F0DFAF; font-weight: bold; } 18.keyword\.unsafe { color: #F0DFAF; font-weight: bold; }
18.keyword\.control { color: #DC8CC3; } 19.keyword\.control { color: #DC8CC3; }
19</style> 20</style>
20<pre><code><span class="keyword">fn</span> <span class="function">main</span>() { 21<pre><code><span class="keyword">fn</span> <span class="function">main</span>() {
21 <span class="keyword">let</span> <span class="variable" data-binding-hash="3888301305669440875" style="color: hsl(242,59%,59%);">hello</span> = <span class="string">"hello"</span>; 22 <span class="keyword">let</span> <span class="variable" data-binding-hash="3888301305669440875" style="color: hsl(242,59%,59%);">hello</span> = <span class="string">"hello"</span>;
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs
index d70ceb7d1..d84ae2cb2 100644
--- a/crates/ra_ide_api/src/syntax_highlighting.rs
+++ b/crates/ra_ide_api/src/syntax_highlighting.rs
@@ -1,9 +1,11 @@
1use rustc_hash::{FxHashMap, FxHashSet}; 1use rustc_hash::{FxHashMap, FxHashSet};
2 2
3use hir::{Mutability, Ty};
3use ra_db::SourceDatabase; 4use ra_db::SourceDatabase;
4use ra_prof::profile; 5use ra_prof::profile;
5use ra_syntax::{ 6use ra_syntax::{
6 ast, AstNode, Direction, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T, 7 ast, AstNode, Direction, Pat, PatKind, SmolStr, SyntaxElement, SyntaxKind, SyntaxKind::*,
8 TextRange, T,
7}; 9};
8 10
9use crate::{db::RootDatabase, FileId}; 11use crate::{db::RootDatabase, FileId};
@@ -30,6 +32,27 @@ fn is_control_keyword(kind: SyntaxKind) -> bool {
30 } 32 }
31} 33}
32 34
35fn is_variable_mutable(db: &RootDatabase, analyzer: &hir::SourceAnalyzer, pat: &Pat) -> bool {
36 let ty = analyzer.type_of_pat(db, pat).unwrap_or(Ty::Unknown);
37 let is_ty_mut = {
38 if let Some((_, mutability)) = ty.as_reference() {
39 match mutability {
40 Mutability::Shared => false,
41 Mutability::Mut => true,
42 }
43 } else {
44 false
45 }
46 };
47
48 let is_pat_mut = match pat.kind() {
49 PatKind::BindPat(bind_pat) => bind_pat.is_mutable(),
50 _ => false,
51 };
52
53 is_ty_mut || is_pat_mut
54}
55
33pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { 56pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> {
34 let _p = profile("highlight"); 57 let _p = profile("highlight");
35 let parse = db.parse(file_id); 58 let parse = db.parse(file_id);
@@ -97,7 +120,11 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
97 calc_binding_hash(file_id, &text, *shadow_count) 120 calc_binding_hash(file_id, &text, *shadow_count)
98 }); 121 });
99 122
100 "variable" 123 if is_variable_mutable(db, &analyzer, ptr.to_node(root)) {
124 "variable.mut"
125 } else {
126 "variable"
127 }
101 } 128 }
102 Some(SelfParam(_)) => "type", 129 Some(SelfParam(_)) => "type",
103 Some(GenericParam(_)) => "type", 130 Some(GenericParam(_)) => "type",
@@ -109,7 +136,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
109 } 136 }
110 NAME => { 137 NAME => {
111 if let Some(name) = node.as_node().and_then(ast::Name::cast) { 138 if let Some(name) = node.as_node().and_then(ast::Name::cast) {
112 if name.syntax().ancestors().any(|x| ast::BindPat::cast(x).is_some()) { 139 let analyzer = hir::SourceAnalyzer::new(db, file_id, name.syntax(), None);
140 if let Some(pat) = name.syntax().ancestors().find_map(Pat::cast) {
113 binding_hash = Some({ 141 binding_hash = Some({
114 let text = name.syntax().text().to_smol_string(); 142 let text = name.syntax().text().to_smol_string();
115 let shadow_count = 143 let shadow_count =
@@ -117,7 +145,12 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
117 *shadow_count += 1; 145 *shadow_count += 1;
118 calc_binding_hash(file_id, &text, *shadow_count) 146 calc_binding_hash(file_id, &text, *shadow_count)
119 }); 147 });
120 "variable" 148
149 if is_variable_mutable(db, &analyzer, pat) {
150 "variable.mut"
151 } else {
152 "variable"
153 }
121 } else if name 154 } else if name
122 .syntax() 155 .syntax()
123 .parent() 156 .parent()
@@ -241,22 +274,23 @@ fn html_escape(text: &str) -> String {
241 274
242const STYLE: &str = " 275const STYLE: &str = "
243<style> 276<style>
244body { margin: 0; } 277body { margin: 0; }
245pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } 278pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; }
246 279
247.comment { color: #7F9F7F; } 280.comment { color: #7F9F7F; }
248.string { color: #CC9393; } 281.string { color: #CC9393; }
249.function { color: #93E0E3; } 282.function { color: #93E0E3; }
250.parameter { color: #94BFF3; } 283.parameter { color: #94BFF3; }
251.builtin { color: #DD6718; } 284.builtin { color: #DD6718; }
252.text { color: #DCDCCC; } 285.text { color: #DCDCCC; }
253.attribute { color: #BFEBBF; } 286.attribute { color: #BFEBBF; }
254.literal { color: #DFAF8F; } 287.literal { color: #DFAF8F; }
255.macro { color: #DFAF8F; } 288.macro { color: #DFAF8F; }
256 289.variable\\.mut { color: #DFAF8F; }
257.keyword { color: #F0DFAF; } 290
258.keyword\\.unsafe { color: #F0DFAF; font-weight: bold; } 291.keyword { color: #F0DFAF; }
259.keyword\\.control { color: #DC8CC3; } 292.keyword\\.unsafe { color: #F0DFAF; font-weight: bold; }
293.keyword\\.control { color: #DC8CC3; }
260</style> 294</style>
261"; 295";
262 296
@@ -289,12 +323,18 @@ fn main() {
289 vec.push(Foo { x: 0, y: 1 }); 323 vec.push(Foo { x: 0, y: 1 });
290 } 324 }
291 unsafe { vec.set_len(0); } 325 unsafe { vec.set_len(0); }
326
327 let mut x = 42;
328 let y = &mut x;
329 let z = &y;
330
331 y;
292} 332}
293"# 333"#
294 .trim(), 334 .trim(),
295 ); 335 );
296 let dst_file = project_dir().join("crates/ra_ide_api/src/snapshots/highlighting.html"); 336 let dst_file = project_dir().join("crates/ra_ide_api/src/snapshots/highlighting.html");
297 let actual_html = &analysis.highlight_as_html(file_id, true).unwrap(); 337 let actual_html = &analysis.highlight_as_html(file_id, false).unwrap();
298 let expected_html = &read_text(&dst_file); 338 let expected_html = &read_text(&dst_file);
299 std::fs::write(dst_file, &actual_html).unwrap(); 339 std::fs::write(dst_file, &actual_html).unwrap();
300 assert_eq_text!(expected_html, actual_html); 340 assert_eq_text!(expected_html, actual_html);
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index ab9ed5080..68865b755 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -695,7 +695,7 @@ pub fn handle_code_lens(
695 let title = match &runnable.kind { 695 let title = match &runnable.kind {
696 RunnableKind::Test { .. } | RunnableKind::TestMod { .. } => Some("▶️Run Test"), 696 RunnableKind::Test { .. } | RunnableKind::TestMod { .. } => Some("▶️Run Test"),
697 RunnableKind::Bench { .. } => Some("Run Bench"), 697 RunnableKind::Bench { .. } => Some("Run Bench"),
698 _ => None, 698 RunnableKind::Bin => Some("️Run"),
699 }; 699 };
700 700
701 if let Some(title) = title { 701 if let Some(title) = title {
diff --git a/crates/ra_prof/Cargo.toml b/crates/ra_prof/Cargo.toml
index e986019ca..84dcc9813 100644
--- a/crates/ra_prof/Cargo.toml
+++ b/crates/ra_prof/Cargo.toml
@@ -10,8 +10,8 @@ once_cell = "0.2.0"
10itertools = "0.8.0" 10itertools = "0.8.0"
11backtrace = "0.3.28" 11backtrace = "0.3.28"
12cpuprofiler = { version = "0.0.3", optional = true } 12cpuprofiler = { version = "0.0.3", optional = true }
13jemallocator = { version = "0.1.9", optional = true } 13jemallocator = { version = "0.3.2", optional = true }
14jemalloc-ctl = { version = "0.2.0", optional = true } 14jemalloc-ctl = { version = "0.3.2", optional = true }
15 15
16 16
17[features] 17[features]
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/ra_prof/src/memory_usage.rs
index 7f857942d..8e8cb7299 100644
--- a/crates/ra_prof/src/memory_usage.rs
+++ b/crates/ra_prof/src/memory_usage.rs
@@ -8,10 +8,10 @@ pub struct MemoryUsage {
8impl MemoryUsage { 8impl MemoryUsage {
9 #[cfg(feature = "jemalloc")] 9 #[cfg(feature = "jemalloc")]
10 pub fn current() -> MemoryUsage { 10 pub fn current() -> MemoryUsage {
11 jemalloc_ctl::epoch().unwrap(); 11 jemalloc_ctl::epoch::advance().unwrap();
12 MemoryUsage { 12 MemoryUsage {
13 allocated: Bytes(jemalloc_ctl::stats::allocated().unwrap()), 13 allocated: Bytes(jemalloc_ctl::stats::allocated::read().unwrap()),
14 resident: Bytes(jemalloc_ctl::stats::resident().unwrap()), 14 resident: Bytes(jemalloc_ctl::stats::resident::read().unwrap()),
15 } 15 }
16 } 16 }
17 17
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 06d3ea727..ff347a567 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -38,7 +38,7 @@ use ra_text_edit::AtomTextEdit;
38use crate::syntax_node::GreenNode; 38use crate::syntax_node::GreenNode;
39 39
40pub use crate::{ 40pub use crate::{
41 ast::AstNode, 41 ast::{AstNode, Pat, PatKind},
42 parsing::{classify_literal, tokenize, Token}, 42 parsing::{classify_literal, tokenize, Token},
43 ptr::{AstPtr, SyntaxNodePtr}, 43 ptr::{AstPtr, SyntaxNodePtr},
44 syntax_error::{Location, SyntaxError, SyntaxErrorKind}, 44 syntax_error::{Location, SyntaxError, SyntaxErrorKind},
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs
index 0550dca1a..4823eb82e 100644
--- a/crates/ra_syntax/src/ptr.rs
+++ b/crates/ra_syntax/src/ptr.rs
@@ -36,7 +36,7 @@ impl SyntaxNodePtr {
36#[derive(Debug, PartialEq, Eq, Hash)] 36#[derive(Debug, PartialEq, Eq, Hash)]
37pub struct AstPtr<N: AstNode> { 37pub struct AstPtr<N: AstNode> {
38 raw: SyntaxNodePtr, 38 raw: SyntaxNodePtr,
39 _ty: PhantomData<N>, 39 _ty: PhantomData<fn() -> N>,
40} 40}
41 41
42impl<N: AstNode> Copy for AstPtr<N> {} 42impl<N: AstNode> Copy for AstPtr<N> {}
diff --git a/editors/code/package.json b/editors/code/package.json
index 052f0b3b3..86076753b 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -433,6 +433,15 @@
433 } 433 }
434 }, 434 },
435 { 435 {
436 "id": "ralsp.variable.mut",
437 "description": "Color for mutable variables",
438 "defaults": {
439 "dark": "#4e65c9",
440 "light": "#263199",
441 "highContrast": "#4e65c9"
442 }
443 },
444 {
436 "id": "ralsp.module", 445 "id": "ralsp.module",
437 "description": "Color for modules", 446 "description": "Color for modules",
438 "defaults": { 447 "defaults": {
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 52a0bd4bb..f3ed66365 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -56,6 +56,7 @@ export class Highlighter {
56 colorContrib('literal'), 56 colorContrib('literal'),
57 colorContrib('macro'), 57 colorContrib('macro'),
58 colorContrib('variable'), 58 colorContrib('variable'),
59 colorContrib('variable.mut'),
59 colorContrib('field'), 60 colorContrib('field'),
60 colorContrib('module') 61 colorContrib('module')
61 ]; 62 ];