diff options
65 files changed, 2066 insertions, 1206 deletions
diff --git a/Cargo.lock b/Cargo.lock index d1fa5ebee..f93f11a82 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -32,7 +32,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
32 | 32 | ||
33 | [[package]] | 33 | [[package]] |
34 | name = "backtrace" | 34 | name = "backtrace" |
35 | version = "0.3.35" | 35 | version = "0.3.37" |
36 | source = "registry+https://github.com/rust-lang/crates.io-index" | 36 | source = "registry+https://github.com/rust-lang/crates.io-index" |
37 | dependencies = [ | 37 | dependencies = [ |
38 | "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", | 38 | "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -46,7 +46,7 @@ name = "backtrace-sys" | |||
46 | version = "0.1.31" | 46 | version = "0.1.31" |
47 | source = "registry+https://github.com/rust-lang/crates.io-index" | 47 | source = "registry+https://github.com/rust-lang/crates.io-index" |
48 | dependencies = [ | 48 | dependencies = [ |
49 | "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", | 49 | "cc 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", |
50 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", | 50 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", |
51 | ] | 51 | ] |
52 | 52 | ||
@@ -78,7 +78,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
78 | 78 | ||
79 | [[package]] | 79 | [[package]] |
80 | name = "bstr" | 80 | name = "bstr" |
81 | version = "0.2.7" | 81 | version = "0.2.8" |
82 | source = "registry+https://github.com/rust-lang/crates.io-index" | 82 | source = "registry+https://github.com/rust-lang/crates.io-index" |
83 | dependencies = [ | 83 | dependencies = [ |
84 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 84 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -111,7 +111,7 @@ dependencies = [ | |||
111 | 111 | ||
112 | [[package]] | 112 | [[package]] |
113 | name = "cc" | 113 | name = "cc" |
114 | version = "1.0.41" | 114 | version = "1.0.42" |
115 | source = "registry+https://github.com/rust-lang/crates.io-index" | 115 | source = "registry+https://github.com/rust-lang/crates.io-index" |
116 | 116 | ||
117 | [[package]] | 117 | [[package]] |
@@ -122,7 +122,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
122 | [[package]] | 122 | [[package]] |
123 | name = "chalk-engine" | 123 | name = "chalk-engine" |
124 | version = "0.9.0" | 124 | version = "0.9.0" |
125 | source = "git+https://github.com/rust-lang/chalk.git#c9314e425e49969c33cabcb8fac7da6eac3c5073" | 125 | source = "git+https://github.com/rust-lang/chalk.git#5c6cea8bc02c8bc282223aa12528648b5cd0b6e4" |
126 | dependencies = [ | 126 | dependencies = [ |
127 | "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)", | 127 | "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)", |
128 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 128 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -132,7 +132,7 @@ dependencies = [ | |||
132 | [[package]] | 132 | [[package]] |
133 | name = "chalk-ir" | 133 | name = "chalk-ir" |
134 | version = "0.1.0" | 134 | version = "0.1.0" |
135 | source = "git+https://github.com/rust-lang/chalk.git#c9314e425e49969c33cabcb8fac7da6eac3c5073" | 135 | source = "git+https://github.com/rust-lang/chalk.git#5c6cea8bc02c8bc282223aa12528648b5cd0b6e4" |
136 | dependencies = [ | 136 | dependencies = [ |
137 | "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", | 137 | "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", |
138 | "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)", | 138 | "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)", |
@@ -142,7 +142,7 @@ dependencies = [ | |||
142 | [[package]] | 142 | [[package]] |
143 | name = "chalk-macros" | 143 | name = "chalk-macros" |
144 | version = "0.1.1" | 144 | version = "0.1.1" |
145 | source = "git+https://github.com/rust-lang/chalk.git#c9314e425e49969c33cabcb8fac7da6eac3c5073" | 145 | source = "git+https://github.com/rust-lang/chalk.git#5c6cea8bc02c8bc282223aa12528648b5cd0b6e4" |
146 | dependencies = [ | 146 | dependencies = [ |
147 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 147 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
148 | ] | 148 | ] |
@@ -150,7 +150,7 @@ dependencies = [ | |||
150 | [[package]] | 150 | [[package]] |
151 | name = "chalk-rust-ir" | 151 | name = "chalk-rust-ir" |
152 | version = "0.1.0" | 152 | version = "0.1.0" |
153 | source = "git+https://github.com/rust-lang/chalk.git#c9314e425e49969c33cabcb8fac7da6eac3c5073" | 153 | source = "git+https://github.com/rust-lang/chalk.git#5c6cea8bc02c8bc282223aa12528648b5cd0b6e4" |
154 | dependencies = [ | 154 | dependencies = [ |
155 | "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", | 155 | "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", |
156 | "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", | 156 | "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", |
@@ -160,7 +160,7 @@ dependencies = [ | |||
160 | [[package]] | 160 | [[package]] |
161 | name = "chalk-solve" | 161 | name = "chalk-solve" |
162 | version = "0.1.0" | 162 | version = "0.1.0" |
163 | source = "git+https://github.com/rust-lang/chalk.git#c9314e425e49969c33cabcb8fac7da6eac3c5073" | 163 | source = "git+https://github.com/rust-lang/chalk.git#5c6cea8bc02c8bc282223aa12528648b5cd0b6e4" |
164 | dependencies = [ | 164 | dependencies = [ |
165 | "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", | 165 | "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)", |
166 | "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", | 166 | "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", |
@@ -176,7 +176,7 @@ dependencies = [ | |||
176 | 176 | ||
177 | [[package]] | 177 | [[package]] |
178 | name = "chrono" | 178 | name = "chrono" |
179 | version = "0.4.7" | 179 | version = "0.4.9" |
180 | source = "registry+https://github.com/rust-lang/crates.io-index" | 180 | source = "registry+https://github.com/rust-lang/crates.io-index" |
181 | dependencies = [ | 181 | dependencies = [ |
182 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", | 182 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -223,7 +223,7 @@ dependencies = [ | |||
223 | "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", | 223 | "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", |
224 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 224 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
225 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", | 225 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", |
226 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 226 | "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
227 | "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | 227 | "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
228 | "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", | 228 | "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", |
229 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | 229 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -252,15 +252,6 @@ dependencies = [ | |||
252 | 252 | ||
253 | [[package]] | 253 | [[package]] |
254 | name = "crossbeam-deque" | 254 | name = "crossbeam-deque" |
255 | version = "0.6.3" | ||
256 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
257 | dependencies = [ | ||
258 | "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", | ||
259 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", | ||
260 | ] | ||
261 | |||
262 | [[package]] | ||
263 | name = "crossbeam-deque" | ||
264 | version = "0.7.1" | 255 | version = "0.7.1" |
265 | source = "registry+https://github.com/rust-lang/crates.io-index" | 256 | source = "registry+https://github.com/rust-lang/crates.io-index" |
266 | dependencies = [ | 257 | dependencies = [ |
@@ -303,7 +294,7 @@ name = "derive-new" | |||
303 | version = "0.5.8" | 294 | version = "0.5.8" |
304 | source = "registry+https://github.com/rust-lang/crates.io-index" | 295 | source = "registry+https://github.com/rust-lang/crates.io-index" |
305 | dependencies = [ | 296 | dependencies = [ |
306 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 297 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
307 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 298 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
308 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 299 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
309 | ] | 300 | ] |
@@ -346,7 +337,7 @@ name = "failure" | |||
346 | version = "0.1.5" | 337 | version = "0.1.5" |
347 | source = "registry+https://github.com/rust-lang/crates.io-index" | 338 | source = "registry+https://github.com/rust-lang/crates.io-index" |
348 | dependencies = [ | 339 | dependencies = [ |
349 | "backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", | 340 | "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", |
350 | "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 341 | "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
351 | ] | 342 | ] |
352 | 343 | ||
@@ -363,12 +354,13 @@ dependencies = [ | |||
363 | 354 | ||
364 | [[package]] | 355 | [[package]] |
365 | name = "filetime" | 356 | name = "filetime" |
366 | version = "0.2.5" | 357 | version = "0.2.7" |
367 | source = "registry+https://github.com/rust-lang/crates.io-index" | 358 | source = "registry+https://github.com/rust-lang/crates.io-index" |
368 | dependencies = [ | 359 | dependencies = [ |
369 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | 360 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", |
370 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", | 361 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", |
371 | "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", | 362 | "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", |
363 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | ||
372 | ] | 364 | ] |
373 | 365 | ||
374 | [[package]] | 366 | [[package]] |
@@ -381,10 +373,10 @@ name = "flexi_logger" | |||
381 | version = "0.14.3" | 373 | version = "0.14.3" |
382 | source = "registry+https://github.com/rust-lang/crates.io-index" | 374 | source = "registry+https://github.com/rust-lang/crates.io-index" |
383 | dependencies = [ | 375 | dependencies = [ |
384 | "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 376 | "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", |
385 | "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 377 | "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
386 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 378 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
387 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 379 | "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
388 | "yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | 380 | "yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", |
389 | ] | 381 | ] |
390 | 382 | ||
@@ -468,10 +460,10 @@ version = "0.4.4" | |||
468 | source = "registry+https://github.com/rust-lang/crates.io-index" | 460 | source = "registry+https://github.com/rust-lang/crates.io-index" |
469 | dependencies = [ | 461 | dependencies = [ |
470 | "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", | 462 | "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", |
471 | "bstr 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", | 463 | "bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", |
472 | "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", | 464 | "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", |
473 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 465 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
474 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 466 | "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
475 | ] | 467 | ] |
476 | 468 | ||
477 | [[package]] | 469 | [[package]] |
@@ -506,7 +498,7 @@ dependencies = [ | |||
506 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 498 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
507 | "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | 499 | "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", |
508 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 500 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
509 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 501 | "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
510 | ] | 502 | ] |
511 | 503 | ||
512 | [[package]] | 504 | [[package]] |
@@ -578,7 +570,7 @@ name = "jemalloc-sys" | |||
578 | version = "0.3.2" | 570 | version = "0.3.2" |
579 | source = "registry+https://github.com/rust-lang/crates.io-index" | 571 | source = "registry+https://github.com/rust-lang/crates.io-index" |
580 | dependencies = [ | 572 | dependencies = [ |
581 | "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", | 573 | "cc 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", |
582 | "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 574 | "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
583 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", | 575 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", |
584 | ] | 576 | ] |
@@ -665,7 +657,7 @@ dependencies = [ | |||
665 | 657 | ||
666 | [[package]] | 658 | [[package]] |
667 | name = "lsp-types" | 659 | name = "lsp-types" |
668 | version = "0.60.0" | 660 | version = "0.61.0" |
669 | source = "registry+https://github.com/rust-lang/crates.io-index" | 661 | source = "registry+https://github.com/rust-lang/crates.io-index" |
670 | dependencies = [ | 662 | dependencies = [ |
671 | "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 663 | "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -749,11 +741,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
749 | 741 | ||
750 | [[package]] | 742 | [[package]] |
751 | name = "notify" | 743 | name = "notify" |
752 | version = "4.0.12" | 744 | version = "4.0.13" |
753 | source = "registry+https://github.com/rust-lang/crates.io-index" | 745 | source = "registry+https://github.com/rust-lang/crates.io-index" |
754 | dependencies = [ | 746 | dependencies = [ |
755 | "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 747 | "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
756 | "filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", | 748 | "filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", |
757 | "fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 749 | "fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
758 | "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 750 | "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
759 | "inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", | 751 | "inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -800,7 +792,7 @@ dependencies = [ | |||
800 | 792 | ||
801 | [[package]] | 793 | [[package]] |
802 | name = "once_cell" | 794 | name = "once_cell" |
803 | version = "1.0.1" | 795 | version = "1.0.2" |
804 | source = "registry+https://github.com/rust-lang/crates.io-index" | 796 | source = "registry+https://github.com/rust-lang/crates.io-index" |
805 | 797 | ||
806 | [[package]] | 798 | [[package]] |
@@ -847,7 +839,7 @@ version = "0.1.6" | |||
847 | source = "registry+https://github.com/rust-lang/crates.io-index" | 839 | source = "registry+https://github.com/rust-lang/crates.io-index" |
848 | dependencies = [ | 840 | dependencies = [ |
849 | "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", | 841 | "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", |
850 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 842 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
851 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 843 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
852 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 844 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
853 | ] | 845 | ] |
@@ -876,7 +868,7 @@ name = "proc-macro-hack" | |||
876 | version = "0.5.9" | 868 | version = "0.5.9" |
877 | source = "registry+https://github.com/rust-lang/crates.io-index" | 869 | source = "registry+https://github.com/rust-lang/crates.io-index" |
878 | dependencies = [ | 870 | dependencies = [ |
879 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 871 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
880 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 872 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
881 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 873 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
882 | ] | 874 | ] |
@@ -891,7 +883,7 @@ dependencies = [ | |||
891 | 883 | ||
892 | [[package]] | 884 | [[package]] |
893 | name = "proc-macro2" | 885 | name = "proc-macro2" |
894 | version = "1.0.1" | 886 | version = "1.0.2" |
895 | source = "registry+https://github.com/rust-lang/crates.io-index" | 887 | source = "registry+https://github.com/rust-lang/crates.io-index" |
896 | dependencies = [ | 888 | dependencies = [ |
897 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 889 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -911,7 +903,7 @@ dependencies = [ | |||
911 | "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 903 | "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", |
912 | "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 904 | "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", |
913 | "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 905 | "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", |
914 | "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", | 906 | "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", |
915 | ] | 907 | ] |
916 | 908 | ||
917 | [[package]] | 909 | [[package]] |
@@ -932,7 +924,7 @@ name = "quote" | |||
932 | version = "1.0.2" | 924 | version = "1.0.2" |
933 | source = "registry+https://github.com/rust-lang/crates.io-index" | 925 | source = "registry+https://github.com/rust-lang/crates.io-index" |
934 | dependencies = [ | 926 | dependencies = [ |
935 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 927 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
936 | ] | 928 | ] |
937 | 929 | ||
938 | [[package]] | 930 | [[package]] |
@@ -947,7 +939,7 @@ dependencies = [ | |||
947 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 939 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
948 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 940 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
949 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 941 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
950 | "once_cell 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 942 | "once_cell 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
951 | "ra_db 0.1.0", | 943 | "ra_db 0.1.0", |
952 | "ra_fmt 0.1.0", | 944 | "ra_fmt 0.1.0", |
953 | "ra_hir 0.1.0", | 945 | "ra_hir 0.1.0", |
@@ -966,7 +958,7 @@ dependencies = [ | |||
966 | "ra_hir 0.1.0", | 958 | "ra_hir 0.1.0", |
967 | "ra_ide_api 0.1.0", | 959 | "ra_ide_api 0.1.0", |
968 | "ra_project_model 0.1.0", | 960 | "ra_project_model 0.1.0", |
969 | "ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 961 | "ra_vfs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
970 | "ra_vfs_glob 0.1.0", | 962 | "ra_vfs_glob 0.1.0", |
971 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 963 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
972 | ] | 964 | ] |
@@ -1017,7 +1009,7 @@ dependencies = [ | |||
1017 | "insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1009 | "insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1018 | "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1010 | "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1019 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1011 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1020 | "once_cell 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1012 | "once_cell 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1021 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1013 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1022 | "ra_arena 0.1.0", | 1014 | "ra_arena 0.1.0", |
1023 | "ra_db 0.1.0", | 1015 | "ra_db 0.1.0", |
@@ -1049,12 +1041,12 @@ dependencies = [ | |||
1049 | "ra_syntax 0.1.0", | 1041 | "ra_syntax 0.1.0", |
1050 | "ra_text_edit 0.1.0", | 1042 | "ra_text_edit 0.1.0", |
1051 | "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1043 | "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1052 | "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1044 | "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1053 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1045 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1054 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1046 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1055 | "superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1047 | "superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1056 | "test_utils 0.1.0", | 1048 | "test_utils 0.1.0", |
1057 | "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1049 | "unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1058 | ] | 1050 | ] |
1059 | 1051 | ||
1060 | [[package]] | 1052 | [[package]] |
@@ -1066,14 +1058,14 @@ dependencies = [ | |||
1066 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1058 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1067 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1059 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1068 | "lsp-server 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1060 | "lsp-server 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1069 | "lsp-types 0.60.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1061 | "lsp-types 0.61.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1070 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1062 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1071 | "ra_ide_api 0.1.0", | 1063 | "ra_ide_api 0.1.0", |
1072 | "ra_prof 0.1.0", | 1064 | "ra_prof 0.1.0", |
1073 | "ra_project_model 0.1.0", | 1065 | "ra_project_model 0.1.0", |
1074 | "ra_syntax 0.1.0", | 1066 | "ra_syntax 0.1.0", |
1075 | "ra_text_edit 0.1.0", | 1067 | "ra_text_edit 0.1.0", |
1076 | "ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1068 | "ra_vfs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1077 | "ra_vfs_glob 0.1.0", | 1069 | "ra_vfs_glob 0.1.0", |
1078 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1070 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1079 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1071 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1108,11 +1100,11 @@ dependencies = [ | |||
1108 | name = "ra_prof" | 1100 | name = "ra_prof" |
1109 | version = "0.1.0" | 1101 | version = "0.1.0" |
1110 | dependencies = [ | 1102 | dependencies = [ |
1111 | "backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)", | 1103 | "backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)", |
1112 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1104 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1113 | "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1105 | "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1114 | "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1106 | "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1115 | "once_cell 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1107 | "once_cell 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1116 | ] | 1108 | ] |
1117 | 1109 | ||
1118 | [[package]] | 1110 | [[package]] |
@@ -1129,22 +1121,14 @@ dependencies = [ | |||
1129 | ] | 1121 | ] |
1130 | 1122 | ||
1131 | [[package]] | 1123 | [[package]] |
1132 | name = "ra_rustc_lexer" | ||
1133 | version = "0.1.0-pre.3" | ||
1134 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1135 | dependencies = [ | ||
1136 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1137 | ] | ||
1138 | |||
1139 | [[package]] | ||
1140 | name = "ra_syntax" | 1124 | name = "ra_syntax" |
1141 | version = "0.1.0" | 1125 | version = "0.1.0" |
1142 | dependencies = [ | 1126 | dependencies = [ |
1143 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1127 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1144 | "ra_parser 0.1.0", | 1128 | "ra_parser 0.1.0", |
1145 | "ra_rustc_lexer 0.1.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1146 | "ra_text_edit 0.1.0", | 1129 | "ra_text_edit 0.1.0", |
1147 | "rowan 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1130 | "rowan 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1131 | "rustc_lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1148 | "smol_str 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", | 1132 | "smol_str 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", |
1149 | "test_utils 0.1.0", | 1133 | "test_utils 0.1.0", |
1150 | "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | 1134 | "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1165,7 +1149,7 @@ version = "0.1.0" | |||
1165 | dependencies = [ | 1149 | dependencies = [ |
1166 | "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1150 | "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1167 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1151 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1168 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1152 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1169 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1153 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1170 | "ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1154 | "ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1171 | "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", | 1155 | "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1181,13 +1165,13 @@ dependencies = [ | |||
1181 | 1165 | ||
1182 | [[package]] | 1166 | [[package]] |
1183 | name = "ra_vfs" | 1167 | name = "ra_vfs" |
1184 | version = "0.3.0" | 1168 | version = "0.4.0" |
1185 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1169 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1186 | dependencies = [ | 1170 | dependencies = [ |
1187 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", | 1171 | "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", |
1188 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1172 | "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1189 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1173 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1190 | "notify 4.0.12 (registry+https://github.com/rust-lang/crates.io-index)", | 1174 | "notify 4.0.13 (registry+https://github.com/rust-lang/crates.io-index)", |
1191 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1175 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1192 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1176 | "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1193 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1177 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1199,7 +1183,7 @@ name = "ra_vfs_glob" | |||
1199 | version = "0.1.0" | 1183 | version = "0.1.0" |
1200 | dependencies = [ | 1184 | dependencies = [ |
1201 | "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", | 1185 | "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", |
1202 | "ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1186 | "ra_vfs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1203 | ] | 1187 | ] |
1204 | 1188 | ||
1205 | [[package]] | 1189 | [[package]] |
@@ -1347,20 +1331,20 @@ dependencies = [ | |||
1347 | 1331 | ||
1348 | [[package]] | 1332 | [[package]] |
1349 | name = "rayon" | 1333 | name = "rayon" |
1350 | version = "1.1.0" | 1334 | version = "1.2.0" |
1351 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1335 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1352 | dependencies = [ | 1336 | dependencies = [ |
1353 | "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1337 | "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1354 | "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1338 | "either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1355 | "rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1339 | "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1356 | ] | 1340 | ] |
1357 | 1341 | ||
1358 | [[package]] | 1342 | [[package]] |
1359 | name = "rayon-core" | 1343 | name = "rayon-core" |
1360 | version = "1.5.0" | 1344 | version = "1.6.0" |
1361 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1345 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1362 | dependencies = [ | 1346 | dependencies = [ |
1363 | "crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1347 | "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1364 | "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1348 | "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1365 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1349 | "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1366 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1350 | "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1382,18 +1366,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1382 | 1366 | ||
1383 | [[package]] | 1367 | [[package]] |
1384 | name = "regex" | 1368 | name = "regex" |
1385 | version = "1.2.1" | 1369 | version = "1.3.1" |
1386 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1370 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1387 | dependencies = [ | 1371 | dependencies = [ |
1388 | "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1372 | "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1389 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1373 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1390 | "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", | 1374 | "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", |
1391 | "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1375 | "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1392 | ] | 1376 | ] |
1393 | 1377 | ||
1394 | [[package]] | 1378 | [[package]] |
1395 | name = "regex-syntax" | 1379 | name = "regex-syntax" |
1396 | version = "0.6.11" | 1380 | version = "0.6.12" |
1397 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1381 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1398 | 1382 | ||
1399 | [[package]] | 1383 | [[package]] |
@@ -1443,6 +1427,14 @@ dependencies = [ | |||
1443 | ] | 1427 | ] |
1444 | 1428 | ||
1445 | [[package]] | 1429 | [[package]] |
1430 | name = "rustc_lexer" | ||
1431 | version = "0.1.0" | ||
1432 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1433 | dependencies = [ | ||
1434 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1435 | ] | ||
1436 | |||
1437 | [[package]] | ||
1446 | name = "rustc_version" | 1438 | name = "rustc_version" |
1447 | version = "0.2.3" | 1439 | version = "0.2.3" |
1448 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1440 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1477,7 +1469,7 @@ version = "0.13.1" | |||
1477 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1469 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1478 | dependencies = [ | 1470 | dependencies = [ |
1479 | "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1471 | "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1480 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1472 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1481 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1473 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1482 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1474 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1483 | ] | 1475 | ] |
@@ -1522,7 +1514,7 @@ name = "serde_derive" | |||
1522 | version = "1.0.99" | 1514 | version = "1.0.99" |
1523 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1515 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1524 | dependencies = [ | 1516 | dependencies = [ |
1525 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1517 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1526 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1518 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1527 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1519 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1528 | ] | 1520 | ] |
@@ -1542,7 +1534,7 @@ name = "serde_repr" | |||
1542 | version = "0.1.5" | 1534 | version = "0.1.5" |
1543 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1535 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1544 | dependencies = [ | 1536 | dependencies = [ |
1545 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1537 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1546 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1538 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1547 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1539 | "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1548 | ] | 1540 | ] |
@@ -1581,7 +1573,7 @@ name = "stacker" | |||
1581 | version = "0.1.5" | 1573 | version = "0.1.5" |
1582 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1574 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1583 | dependencies = [ | 1575 | dependencies = [ |
1584 | "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", | 1576 | "cc 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", |
1585 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", | 1577 | "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", |
1586 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", | 1578 | "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", |
1587 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1579 | "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1607,7 +1599,7 @@ name = "syn" | |||
1607 | version = "1.0.5" | 1599 | version = "1.0.5" |
1608 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1600 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1609 | dependencies = [ | 1601 | dependencies = [ |
1610 | "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1602 | "proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1611 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1603 | "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1612 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1604 | "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1613 | ] | 1605 | ] |
@@ -1694,7 +1686,7 @@ dependencies = [ | |||
1694 | 1686 | ||
1695 | [[package]] | 1687 | [[package]] |
1696 | name = "unicase" | 1688 | name = "unicase" |
1697 | version = "2.4.0" | 1689 | version = "2.5.1" |
1698 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1690 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1699 | dependencies = [ | 1691 | dependencies = [ |
1700 | "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1692 | "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1847,31 +1839,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1847 | "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" | 1839 | "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" |
1848 | "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" | 1840 | "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" |
1849 | "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" | 1841 | "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" |
1850 | "checksum backtrace 0.3.35 (registry+https://github.com/rust-lang/crates.io-index)" = "1371048253fa3bac6704bfd6bbfc922ee9bdcee8881330d40f308b81cc5adc55" | 1842 | "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" |
1851 | "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" | 1843 | "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" |
1852 | "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" | 1844 | "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" |
1853 | "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" | 1845 | "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" |
1854 | "checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" | 1846 | "checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" |
1855 | "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" | 1847 | "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" |
1856 | "checksum bstr 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94cdf78eb7e94c566c1f5dbe2abf8fc70a548fc902942a48c4b3a98b48ca9ade" | 1848 | "checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" |
1857 | "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" | 1849 | "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" |
1858 | "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" | 1850 | "checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" |
1859 | "checksum cargo_metadata 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "700b3731fd7d357223d0000f4dbf1808401b694609035c3c411fbc0cd375c426" | 1851 | "checksum cargo_metadata 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "700b3731fd7d357223d0000f4dbf1808401b694609035c3c411fbc0cd375c426" |
1860 | "checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" | 1852 | "checksum cc 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)" = "a61c7bce55cd2fae6ec8cb935ebd76256c2959a1f95790f6118a441c2cd5b406" |
1861 | "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" | 1853 | "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" |
1862 | "checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" | 1854 | "checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" |
1863 | "checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" | 1855 | "checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" |
1864 | "checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)" = "<none>" | 1856 | "checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git)" = "<none>" |
1865 | "checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" | 1857 | "checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" |
1866 | "checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" | 1858 | "checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)" = "<none>" |
1867 | "checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" | 1859 | "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" |
1868 | "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" | 1860 | "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" |
1869 | "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" | 1861 | "checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" |
1870 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" | 1862 | "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" |
1871 | "checksum console 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242" | 1863 | "checksum console 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242" |
1872 | "checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" | 1864 | "checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" |
1873 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" | 1865 | "checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" |
1874 | "checksum crossbeam-deque 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05e44b8cf3e1a625844d1750e1f7820da46044ff6d28f4d43e455ba3e5bb2c13" | ||
1875 | "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" | 1866 | "checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" |
1876 | "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" | 1867 | "checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" |
1877 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" | 1868 | "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" |
@@ -1885,7 +1876,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1885 | "checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" | 1876 | "checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" |
1886 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" | 1877 | "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" |
1887 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" | 1878 | "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" |
1888 | "checksum filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2f8c63033fcba1f51ef744505b3cad42510432b904c062afa67ad7ece008429d" | 1879 | "checksum filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd7380b54ced79dda72ecc35cc4fbbd1da6bba54afaa37e96fd1c2a308cd469" |
1889 | "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" | 1880 | "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" |
1890 | "checksum flexi_logger 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66473c1b6a0d2a72f6ed983d33021a4c744a1d179e6f4265867b7d0a9dd679c5" | 1881 | "checksum flexi_logger 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)" = "66473c1b6a0d2a72f6ed983d33021a4c744a1d179e6f4265867b7d0a9dd679c5" |
1891 | "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" | 1882 | "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" |
@@ -1924,7 +1915,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1924 | "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" | 1915 | "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" |
1925 | "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" | 1916 | "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" |
1926 | "checksum lsp-server 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "148cfb1c0b3295c23d9fb4a20fd1b242f5e6f46c525fdcc7f5c0a65710362012" | 1917 | "checksum lsp-server 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "148cfb1c0b3295c23d9fb4a20fd1b242f5e6f46c525fdcc7f5c0a65710362012" |
1927 | "checksum lsp-types 0.60.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3edefcd66dde1f7f1df706f46520a3c93adc5ca4bc5747da6621195e894efd" | 1918 | "checksum lsp-types 0.61.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa3268fbe8beb2795c2fb327bf44f4f3d24f5fe9ebc18d7e2980afd444d72bcf" |
1928 | "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" | 1919 | "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" |
1929 | "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" | 1920 | "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" |
1930 | "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" | 1921 | "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" |
@@ -1933,12 +1924,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1933 | "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" | 1924 | "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" |
1934 | "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" | 1925 | "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" |
1935 | "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" | 1926 | "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" |
1936 | "checksum notify 4.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "3572d71f13ea8ed41867accd971fd564aa75934cf7a1fae03ddb8c74a8a49943" | 1927 | "checksum notify 4.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1191efa2b8fe041decb55c238a125b7a1aeb6fad7a525133a02be5ec949ff3cb" |
1937 | "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" | 1928 | "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" |
1938 | "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" | 1929 | "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" |
1939 | "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" | 1930 | "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" |
1940 | "checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee" | 1931 | "checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee" |
1941 | "checksum once_cell 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c9192c5a4c3b5488dae8d3886ef9df6b5eb246d36323dc7a5078595a154e7771" | 1932 | "checksum once_cell 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd38c1bb51148ca239ec38ef1bb4f7570d432861f03e91774d53b01c2ba2132f" |
1942 | "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" | 1933 | "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" |
1943 | "checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" | 1934 | "checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" |
1944 | "checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" | 1935 | "checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" |
@@ -1949,13 +1940,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1949 | "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" | 1940 | "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" |
1950 | "checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" | 1941 | "checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" |
1951 | "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" | 1942 | "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" |
1952 | "checksum proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5c2380ae88876faae57698be9e9775e3544decad214599c3a6266cca6ac802" | 1943 | "checksum proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "175a40b9cf564ce9bf050654633dbf339978706b8ead1a907bb970b63185dd95" |
1953 | "checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f" | 1944 | "checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f" |
1954 | "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" | 1945 | "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" |
1955 | "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" | 1946 | "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" |
1956 | "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" | 1947 | "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" |
1957 | "checksum ra_rustc_lexer 0.1.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)" = "04371af481820ff8d35c7d12b503eb09cf9e1bd246269bf4a33e3d8c54fa3a4a" | 1948 | "checksum ra_vfs 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdf6a0926414eb0c00866eb9274894182302f879cd06b5459c1d8ee7f1234aed" |
1958 | "checksum ra_vfs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc8b709e0b7ceec822513451b610df1b9370b01953a8bc545a041a6b3bfef01" | ||
1959 | "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" | 1949 | "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" |
1960 | "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" | 1950 | "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" |
1961 | "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" | 1951 | "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" |
@@ -1971,18 +1961,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1971 | "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" | 1961 | "checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" |
1972 | "checksum rand_pcg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e196346cbbc5c70c77e7b4926147ee8e383a38ee4d15d58a08098b169e492b6" | 1962 | "checksum rand_pcg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e196346cbbc5c70c77e7b4926147ee8e383a38ee4d15d58a08098b169e492b6" |
1973 | "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" | 1963 | "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" |
1974 | "checksum rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b0186e22767d5b9738a05eab7c6ac90b15db17e5b5f9bd87976dd7d89a10a4" | 1964 | "checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" |
1975 | "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" | 1965 | "checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" |
1976 | "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" | 1966 | "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" |
1977 | "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" | 1967 | "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" |
1978 | "checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" | 1968 | "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" |
1979 | "checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" | 1969 | "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" |
1980 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" | 1970 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" |
1981 | "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" | 1971 | "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" |
1982 | "checksum ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ece421e0c4129b90e4a35b6f625e472e96c552136f5093a2f4fa2bbb75a62d5" | 1972 | "checksum ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ece421e0c4129b90e4a35b6f625e472e96c552136f5093a2f4fa2bbb75a62d5" |
1983 | "checksum rowan 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dc2b79612dedc9004083a61448eb669d336d56690aab29fbd7249e8c8ab41d8c" | 1973 | "checksum rowan 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dc2b79612dedc9004083a61448eb669d336d56690aab29fbd7249e8c8ab41d8c" |
1984 | "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" | 1974 | "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" |
1985 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 1975 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
1976 | "checksum rustc_lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c86aae0c77166108c01305ee1a36a1e77289d7dc6ca0a3cd91ff4992de2d16a5" | ||
1986 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 1977 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
1987 | "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" | 1978 | "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" |
1988 | "checksum salsa 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3265a2a9bbd384bd2a9f9511c2c18fb41f62c412516052e8934517dc8ff64f1" | 1979 | "checksum salsa 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3265a2a9bbd384bd2a9f9511c2c18fb41f62c412516052e8934517dc8ff64f1" |
@@ -2011,7 +2002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2011 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" | 2002 | "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" |
2012 | "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" | 2003 | "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" |
2013 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" | 2004 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" |
2014 | "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" | 2005 | "checksum unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" |
2015 | "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" | 2006 | "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" |
2016 | "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" | 2007 | "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" |
2017 | "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" | 2008 | "checksum unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1967f4cdfc355b37fd76d2a954fb2ed3871034eb4f26d60537d88795cfc332a9" |
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index 048478662..a710edce8 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -297,6 +297,11 @@ impl AstBuilder<ast::Path> { | |||
297 | ast_node_from_file_text(text) | 297 | ast_node_from_file_text(text) |
298 | } | 298 | } |
299 | 299 | ||
300 | pub fn from_name(name: ast::Name) -> ast::Path { | ||
301 | let name = name.syntax().to_string(); | ||
302 | Self::from_text(name.as_str()) | ||
303 | } | ||
304 | |||
300 | pub fn from_pieces(enum_name: ast::Name, var_name: ast::Name) -> ast::Path { | 305 | pub fn from_pieces(enum_name: ast::Name, var_name: ast::Name) -> ast::Path { |
301 | Self::from_text(&format!("{}::{}", enum_name.syntax(), var_name.syntax())) | 306 | Self::from_text(&format!("{}::{}", enum_name.syntax(), var_name.syntax())) |
302 | } | 307 | } |
@@ -380,6 +385,31 @@ impl AstBuilder<ast::MatchArmList> { | |||
380 | } | 385 | } |
381 | } | 386 | } |
382 | 387 | ||
388 | impl AstBuilder<ast::WherePred> { | ||
389 | fn from_text(text: &str) -> ast::WherePred { | ||
390 | ast_node_from_file_text(&format!("fn f() where {} {{ }}", text)) | ||
391 | } | ||
392 | |||
393 | pub fn from_pieces( | ||
394 | path: ast::Path, | ||
395 | bounds: impl Iterator<Item = ast::TypeBound>, | ||
396 | ) -> ast::WherePred { | ||
397 | let bounds = bounds.map(|b| b.syntax().to_string()).collect::<Vec<_>>().join(" + "); | ||
398 | Self::from_text(&format!("{}: {}", path.syntax(), bounds)) | ||
399 | } | ||
400 | } | ||
401 | |||
402 | impl AstBuilder<ast::WhereClause> { | ||
403 | fn from_text(text: &str) -> ast::WhereClause { | ||
404 | ast_node_from_file_text(&format!("fn f() where {} {{ }}", text)) | ||
405 | } | ||
406 | |||
407 | pub fn from_predicates(preds: impl Iterator<Item = ast::WherePred>) -> ast::WhereClause { | ||
408 | let preds = preds.map(|p| p.syntax().to_string()).collect::<Vec<_>>().join(", "); | ||
409 | Self::from_text(preds.as_str()) | ||
410 | } | ||
411 | } | ||
412 | |||
383 | fn ast_node_from_file_text<N: AstNode>(text: &str) -> N { | 413 | fn ast_node_from_file_text<N: AstNode>(text: &str) -> N { |
384 | let parse = SourceFile::parse(text); | 414 | let parse = SourceFile::parse(text); |
385 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); | 415 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 03eec73ad..10ccc345c 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -102,6 +102,7 @@ mod remove_dbg; | |||
102 | pub mod auto_import; | 102 | pub mod auto_import; |
103 | mod add_missing_impl_members; | 103 | mod add_missing_impl_members; |
104 | mod move_guard; | 104 | mod move_guard; |
105 | mod move_bounds; | ||
105 | 106 | ||
106 | fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assist>] { | 107 | fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assist>] { |
107 | &[ | 108 | &[ |
@@ -123,6 +124,7 @@ fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assis | |||
123 | inline_local_variable::inline_local_varialbe, | 124 | inline_local_variable::inline_local_varialbe, |
124 | move_guard::move_guard_to_arm_body, | 125 | move_guard::move_guard_to_arm_body, |
125 | move_guard::move_arm_cond_to_match_guard, | 126 | move_guard::move_arm_cond_to_match_guard, |
127 | move_bounds::move_bounds_to_where_clause, | ||
126 | ] | 128 | ] |
127 | } | 129 | } |
128 | 130 | ||
diff --git a/crates/ra_assists/src/move_bounds.rs b/crates/ra_assists/src/move_bounds.rs new file mode 100644 index 000000000..526de1d98 --- /dev/null +++ b/crates/ra_assists/src/move_bounds.rs | |||
@@ -0,0 +1,135 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | ||
3 | ast::{self, AstNode, NameOwner, TypeBoundsOwner}, | ||
4 | SyntaxElement, | ||
5 | SyntaxKind::*, | ||
6 | TextRange, | ||
7 | }; | ||
8 | |||
9 | use crate::{ast_editor::AstBuilder, Assist, AssistCtx, AssistId}; | ||
10 | |||
11 | pub(crate) fn move_bounds_to_where_clause(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | ||
12 | let type_param_list = ctx.node_at_offset::<ast::TypeParamList>()?; | ||
13 | |||
14 | let mut type_params = type_param_list.type_params(); | ||
15 | if type_params.all(|p| p.type_bound_list().is_none()) { | ||
16 | return None; | ||
17 | } | ||
18 | |||
19 | let parent = type_param_list.syntax().parent()?; | ||
20 | if parent.children_with_tokens().find(|it| it.kind() == WHERE_CLAUSE).is_some() { | ||
21 | return None; | ||
22 | } | ||
23 | |||
24 | let anchor: SyntaxElement = match parent.kind() { | ||
25 | FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), | ||
26 | TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), | ||
27 | IMPL_BLOCK => ast::ImplBlock::cast(parent)?.item_list()?.syntax().clone().into(), | ||
28 | ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), | ||
29 | STRUCT_DEF => parent | ||
30 | .children_with_tokens() | ||
31 | .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == SEMI)?, | ||
32 | _ => return None, | ||
33 | }; | ||
34 | |||
35 | ctx.add_action( | ||
36 | AssistId("move_bounds_to_where_clause"), | ||
37 | "move_bounds_to_where_clause", | ||
38 | |edit| { | ||
39 | let type_params = type_param_list.type_params().collect::<Vec<_>>(); | ||
40 | |||
41 | for param in &type_params { | ||
42 | if let Some(bounds) = param.type_bound_list() { | ||
43 | let colon = param | ||
44 | .syntax() | ||
45 | .children_with_tokens() | ||
46 | .find(|it| it.kind() == COLON) | ||
47 | .unwrap(); | ||
48 | let start = colon.text_range().start(); | ||
49 | let end = bounds.syntax().text_range().end(); | ||
50 | edit.delete(TextRange::from_to(start, end)); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | let predicates = type_params.iter().filter_map(build_predicate); | ||
55 | let where_clause = AstBuilder::<ast::WhereClause>::from_predicates(predicates); | ||
56 | |||
57 | let to_insert = match anchor.prev_sibling_or_token() { | ||
58 | Some(ref elem) if elem.kind() == WHITESPACE => { | ||
59 | format!("{} ", where_clause.syntax()) | ||
60 | } | ||
61 | _ => format!(" {}", where_clause.syntax()), | ||
62 | }; | ||
63 | edit.insert(anchor.text_range().start(), to_insert); | ||
64 | edit.target(type_param_list.syntax().text_range()); | ||
65 | }, | ||
66 | ); | ||
67 | |||
68 | ctx.build() | ||
69 | } | ||
70 | |||
71 | fn build_predicate(param: &ast::TypeParam) -> Option<ast::WherePred> { | ||
72 | let path = AstBuilder::<ast::Path>::from_name(param.name()?); | ||
73 | let predicate = | ||
74 | AstBuilder::<ast::WherePred>::from_pieces(path, param.type_bound_list()?.bounds()); | ||
75 | Some(predicate) | ||
76 | } | ||
77 | |||
78 | #[cfg(test)] | ||
79 | mod tests { | ||
80 | use super::*; | ||
81 | |||
82 | use crate::helpers::check_assist; | ||
83 | |||
84 | #[test] | ||
85 | fn move_bounds_to_where_clause_fn() { | ||
86 | check_assist( | ||
87 | move_bounds_to_where_clause, | ||
88 | r#" | ||
89 | fn foo<T: u32, <|>F: FnOnce(T) -> T>() {} | ||
90 | "#, | ||
91 | r#" | ||
92 | fn foo<T, <|>F>() where T: u32, F: FnOnce(T) -> T {} | ||
93 | "#, | ||
94 | ); | ||
95 | } | ||
96 | |||
97 | #[test] | ||
98 | fn move_bounds_to_where_clause_impl() { | ||
99 | check_assist( | ||
100 | move_bounds_to_where_clause, | ||
101 | r#" | ||
102 | impl<U: u32, <|>T> A<U, T> {} | ||
103 | "#, | ||
104 | r#" | ||
105 | impl<U, <|>T> A<U, T> where U: u32 {} | ||
106 | "#, | ||
107 | ); | ||
108 | } | ||
109 | |||
110 | #[test] | ||
111 | fn move_bounds_to_where_clause_struct() { | ||
112 | check_assist( | ||
113 | move_bounds_to_where_clause, | ||
114 | r#" | ||
115 | struct A<<|>T: Iterator<Item = u32>> {} | ||
116 | "#, | ||
117 | r#" | ||
118 | struct A<<|>T> where T: Iterator<Item = u32> {} | ||
119 | "#, | ||
120 | ); | ||
121 | } | ||
122 | |||
123 | #[test] | ||
124 | fn move_bounds_to_where_clause_tuple_struct() { | ||
125 | check_assist( | ||
126 | move_bounds_to_where_clause, | ||
127 | r#" | ||
128 | struct Pair<<|>T: u32>(T, T); | ||
129 | "#, | ||
130 | r#" | ||
131 | struct Pair<<|>T>(T, T) where T: u32; | ||
132 | "#, | ||
133 | ); | ||
134 | } | ||
135 | } | ||
diff --git a/crates/ra_batch/Cargo.toml b/crates/ra_batch/Cargo.toml index 5fc2703ee..62850746f 100644 --- a/crates/ra_batch/Cargo.toml +++ b/crates/ra_batch/Cargo.toml | |||
@@ -9,7 +9,7 @@ log = "0.4.5" | |||
9 | rustc-hash = "1.0" | 9 | rustc-hash = "1.0" |
10 | crossbeam-channel = "0.3.5" | 10 | crossbeam-channel = "0.3.5" |
11 | 11 | ||
12 | ra_vfs = "0.3.0" | 12 | ra_vfs = "0.4.0" |
13 | ra_vfs_glob = { path = "../ra_vfs_glob" } | 13 | ra_vfs_glob = { path = "../ra_vfs_glob" } |
14 | ra_db = { path = "../ra_db" } | 14 | ra_db = { path = "../ra_db" } |
15 | ra_ide_api = { path = "../ra_ide_api" } | 15 | ra_ide_api = { path = "../ra_ide_api" } |
diff --git a/crates/ra_batch/src/lib.rs b/crates/ra_batch/src/lib.rs index 4e5bad044..07a7e0c86 100644 --- a/crates/ra_batch/src/lib.rs +++ b/crates/ra_batch/src/lib.rs | |||
@@ -6,7 +6,7 @@ use crossbeam_channel::{unbounded, Receiver}; | |||
6 | use ra_db::{CrateGraph, FileId, SourceRootId}; | 6 | use ra_db::{CrateGraph, FileId, SourceRootId}; |
7 | use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; | 7 | use ra_ide_api::{AnalysisChange, AnalysisHost, FeatureFlags}; |
8 | use ra_project_model::{PackageRoot, ProjectWorkspace}; | 8 | use ra_project_model::{PackageRoot, ProjectWorkspace}; |
9 | use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask}; | 9 | use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; |
10 | use ra_vfs_glob::RustPackageFilterBuilder; | 10 | use ra_vfs_glob::RustPackageFilterBuilder; |
11 | 11 | ||
12 | type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; | 12 | type Result<T> = std::result::Result<T, Box<dyn Error + Send + Sync>>; |
@@ -37,6 +37,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId, | |||
37 | }) | 37 | }) |
38 | .collect(), | 38 | .collect(), |
39 | sender, | 39 | sender, |
40 | Watch(false), | ||
40 | ); | 41 | ); |
41 | let crate_graph = ws.to_crate_graph(&mut |path: &Path| { | 42 | let crate_graph = ws.to_crate_graph(&mut |path: &Path| { |
42 | let vfs_file = vfs.load(path); | 43 | let vfs_file = vfs.load(path); |
diff --git a/crates/ra_cli/src/analysis_bench.rs b/crates/ra_cli/src/analysis_bench.rs index 9e76bcebf..01b96ec58 100644 --- a/crates/ra_cli/src/analysis_bench.rs +++ b/crates/ra_cli/src/analysis_bench.rs | |||
@@ -34,10 +34,11 @@ pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { | |||
34 | .iter() | 34 | .iter() |
35 | .find_map(|(source_root_id, project_root)| { | 35 | .find_map(|(source_root_id, project_root)| { |
36 | if project_root.is_member() { | 36 | if project_root.is_member() { |
37 | for (rel_path, file_id) in &db.source_root(*source_root_id).files { | 37 | for file_id in db.source_root(*source_root_id).walk() { |
38 | let rel_path = db.file_relative_path(file_id); | ||
38 | let abs_path = rel_path.to_path(project_root.path()); | 39 | let abs_path = rel_path.to_path(project_root.path()); |
39 | if abs_path == path { | 40 | if abs_path == path { |
40 | return Some(*file_id); | 41 | return Some(file_id); |
41 | } | 42 | } |
42 | } | 43 | } |
43 | } | 44 | } |
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index d355fa2e8..1fad5b233 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; | 1 | use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; |
2 | 2 | ||
3 | use ra_db::SourceDatabase; | 3 | use ra_db::SourceDatabase; |
4 | use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty}; | 4 | use ra_hir::{Crate, HasBodySource, HasSource, HirDisplay, ImplItem, ModuleDef, Ty, TypeWalk}; |
5 | use ra_syntax::AstNode; | 5 | use ra_syntax::AstNode; |
6 | 6 | ||
7 | use crate::Result; | 7 | use crate::Result; |
@@ -110,9 +110,12 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) - | |||
110 | let original_file = src.file_id.original_file(db); | 110 | let original_file = src.file_id.original_file(db); |
111 | let path = db.file_relative_path(original_file); | 111 | let path = db.file_relative_path(original_file); |
112 | let line_index = host.analysis().file_line_index(original_file).unwrap(); | 112 | let line_index = host.analysis().file_line_index(original_file).unwrap(); |
113 | let text_range = src | ||
114 | .ast | ||
115 | .either(|it| it.syntax().text_range(), |it| it.syntax().text_range()); | ||
113 | let (start, end) = ( | 116 | let (start, end) = ( |
114 | line_index.line_col(src.ast.syntax().text_range().start()), | 117 | line_index.line_col(text_range.start()), |
115 | line_index.line_col(src.ast.syntax().text_range().end()), | 118 | line_index.line_col(text_range.end()), |
116 | ); | 119 | ); |
117 | bar.println(format!( | 120 | bar.println(format!( |
118 | "{} {}:{}-{}:{}: Expected {}, got {}", | 121 | "{} {}:{}-{}:{}: Expected {}, got {}", |
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index ad8e10c52..d1ee3c036 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -5,7 +5,7 @@ | |||
5 | /// Note that neither this module, nor any other part of the analyzer's core do | 5 | /// Note that neither this module, nor any other part of the analyzer's core do |
6 | /// actual IO. See `vfs` and `project_model` in the `ra_lsp_server` crate for how | 6 | /// actual IO. See `vfs` and `project_model` in the `ra_lsp_server` crate for how |
7 | /// actual IO is done and lowered to input. | 7 | /// actual IO is done and lowered to input. |
8 | use relative_path::RelativePathBuf; | 8 | use relative_path::{RelativePath, RelativePathBuf}; |
9 | use rustc_hash::FxHashMap; | 9 | use rustc_hash::FxHashMap; |
10 | 10 | ||
11 | use ra_syntax::SmolStr; | 11 | use ra_syntax::SmolStr; |
@@ -36,7 +36,7 @@ pub struct SourceRoot { | |||
36 | /// Libraries are considered mostly immutable, this assumption is used to | 36 | /// Libraries are considered mostly immutable, this assumption is used to |
37 | /// optimize salsa's query structure | 37 | /// optimize salsa's query structure |
38 | pub is_library: bool, | 38 | pub is_library: bool, |
39 | pub files: FxHashMap<RelativePathBuf, FileId>, | 39 | files: FxHashMap<RelativePathBuf, FileId>, |
40 | } | 40 | } |
41 | 41 | ||
42 | impl SourceRoot { | 42 | impl SourceRoot { |
@@ -46,6 +46,18 @@ impl SourceRoot { | |||
46 | pub fn new_library() -> SourceRoot { | 46 | pub fn new_library() -> SourceRoot { |
47 | SourceRoot { is_library: true, ..SourceRoot::new() } | 47 | SourceRoot { is_library: true, ..SourceRoot::new() } |
48 | } | 48 | } |
49 | pub fn file_by_relative_path(&self, path: &RelativePath) -> Option<FileId> { | ||
50 | self.files.get(path).copied() | ||
51 | } | ||
52 | pub fn insert_file(&mut self, path: RelativePathBuf, file_id: FileId) { | ||
53 | self.files.insert(path, file_id); | ||
54 | } | ||
55 | pub fn remove_file(&mut self, path: &RelativePath) { | ||
56 | self.files.remove(path); | ||
57 | } | ||
58 | pub fn walk(&self) -> impl Iterator<Item = FileId> + '_ { | ||
59 | self.files.values().copied() | ||
60 | } | ||
49 | } | 61 | } |
50 | 62 | ||
51 | /// `CrateGraph` is a bit of information which turns a set of text files into a | 63 | /// `CrateGraph` is a bit of information which turns a set of text files into a |
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index b82d1bda0..c54791b7a 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -12,7 +12,7 @@ pub use crate::{ | |||
12 | cancellation::Canceled, | 12 | cancellation::Canceled, |
13 | input::{CrateGraph, CrateId, Dependency, Edition, FileId, SourceRoot, SourceRootId}, | 13 | input::{CrateGraph, CrateId, Dependency, Edition, FileId, SourceRoot, SourceRootId}, |
14 | }; | 14 | }; |
15 | pub use ::salsa; | 15 | pub use salsa; |
16 | 16 | ||
17 | pub trait CheckCanceled { | 17 | pub trait CheckCanceled { |
18 | /// Aborts current query if there are pending changes. | 18 | /// Aborts current query if there are pending changes. |
@@ -93,8 +93,7 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug { | |||
93 | fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> { | 93 | fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> { |
94 | let root = db.source_root(id); | 94 | let root = db.source_root(id); |
95 | let graph = db.crate_graph(); | 95 | let graph = db.crate_graph(); |
96 | let res = | 96 | let res = root.walk().filter_map(|it| graph.crate_id_for_crate_root(it)).collect::<Vec<_>>(); |
97 | root.files.values().filter_map(|&it| graph.crate_id_for_crate_root(it)).collect::<Vec<_>>(); | ||
98 | Arc::new(res) | 97 | Arc::new(res) |
99 | } | 98 | } |
100 | 99 | ||
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 7c9454c0b..b9ffb0c7a 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -1,11 +1,15 @@ | |||
1 | use ra_syntax::ast::{self, AstNode}; | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | ||
3 | SyntaxNode, | ||
4 | }; | ||
2 | 5 | ||
3 | use crate::{ | 6 | use crate::{ |
4 | ids::AstItemDef, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, | 7 | ids::AstItemDef, AstDatabase, Const, DefDatabase, Either, Enum, EnumVariant, FieldSource, |
5 | HasBody, HirDatabase, HirFileId, MacroDef, Module, ModuleSource, Static, Struct, StructField, | 8 | Function, HasBody, HirDatabase, HirFileId, MacroDef, Module, ModuleSource, Static, Struct, |
6 | Trait, TypeAlias, Union, | 9 | StructField, Trait, TypeAlias, Union, |
7 | }; | 10 | }; |
8 | 11 | ||
12 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | ||
9 | pub struct Source<T> { | 13 | pub struct Source<T> { |
10 | pub file_id: HirFileId, | 14 | pub file_id: HirFileId, |
11 | pub ast: T, | 15 | pub ast: T, |
@@ -16,6 +20,15 @@ pub trait HasSource { | |||
16 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<Self::Ast>; | 20 | fn source(self, db: &(impl DefDatabase + AstDatabase)) -> Source<Self::Ast>; |
17 | } | 21 | } |
18 | 22 | ||
23 | impl<T> Source<T> { | ||
24 | pub(crate) fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { | ||
25 | Source { file_id: self.file_id, ast: f(self.ast) } | ||
26 | } | ||
27 | pub(crate) fn file_syntax(&self, db: &impl AstDatabase) -> SyntaxNode { | ||
28 | db.parse_or_expand(self.file_id).expect("source created from invalid file") | ||
29 | } | ||
30 | } | ||
31 | |||
19 | /// NB: Module is !HasSource, because it has two source nodes at the same time: | 32 | /// NB: Module is !HasSource, because it has two source nodes at the same time: |
20 | /// definition and declaration. | 33 | /// definition and declaration. |
21 | impl Module { | 34 | impl Module { |
@@ -117,12 +130,12 @@ where | |||
117 | self, | 130 | self, |
118 | db: &impl HirDatabase, | 131 | db: &impl HirDatabase, |
119 | expr_id: crate::expr::ExprId, | 132 | expr_id: crate::expr::ExprId, |
120 | ) -> Option<Source<ast::Expr>> { | 133 | ) -> Option<Source<Either<ast::Expr, ast::RecordField>>> { |
121 | let source_map = self.body_source_map(db); | 134 | let source_map = self.body_source_map(db); |
122 | let expr_syntax = source_map.expr_syntax(expr_id)?.a()?; | 135 | let source_ptr = source_map.expr_syntax(expr_id)?; |
123 | let source = self.source(db); | 136 | let root = source_ptr.file_syntax(db); |
124 | let ast = expr_syntax.to_node(&source.ast.syntax()); | 137 | let source = source_ptr.map(|ast| ast.map(|it| it.to_node(&root), |it| it.to_node(&root))); |
125 | Some(Source { file_id: source.file_id, ast }) | 138 | Some(source) |
126 | } | 139 | } |
127 | } | 140 | } |
128 | 141 | ||
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index f669ab969..7b7974f5b 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -169,13 +169,13 @@ pub trait HirDatabase: DefDatabase + AstDatabase { | |||
169 | #[salsa::invoke(crate::ty::generic_defaults_query)] | 169 | #[salsa::invoke(crate::ty::generic_defaults_query)] |
170 | fn generic_defaults(&self, def: GenericDef) -> Substs; | 170 | fn generic_defaults(&self, def: GenericDef) -> Substs; |
171 | 171 | ||
172 | #[salsa::invoke(crate::expr::lower::body_with_source_map_query)] | 172 | #[salsa::invoke(crate::expr::body_with_source_map_query)] |
173 | fn body_with_source_map( | 173 | fn body_with_source_map( |
174 | &self, | 174 | &self, |
175 | def: DefWithBody, | 175 | def: DefWithBody, |
176 | ) -> (Arc<crate::expr::Body>, Arc<crate::expr::BodySourceMap>); | 176 | ) -> (Arc<crate::expr::Body>, Arc<crate::expr::BodySourceMap>); |
177 | 177 | ||
178 | #[salsa::invoke(crate::expr::lower::body_hir_query)] | 178 | #[salsa::invoke(crate::expr::body_hir_query)] |
179 | fn body_hir(&self, def: DefWithBody) -> Arc<crate::expr::Body>; | 179 | fn body_hir(&self, def: DefWithBody) -> Arc<crate::expr::Body>; |
180 | 180 | ||
181 | #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] | 181 | #[salsa::invoke(crate::ty::method_resolution::CrateImplBlocks::impls_in_crate_query)] |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index bfd250f38..fc21e269f 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -12,7 +12,7 @@ use crate::{ | |||
12 | path::GenericArgs, | 12 | path::GenericArgs, |
13 | ty::primitive::{UncertainFloatTy, UncertainIntTy}, | 13 | ty::primitive::{UncertainFloatTy, UncertainIntTy}, |
14 | type_ref::{Mutability, TypeRef}, | 14 | type_ref::{Mutability, TypeRef}, |
15 | DefWithBody, Either, HirDatabase, Name, Path, Resolver, | 15 | DefWithBody, Either, HasSource, HirDatabase, Name, Path, Resolver, Source, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | pub use self::scope::ExprScopes; | 18 | pub use self::scope::ExprScopes; |
@@ -43,23 +43,32 @@ pub struct Body { | |||
43 | body_expr: ExprId, | 43 | body_expr: ExprId, |
44 | } | 44 | } |
45 | 45 | ||
46 | type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>; | ||
47 | type ExprSource = Source<ExprPtr>; | ||
48 | |||
49 | type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>; | ||
50 | type PatSource = Source<PatPtr>; | ||
51 | |||
46 | /// An item body together with the mapping from syntax nodes to HIR expression | 52 | /// An item body together with the mapping from syntax nodes to HIR expression |
47 | /// IDs. This is needed to go from e.g. a position in a file to the HIR | 53 | /// IDs. This is needed to go from e.g. a position in a file to the HIR |
48 | /// expression containing it; but for type inference etc., we want to operate on | 54 | /// expression containing it; but for type inference etc., we want to operate on |
49 | /// a structure that is agnostic to the actual positions of expressions in the | 55 | /// a structure that is agnostic to the actual positions of expressions in the |
50 | /// file, so that we don't recompute types whenever some whitespace is typed. | 56 | /// file, so that we don't recompute types whenever some whitespace is typed. |
57 | /// | ||
58 | /// One complication here is that, due to macro expansion, a single `Body` might | ||
59 | /// be spread across several files. So, for each ExprId and PatId, we record | ||
60 | /// both the HirFileId and the position inside the file. However, we only store | ||
61 | /// AST -> ExprId mapping for non-macro files, as it is not clear how to handle | ||
62 | /// this properly for macros. | ||
51 | #[derive(Default, Debug, Eq, PartialEq)] | 63 | #[derive(Default, Debug, Eq, PartialEq)] |
52 | pub struct BodySourceMap { | 64 | pub struct BodySourceMap { |
53 | expr_map: FxHashMap<ExprPtr, ExprId>, | 65 | expr_map: FxHashMap<ExprPtr, ExprId>, |
54 | expr_map_back: ArenaMap<ExprId, ExprPtr>, | 66 | expr_map_back: ArenaMap<ExprId, ExprSource>, |
55 | pat_map: FxHashMap<PatPtr, PatId>, | 67 | pat_map: FxHashMap<PatPtr, PatId>, |
56 | pat_map_back: ArenaMap<PatId, PatPtr>, | 68 | pat_map_back: ArenaMap<PatId, PatSource>, |
57 | field_map: FxHashMap<(ExprId, usize), AstPtr<ast::RecordField>>, | 69 | field_map: FxHashMap<(ExprId, usize), AstPtr<ast::RecordField>>, |
58 | } | 70 | } |
59 | 71 | ||
60 | type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>; | ||
61 | type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>; | ||
62 | |||
63 | impl Body { | 72 | impl Body { |
64 | pub fn params(&self) -> &[PatId] { | 73 | pub fn params(&self) -> &[PatId] { |
65 | &self.params | 74 | &self.params |
@@ -123,16 +132,16 @@ impl Index<PatId> for Body { | |||
123 | } | 132 | } |
124 | 133 | ||
125 | impl BodySourceMap { | 134 | impl BodySourceMap { |
126 | pub(crate) fn expr_syntax(&self, expr: ExprId) -> Option<ExprPtr> { | 135 | pub(crate) fn expr_syntax(&self, expr: ExprId) -> Option<ExprSource> { |
127 | self.expr_map_back.get(expr).cloned() | 136 | self.expr_map_back.get(expr).copied() |
128 | } | 137 | } |
129 | 138 | ||
130 | pub(crate) fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { | 139 | pub(crate) fn node_expr(&self, node: &ast::Expr) -> Option<ExprId> { |
131 | self.expr_map.get(&Either::A(AstPtr::new(node))).cloned() | 140 | self.expr_map.get(&Either::A(AstPtr::new(node))).cloned() |
132 | } | 141 | } |
133 | 142 | ||
134 | pub(crate) fn pat_syntax(&self, pat: PatId) -> Option<PatPtr> { | 143 | pub(crate) fn pat_syntax(&self, pat: PatId) -> Option<PatSource> { |
135 | self.pat_map_back.get(pat).cloned() | 144 | self.pat_map_back.get(pat).copied() |
136 | } | 145 | } |
137 | 146 | ||
138 | pub(crate) fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { | 147 | pub(crate) fn node_pat(&self, node: &ast::Pat) -> Option<PatId> { |
@@ -524,3 +533,34 @@ impl Pat { | |||
524 | } | 533 | } |
525 | } | 534 | } |
526 | } | 535 | } |
536 | |||
537 | // Queries | ||
538 | pub(crate) fn body_with_source_map_query( | ||
539 | db: &impl HirDatabase, | ||
540 | def: DefWithBody, | ||
541 | ) -> (Arc<Body>, Arc<BodySourceMap>) { | ||
542 | let mut params = None; | ||
543 | |||
544 | let (file_id, body) = match def { | ||
545 | DefWithBody::Function(f) => { | ||
546 | let src = f.source(db); | ||
547 | params = src.ast.param_list(); | ||
548 | (src.file_id, src.ast.body().map(ast::Expr::from)) | ||
549 | } | ||
550 | DefWithBody::Const(c) => { | ||
551 | let src = c.source(db); | ||
552 | (src.file_id, src.ast.body()) | ||
553 | } | ||
554 | DefWithBody::Static(s) => { | ||
555 | let src = s.source(db); | ||
556 | (src.file_id, src.ast.body()) | ||
557 | } | ||
558 | }; | ||
559 | |||
560 | let (body, source_map) = lower::lower(db, def.resolver(db), file_id, def, params, body); | ||
561 | (Arc::new(body), Arc::new(source_map)) | ||
562 | } | ||
563 | |||
564 | pub(crate) fn body_hir_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<Body> { | ||
565 | db.body_with_source_map(def).0 | ||
566 | } | ||
diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index f6a75a379..6afd80989 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | use std::sync::Arc; | ||
2 | |||
3 | use ra_arena::Arena; | 1 | use ra_arena::Arena; |
4 | use ra_syntax::{ | 2 | use ra_syntax::{ |
5 | ast::{ | 3 | ast::{ |
@@ -15,8 +13,8 @@ use crate::{ | |||
15 | path::GenericArgs, | 13 | path::GenericArgs, |
16 | ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, | 14 | ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, |
17 | type_ref::TypeRef, | 15 | type_ref::TypeRef, |
18 | DefWithBody, Either, HasSource, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, | 16 | DefWithBody, Either, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, |
19 | Mutability, Path, Resolver, | 17 | Resolver, Source, |
20 | }; | 18 | }; |
21 | 19 | ||
22 | use super::{ | 20 | use super::{ |
@@ -24,14 +22,33 @@ use super::{ | |||
24 | LogicOp, MatchArm, Ordering, Pat, PatId, PatPtr, RecordFieldPat, RecordLitField, Statement, | 22 | LogicOp, MatchArm, Ordering, Pat, PatId, PatPtr, RecordFieldPat, RecordLitField, Statement, |
25 | }; | 23 | }; |
26 | 24 | ||
27 | pub(crate) struct ExprCollector<DB> { | 25 | pub(super) fn lower( |
28 | db: DB, | 26 | db: &impl HirDatabase, |
27 | resolver: Resolver, | ||
28 | file_id: HirFileId, | ||
29 | owner: DefWithBody, | 29 | owner: DefWithBody, |
30 | exprs: Arena<ExprId, Expr>, | 30 | params: Option<ast::ParamList>, |
31 | pats: Arena<PatId, Pat>, | 31 | body: Option<ast::Expr>, |
32 | source_map: BodySourceMap, | 32 | ) -> (Body, BodySourceMap) { |
33 | params: Vec<PatId>, | 33 | ExprCollector { |
34 | body_expr: Option<ExprId>, | 34 | resolver, |
35 | db, | ||
36 | original_file_id: file_id, | ||
37 | current_file_id: file_id, | ||
38 | source_map: BodySourceMap::default(), | ||
39 | body: Body { | ||
40 | owner, | ||
41 | exprs: Arena::default(), | ||
42 | pats: Arena::default(), | ||
43 | params: Vec::new(), | ||
44 | body_expr: ExprId((!0).into()), | ||
45 | }, | ||
46 | } | ||
47 | .collect(params, body) | ||
48 | } | ||
49 | |||
50 | struct ExprCollector<DB> { | ||
51 | db: DB, | ||
35 | resolver: Resolver, | 52 | resolver: Resolver, |
36 | // Expr collector expands macros along the way. original points to the file | 53 | // Expr collector expands macros along the way. original points to the file |
37 | // we started with, current points to the current macro expansion. source | 54 | // we started with, current points to the current macro expansion. source |
@@ -39,50 +56,95 @@ pub(crate) struct ExprCollector<DB> { | |||
39 | // current == original (see #1196) | 56 | // current == original (see #1196) |
40 | original_file_id: HirFileId, | 57 | original_file_id: HirFileId, |
41 | current_file_id: HirFileId, | 58 | current_file_id: HirFileId, |
59 | |||
60 | body: Body, | ||
61 | source_map: BodySourceMap, | ||
42 | } | 62 | } |
43 | 63 | ||
44 | impl<'a, DB> ExprCollector<&'a DB> | 64 | impl<'a, DB> ExprCollector<&'a DB> |
45 | where | 65 | where |
46 | DB: HirDatabase, | 66 | DB: HirDatabase, |
47 | { | 67 | { |
48 | fn new(owner: DefWithBody, file_id: HirFileId, resolver: Resolver, db: &'a DB) -> Self { | 68 | fn collect( |
49 | ExprCollector { | 69 | mut self, |
50 | owner, | 70 | param_list: Option<ast::ParamList>, |
51 | resolver, | 71 | body: Option<ast::Expr>, |
52 | db, | 72 | ) -> (Body, BodySourceMap) { |
53 | exprs: Arena::default(), | 73 | if let Some(param_list) = param_list { |
54 | pats: Arena::default(), | 74 | if let Some(self_param) = param_list.self_param() { |
55 | source_map: BodySourceMap::default(), | 75 | let ptr = AstPtr::new(&self_param); |
56 | params: Vec::new(), | 76 | let param_pat = self.alloc_pat( |
57 | body_expr: None, | 77 | Pat::Bind { |
58 | original_file_id: file_id, | 78 | name: SELF_PARAM, |
59 | current_file_id: file_id, | 79 | mode: BindingAnnotation::Unannotated, |
60 | } | 80 | subpat: None, |
81 | }, | ||
82 | Either::B(ptr), | ||
83 | ); | ||
84 | self.body.params.push(param_pat); | ||
85 | } | ||
86 | |||
87 | for param in param_list.params() { | ||
88 | let pat = match param.pat() { | ||
89 | None => continue, | ||
90 | Some(pat) => pat, | ||
91 | }; | ||
92 | let param_pat = self.collect_pat(pat); | ||
93 | self.body.params.push(param_pat); | ||
94 | } | ||
95 | }; | ||
96 | |||
97 | self.body.body_expr = self.collect_expr_opt(body); | ||
98 | (self.body, self.source_map) | ||
61 | } | 99 | } |
100 | |||
62 | fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { | 101 | fn alloc_expr(&mut self, expr: Expr, ptr: AstPtr<ast::Expr>) -> ExprId { |
63 | let ptr = Either::A(ptr); | 102 | let ptr = Either::A(ptr); |
64 | let id = self.exprs.alloc(expr); | 103 | let id = self.body.exprs.alloc(expr); |
65 | if self.current_file_id == self.original_file_id { | 104 | if self.current_file_id == self.original_file_id { |
66 | self.source_map.expr_map.insert(ptr, id); | 105 | self.source_map.expr_map.insert(ptr, id); |
67 | self.source_map.expr_map_back.insert(id, ptr); | ||
68 | } | 106 | } |
107 | self.source_map | ||
108 | .expr_map_back | ||
109 | .insert(id, Source { file_id: self.current_file_id, ast: ptr }); | ||
110 | id | ||
111 | } | ||
112 | // desugared exprs don't have ptr, that's wrong and should be fixed | ||
113 | // somehow. | ||
114 | fn alloc_expr_desugared(&mut self, expr: Expr) -> ExprId { | ||
115 | self.body.exprs.alloc(expr) | ||
116 | } | ||
117 | fn alloc_expr_field_shorthand(&mut self, expr: Expr, ptr: AstPtr<ast::RecordField>) -> ExprId { | ||
118 | let ptr = Either::B(ptr); | ||
119 | let id = self.body.exprs.alloc(expr); | ||
120 | if self.current_file_id == self.original_file_id { | ||
121 | self.source_map.expr_map.insert(ptr, id); | ||
122 | } | ||
123 | self.source_map | ||
124 | .expr_map_back | ||
125 | .insert(id, Source { file_id: self.current_file_id, ast: ptr }); | ||
69 | id | 126 | id |
70 | } | 127 | } |
71 | |||
72 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { | 128 | fn alloc_pat(&mut self, pat: Pat, ptr: PatPtr) -> PatId { |
73 | let id = self.pats.alloc(pat); | 129 | let id = self.body.pats.alloc(pat); |
74 | |||
75 | if self.current_file_id == self.original_file_id { | 130 | if self.current_file_id == self.original_file_id { |
76 | self.source_map.pat_map.insert(ptr, id); | 131 | self.source_map.pat_map.insert(ptr, id); |
77 | self.source_map.pat_map_back.insert(id, ptr); | ||
78 | } | 132 | } |
79 | 133 | self.source_map.pat_map_back.insert(id, Source { file_id: self.current_file_id, ast: ptr }); | |
80 | id | 134 | id |
81 | } | 135 | } |
82 | 136 | ||
83 | fn empty_block(&mut self) -> ExprId { | 137 | fn empty_block(&mut self) -> ExprId { |
84 | let block = Expr::Block { statements: Vec::new(), tail: None }; | 138 | let block = Expr::Block { statements: Vec::new(), tail: None }; |
85 | self.exprs.alloc(block) | 139 | self.body.exprs.alloc(block) |
140 | } | ||
141 | |||
142 | fn missing_expr(&mut self) -> ExprId { | ||
143 | self.body.exprs.alloc(Expr::Missing) | ||
144 | } | ||
145 | |||
146 | fn missing_pat(&mut self) -> PatId { | ||
147 | self.body.pats.alloc(Pat::Missing) | ||
86 | } | 148 | } |
87 | 149 | ||
88 | fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { | 150 | fn collect_expr(&mut self, expr: ast::Expr) -> ExprId { |
@@ -100,14 +162,14 @@ where | |||
100 | }); | 162 | }); |
101 | 163 | ||
102 | let condition = match e.condition() { | 164 | let condition = match e.condition() { |
103 | None => self.exprs.alloc(Expr::Missing), | 165 | None => self.missing_expr(), |
104 | Some(condition) => match condition.pat() { | 166 | Some(condition) => match condition.pat() { |
105 | None => self.collect_expr_opt(condition.expr()), | 167 | None => self.collect_expr_opt(condition.expr()), |
106 | // if let -- desugar to match | 168 | // if let -- desugar to match |
107 | Some(pat) => { | 169 | Some(pat) => { |
108 | let pat = self.collect_pat(pat); | 170 | let pat = self.collect_pat(pat); |
109 | let match_expr = self.collect_expr_opt(condition.expr()); | 171 | let match_expr = self.collect_expr_opt(condition.expr()); |
110 | let placeholder_pat = self.pats.alloc(Pat::Missing); | 172 | let placeholder_pat = self.missing_pat(); |
111 | let arms = vec![ | 173 | let arms = vec![ |
112 | MatchArm { pats: vec![pat], expr: then_branch, guard: None }, | 174 | MatchArm { pats: vec![pat], expr: then_branch, guard: None }, |
113 | MatchArm { | 175 | MatchArm { |
@@ -137,7 +199,7 @@ where | |||
137 | let body = self.collect_block_opt(e.loop_body()); | 199 | let body = self.collect_block_opt(e.loop_body()); |
138 | 200 | ||
139 | let condition = match e.condition() { | 201 | let condition = match e.condition() { |
140 | None => self.exprs.alloc(Expr::Missing), | 202 | None => self.missing_expr(), |
141 | Some(condition) => match condition.pat() { | 203 | Some(condition) => match condition.pat() { |
142 | None => self.collect_expr_opt(condition.expr()), | 204 | None => self.collect_expr_opt(condition.expr()), |
143 | // if let -- desugar to match | 205 | // if let -- desugar to match |
@@ -145,14 +207,14 @@ where | |||
145 | tested_by!(infer_while_let); | 207 | tested_by!(infer_while_let); |
146 | let pat = self.collect_pat(pat); | 208 | let pat = self.collect_pat(pat); |
147 | let match_expr = self.collect_expr_opt(condition.expr()); | 209 | let match_expr = self.collect_expr_opt(condition.expr()); |
148 | let placeholder_pat = self.pats.alloc(Pat::Missing); | 210 | let placeholder_pat = self.missing_pat(); |
149 | let break_ = self.exprs.alloc(Expr::Break { expr: None }); | 211 | let break_ = self.alloc_expr_desugared(Expr::Break { expr: None }); |
150 | let arms = vec![ | 212 | let arms = vec![ |
151 | MatchArm { pats: vec![pat], expr: body, guard: None }, | 213 | MatchArm { pats: vec![pat], expr: body, guard: None }, |
152 | MatchArm { pats: vec![placeholder_pat], expr: break_, guard: None }, | 214 | MatchArm { pats: vec![placeholder_pat], expr: break_, guard: None }, |
153 | ]; | 215 | ]; |
154 | let match_expr = | 216 | let match_expr = |
155 | self.exprs.alloc(Expr::Match { expr: match_expr, arms }); | 217 | self.alloc_expr_desugared(Expr::Match { expr: match_expr, arms }); |
156 | return self.alloc_expr(Expr::Loop { body: match_expr }, syntax_ptr); | 218 | return self.alloc_expr(Expr::Loop { body: match_expr }, syntax_ptr); |
157 | } | 219 | } |
158 | }, | 220 | }, |
@@ -247,13 +309,12 @@ where | |||
247 | self.collect_expr(e) | 309 | self.collect_expr(e) |
248 | } else if let Some(nr) = field.name_ref() { | 310 | } else if let Some(nr) = field.name_ref() { |
249 | // field shorthand | 311 | // field shorthand |
250 | let id = self.exprs.alloc(Expr::Path(Path::from_name_ref(&nr))); | 312 | self.alloc_expr_field_shorthand( |
251 | let ptr = Either::B(AstPtr::new(&field)); | 313 | Expr::Path(Path::from_name_ref(&nr)), |
252 | self.source_map.expr_map.insert(ptr, id); | 314 | AstPtr::new(&field), |
253 | self.source_map.expr_map_back.insert(id, ptr); | 315 | ) |
254 | id | ||
255 | } else { | 316 | } else { |
256 | self.exprs.alloc(Expr::Missing) | 317 | self.missing_expr() |
257 | }, | 318 | }, |
258 | }) | 319 | }) |
259 | .collect(); | 320 | .collect(); |
@@ -420,7 +481,7 @@ where | |||
420 | if let Some(expr) = expr { | 481 | if let Some(expr) = expr { |
421 | self.collect_expr(expr) | 482 | self.collect_expr(expr) |
422 | } else { | 483 | } else { |
423 | self.exprs.alloc(Expr::Missing) | 484 | self.missing_expr() |
424 | } | 485 | } |
425 | } | 486 | } |
426 | 487 | ||
@@ -450,7 +511,7 @@ where | |||
450 | if let Some(block) = expr { | 511 | if let Some(block) = expr { |
451 | self.collect_block(block) | 512 | self.collect_block(block) |
452 | } else { | 513 | } else { |
453 | self.exprs.alloc(Expr::Missing) | 514 | self.missing_expr() |
454 | } | 515 | } |
455 | } | 516 | } |
456 | 517 | ||
@@ -519,60 +580,9 @@ where | |||
519 | if let Some(pat) = pat { | 580 | if let Some(pat) = pat { |
520 | self.collect_pat(pat) | 581 | self.collect_pat(pat) |
521 | } else { | 582 | } else { |
522 | self.pats.alloc(Pat::Missing) | 583 | self.missing_pat() |
523 | } | 584 | } |
524 | } | 585 | } |
525 | |||
526 | fn collect_const_body(&mut self, node: ast::ConstDef) { | ||
527 | let body = self.collect_expr_opt(node.body()); | ||
528 | self.body_expr = Some(body); | ||
529 | } | ||
530 | |||
531 | fn collect_static_body(&mut self, node: ast::StaticDef) { | ||
532 | let body = self.collect_expr_opt(node.body()); | ||
533 | self.body_expr = Some(body); | ||
534 | } | ||
535 | |||
536 | fn collect_fn_body(&mut self, node: ast::FnDef) { | ||
537 | if let Some(param_list) = node.param_list() { | ||
538 | if let Some(self_param) = param_list.self_param() { | ||
539 | let ptr = AstPtr::new(&self_param); | ||
540 | let param_pat = self.alloc_pat( | ||
541 | Pat::Bind { | ||
542 | name: SELF_PARAM, | ||
543 | mode: BindingAnnotation::Unannotated, | ||
544 | subpat: None, | ||
545 | }, | ||
546 | Either::B(ptr), | ||
547 | ); | ||
548 | self.params.push(param_pat); | ||
549 | } | ||
550 | |||
551 | for param in param_list.params() { | ||
552 | let pat = if let Some(pat) = param.pat() { | ||
553 | pat | ||
554 | } else { | ||
555 | continue; | ||
556 | }; | ||
557 | let param_pat = self.collect_pat(pat); | ||
558 | self.params.push(param_pat); | ||
559 | } | ||
560 | }; | ||
561 | |||
562 | let body = self.collect_block_opt(node.body()); | ||
563 | self.body_expr = Some(body); | ||
564 | } | ||
565 | |||
566 | fn finish(self) -> (Body, BodySourceMap) { | ||
567 | let body = Body { | ||
568 | owner: self.owner, | ||
569 | exprs: self.exprs, | ||
570 | pats: self.pats, | ||
571 | params: self.params, | ||
572 | body_expr: self.body_expr.expect("A body should have been collected"), | ||
573 | }; | ||
574 | (body, self.source_map) | ||
575 | } | ||
576 | } | 586 | } |
577 | 587 | ||
578 | impl From<ast::BinOp> for BinaryOp { | 588 | impl From<ast::BinOp> for BinaryOp { |
@@ -618,35 +628,3 @@ impl From<ast::BinOp> for BinaryOp { | |||
618 | } | 628 | } |
619 | } | 629 | } |
620 | } | 630 | } |
621 | |||
622 | pub(crate) fn body_with_source_map_query( | ||
623 | db: &impl HirDatabase, | ||
624 | def: DefWithBody, | ||
625 | ) -> (Arc<Body>, Arc<BodySourceMap>) { | ||
626 | let mut collector; | ||
627 | |||
628 | match def { | ||
629 | DefWithBody::Const(ref c) => { | ||
630 | let src = c.source(db); | ||
631 | collector = ExprCollector::new(def, src.file_id, def.resolver(db), db); | ||
632 | collector.collect_const_body(src.ast) | ||
633 | } | ||
634 | DefWithBody::Function(ref f) => { | ||
635 | let src = f.source(db); | ||
636 | collector = ExprCollector::new(def, src.file_id, def.resolver(db), db); | ||
637 | collector.collect_fn_body(src.ast) | ||
638 | } | ||
639 | DefWithBody::Static(ref s) => { | ||
640 | let src = s.source(db); | ||
641 | collector = ExprCollector::new(def, src.file_id, def.resolver(db), db); | ||
642 | collector.collect_static_body(src.ast) | ||
643 | } | ||
644 | } | ||
645 | |||
646 | let (body, source_map) = collector.finish(); | ||
647 | (Arc::new(body), Arc::new(source_map)) | ||
648 | } | ||
649 | |||
650 | pub(crate) fn body_hir_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<Body> { | ||
651 | db.body_with_source_map(def).0 | ||
652 | } | ||
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index 6fdaf1fce..1202913e2 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -1,9 +1,8 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::ast::{self, AstNode}; | 3 | use ra_syntax::ast; |
4 | use rustc_hash::FxHashSet; | 4 | use rustc_hash::FxHashSet; |
5 | 5 | ||
6 | use super::{Expr, ExprId, RecordLitField}; | ||
7 | use crate::{ | 6 | use crate::{ |
8 | adt::AdtDef, | 7 | adt::AdtDef, |
9 | diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr}, | 8 | diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr}, |
@@ -11,9 +10,11 @@ use crate::{ | |||
11 | name, | 10 | name, |
12 | path::{PathKind, PathSegment}, | 11 | path::{PathKind, PathSegment}, |
13 | ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, | 12 | ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, |
14 | Function, HasSource, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution, | 13 | Function, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution, |
15 | }; | 14 | }; |
16 | 15 | ||
16 | use super::{Expr, ExprId, RecordLitField}; | ||
17 | |||
17 | pub(crate) struct ExprValidator<'a, 'b: 'a> { | 18 | pub(crate) struct ExprValidator<'a, 'b: 'a> { |
18 | func: Function, | 19 | func: Function, |
19 | infer: Arc<InferenceResult>, | 20 | infer: Arc<InferenceResult>, |
@@ -78,25 +79,20 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
78 | return; | 79 | return; |
79 | } | 80 | } |
80 | let source_map = self.func.body_source_map(db); | 81 | let source_map = self.func.body_source_map(db); |
81 | let file_id = self.func.source(db).file_id; | 82 | |
82 | let parse = db.parse(file_id.original_file(db)); | 83 | if let Some(source_ptr) = source_map.expr_syntax(id) { |
83 | let source_file = parse.tree(); | 84 | if let Some(expr) = source_ptr.ast.a() { |
84 | if let Some(field_list_node) = source_map | 85 | let root = source_ptr.file_syntax(db); |
85 | .expr_syntax(id) | 86 | if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { |
86 | .and_then(|ptr| ptr.a()) | 87 | if let Some(field_list) = record_lit.record_field_list() { |
87 | .map(|ptr| ptr.to_node(source_file.syntax())) | 88 | self.sink.push(MissingFields { |
88 | .and_then(|expr| match expr { | 89 | file: source_ptr.file_id, |
89 | ast::Expr::RecordLit(it) => Some(it), | 90 | field_list: AstPtr::new(&field_list), |
90 | _ => None, | 91 | missed_fields, |
91 | }) | 92 | }) |
92 | .and_then(|lit| lit.record_field_list()) | 93 | } |
93 | { | 94 | } |
94 | let field_list_ptr = AstPtr::new(&field_list_node); | 95 | } |
95 | self.sink.push(MissingFields { | ||
96 | file: file_id, | ||
97 | field_list: field_list_ptr, | ||
98 | missed_fields, | ||
99 | }) | ||
100 | } | 96 | } |
101 | } | 97 | } |
102 | 98 | ||
@@ -136,10 +132,11 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
136 | 132 | ||
137 | if params.len() == 2 && ¶ms[0] == &mismatch.actual { | 133 | if params.len() == 2 && ¶ms[0] == &mismatch.actual { |
138 | let source_map = self.func.body_source_map(db); | 134 | let source_map = self.func.body_source_map(db); |
139 | let file_id = self.func.source(db).file_id; | ||
140 | 135 | ||
141 | if let Some(expr) = source_map.expr_syntax(id).and_then(|n| n.a()) { | 136 | if let Some(source_ptr) = source_map.expr_syntax(id) { |
142 | self.sink.push(MissingOkInTailExpr { file: file_id, expr }); | 137 | if let Some(expr) = source_ptr.ast.a() { |
138 | self.sink.push(MissingOkInTailExpr { file: source_ptr.file_id, expr }); | ||
139 | } | ||
143 | } | 140 | } |
144 | } | 141 | } |
145 | } | 142 | } |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 752653ad7..c3e589921 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -69,7 +69,9 @@ pub use self::{ | |||
69 | resolve::Resolution, | 69 | resolve::Resolution, |
70 | source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer}, | 70 | source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer}, |
71 | source_id::{AstIdMap, ErasedFileAstId}, | 71 | source_id::{AstIdMap, ErasedFileAstId}, |
72 | ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor}, | 72 | ty::{ |
73 | display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor, TypeWalk, | ||
74 | }, | ||
73 | type_ref::Mutability, | 75 | type_ref::Mutability, |
74 | }; | 76 | }; |
75 | 77 | ||
diff --git a/crates/ra_hir/src/marks.rs b/crates/ra_hir/src/marks.rs index 5b15eee90..fe119b97c 100644 --- a/crates/ra_hir/src/marks.rs +++ b/crates/ra_hir/src/marks.rs | |||
@@ -11,4 +11,6 @@ test_utils::marks!( | |||
11 | match_ergonomics_ref | 11 | match_ergonomics_ref |
12 | trait_resolution_on_fn_type | 12 | trait_resolution_on_fn_type |
13 | infer_while_let | 13 | infer_while_let |
14 | macro_rules_from_other_crates_are_visible_with_macro_use | ||
15 | prelude_is_macro_use | ||
14 | ); | 16 | ); |
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index 77a44a275..972f0ece5 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs | |||
@@ -157,7 +157,7 @@ impl MockDatabase { | |||
157 | self.set_file_text(file_id, text); | 157 | self.set_file_text(file_id, text); |
158 | self.set_file_relative_path(file_id, rel_path.clone()); | 158 | self.set_file_relative_path(file_id, rel_path.clone()); |
159 | self.set_file_source_root(file_id, source_root_id); | 159 | self.set_file_source_root(file_id, source_root_id); |
160 | source_root.files.insert(rel_path, file_id); | 160 | source_root.insert_file(rel_path, file_id); |
161 | 161 | ||
162 | if is_crate_root { | 162 | if is_crate_root { |
163 | let mut crate_graph = CrateGraph::default(); | 163 | let mut crate_graph = CrateGraph::default(); |
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index bbdc606cd..fe90879b6 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -1,55 +1,56 @@ | |||
1 | /// This module implements import-resolution/macro expansion algorithm. | 1 | //! This module implements import-resolution/macro expansion algorithm. |
2 | /// | 2 | //! |
3 | /// The result of this module is `CrateDefMap`: a data structure which contains: | 3 | //! The result of this module is `CrateDefMap`: a data structure which contains: |
4 | /// | 4 | //! |
5 | /// * a tree of modules for the crate | 5 | //! * a tree of modules for the crate |
6 | /// * for each module, a set of items visible in the module (directly declared | 6 | //! * for each module, a set of items visible in the module (directly declared |
7 | /// or imported) | 7 | //! or imported) |
8 | /// | 8 | //! |
9 | /// Note that `CrateDefMap` contains fully macro expanded code. | 9 | //! Note that `CrateDefMap` contains fully macro expanded code. |
10 | /// | 10 | //! |
11 | /// Computing `CrateDefMap` can be partitioned into several logically | 11 | //! Computing `CrateDefMap` can be partitioned into several logically |
12 | /// independent "phases". The phases are mutually recursive though, there's no | 12 | //! independent "phases". The phases are mutually recursive though, there's no |
13 | /// strict ordering. | 13 | //! strict ordering. |
14 | /// | 14 | //! |
15 | /// ## Collecting RawItems | 15 | //! ## Collecting RawItems |
16 | /// | 16 | //! |
17 | /// This happens in the `raw` module, which parses a single source file into a | 17 | //! This happens in the `raw` module, which parses a single source file into a |
18 | /// set of top-level items. Nested imports are desugared to flat imports in | 18 | //! set of top-level items. Nested imports are desugared to flat imports in |
19 | /// this phase. Macro calls are represented as a triple of (Path, Option<Name>, | 19 | //! this phase. Macro calls are represented as a triple of (Path, Option<Name>, |
20 | /// TokenTree). | 20 | //! TokenTree). |
21 | /// | 21 | //! |
22 | /// ## Collecting Modules | 22 | //! ## Collecting Modules |
23 | /// | 23 | //! |
24 | /// This happens in the `collector` module. In this phase, we recursively walk | 24 | //! This happens in the `collector` module. In this phase, we recursively walk |
25 | /// tree of modules, collect raw items from submodules, populate module scopes | 25 | //! tree of modules, collect raw items from submodules, populate module scopes |
26 | /// with defined items (so, we assign item ids in this phase) and record the set | 26 | //! with defined items (so, we assign item ids in this phase) and record the set |
27 | /// of unresolved imports and macros. | 27 | //! of unresolved imports and macros. |
28 | /// | 28 | //! |
29 | /// While we walk tree of modules, we also record macro_rules definitions and | 29 | //! While we walk tree of modules, we also record macro_rules definitions and |
30 | /// expand calls to macro_rules defined macros. | 30 | //! expand calls to macro_rules defined macros. |
31 | /// | 31 | //! |
32 | /// ## Resolving Imports | 32 | //! ## Resolving Imports |
33 | /// | 33 | //! |
34 | /// We maintain a list of currently unresolved imports. On every iteration, we | 34 | //! We maintain a list of currently unresolved imports. On every iteration, we |
35 | /// try to resolve some imports from this list. If the import is resolved, we | 35 | //! try to resolve some imports from this list. If the import is resolved, we |
36 | /// record it, by adding an item to current module scope and, if necessary, by | 36 | //! record it, by adding an item to current module scope and, if necessary, by |
37 | /// recursively populating glob imports. | 37 | //! recursively populating glob imports. |
38 | /// | 38 | //! |
39 | /// ## Resolving Macros | 39 | //! ## Resolving Macros |
40 | /// | 40 | //! |
41 | /// macro_rules from the same crate use a global mutable namespace. We expand | 41 | //! macro_rules from the same crate use a global mutable namespace. We expand |
42 | /// them immediately, when we collect modules. | 42 | //! them immediately, when we collect modules. |
43 | /// | 43 | //! |
44 | /// Macros from other crates (including proc-macros) can be used with | 44 | //! Macros from other crates (including proc-macros) can be used with |
45 | /// `foo::bar!` syntax. We handle them similarly to imports. There's a list of | 45 | //! `foo::bar!` syntax. We handle them similarly to imports. There's a list of |
46 | /// unexpanded macros. On every iteration, we try to resolve each macro call | 46 | //! unexpanded macros. On every iteration, we try to resolve each macro call |
47 | /// path and, upon success, we run macro expansion and "collect module" phase | 47 | //! path and, upon success, we run macro expansion and "collect module" phase |
48 | /// on the result | 48 | //! on the result |
49 | 49 | ||
50 | mod per_ns; | 50 | mod per_ns; |
51 | mod raw; | 51 | mod raw; |
52 | mod collector; | 52 | mod collector; |
53 | mod mod_resolution; | ||
53 | #[cfg(test)] | 54 | #[cfg(test)] |
54 | mod tests; | 55 | mod tests; |
55 | 56 | ||
@@ -101,6 +102,8 @@ pub struct CrateDefMap { | |||
101 | /// However, do we want to put it as a global variable? | 102 | /// However, do we want to put it as a global variable? |
102 | poison_macros: FxHashSet<MacroDefId>, | 103 | poison_macros: FxHashSet<MacroDefId>, |
103 | 104 | ||
105 | exported_macros: FxHashMap<Name, MacroDefId>, | ||
106 | |||
104 | diagnostics: Vec<DefDiagnostic>, | 107 | diagnostics: Vec<DefDiagnostic>, |
105 | } | 108 | } |
106 | 109 | ||
@@ -245,6 +248,7 @@ impl CrateDefMap { | |||
245 | root, | 248 | root, |
246 | modules, | 249 | modules, |
247 | poison_macros: FxHashSet::default(), | 250 | poison_macros: FxHashSet::default(), |
251 | exported_macros: FxHashMap::default(), | ||
248 | diagnostics: Vec::new(), | 252 | diagnostics: Vec::new(), |
249 | } | 253 | } |
250 | }; | 254 | }; |
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 7da2dcdff..5af26f953 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -1,9 +1,5 @@ | |||
1 | use std::borrow::Cow; | 1 | use ra_db::FileId; |
2 | use std::sync::Arc; | 2 | use ra_syntax::ast; |
3 | |||
4 | use ra_db::{FileId, SourceRoot}; | ||
5 | use ra_syntax::{ast, SmolStr}; | ||
6 | use relative_path::RelativePathBuf; | ||
7 | use rustc_hash::FxHashMap; | 3 | use rustc_hash::FxHashMap; |
8 | use test_utils::tested_by; | 4 | use test_utils::tested_by; |
9 | 5 | ||
@@ -12,8 +8,10 @@ use crate::{ | |||
12 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, | 8 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, |
13 | name::MACRO_RULES, | 9 | name::MACRO_RULES, |
14 | nameres::{ | 10 | nameres::{ |
15 | diagnostics::DefDiagnostic, raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData, | 11 | diagnostics::DefDiagnostic, |
16 | ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode, | 12 | mod_resolution::{resolve_submodule, ParentModule}, |
13 | raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData, ModuleDef, PerNs, | ||
14 | ReachedFixedPoint, Resolution, ResolveMode, | ||
17 | }, | 15 | }, |
18 | AstId, Const, DefDatabase, Enum, Function, HirFileId, MacroDef, Module, Name, Path, Static, | 16 | AstId, Const, DefDatabase, Enum, Function, HirFileId, MacroDef, Module, Name, Path, Static, |
19 | Struct, Trait, TypeAlias, Union, | 17 | Struct, Trait, TypeAlias, Union, |
@@ -157,11 +155,45 @@ where | |||
157 | // crate root, even if the parent modules is **not** visible. | 155 | // crate root, even if the parent modules is **not** visible. |
158 | if export { | 156 | if export { |
159 | self.update(self.def_map.root, None, &[(name.clone(), def.clone())]); | 157 | self.update(self.def_map.root, None, &[(name.clone(), def.clone())]); |
158 | |||
159 | // Exported macros are collected in crate level ready for | ||
160 | // glob import with `#[macro_use]`. | ||
161 | self.def_map.exported_macros.insert(name.clone(), macro_id); | ||
160 | } | 162 | } |
161 | self.update(module_id, None, &[(name.clone(), def)]); | 163 | self.update(module_id, None, &[(name.clone(), def)]); |
162 | self.global_macro_scope.insert(name, macro_id); | 164 | self.global_macro_scope.insert(name, macro_id); |
163 | } | 165 | } |
164 | 166 | ||
167 | /// Import macros from `#[macro_use] extern crate`. | ||
168 | /// | ||
169 | /// They are non-scoped, and will only be inserted into mutable `global_macro_scope`. | ||
170 | fn import_macros_from_extern_crate(&mut self, import: &raw::ImportData) { | ||
171 | log::debug!( | ||
172 | "importing macros from extern crate: {:?} ({:?})", | ||
173 | import, | ||
174 | self.def_map.edition, | ||
175 | ); | ||
176 | |||
177 | let res = self.def_map.resolve_name_in_extern_prelude( | ||
178 | &import | ||
179 | .path | ||
180 | .as_ident() | ||
181 | .expect("extern crate should have been desugared to one-element path"), | ||
182 | ); | ||
183 | |||
184 | if let Some(ModuleDef::Module(m)) = res.take_types() { | ||
185 | tested_by!(macro_rules_from_other_crates_are_visible_with_macro_use); | ||
186 | self.import_all_macros_exported(m); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | fn import_all_macros_exported(&mut self, module: Module) { | ||
191 | let item_map = self.db.crate_def_map(module.krate); | ||
192 | for (name, ¯o_id) in &item_map.exported_macros { | ||
193 | self.global_macro_scope.insert(name.clone(), macro_id); | ||
194 | } | ||
195 | } | ||
196 | |||
165 | fn resolve_imports(&mut self) -> ReachedFixedPoint { | 197 | fn resolve_imports(&mut self) -> ReachedFixedPoint { |
166 | let mut imports = std::mem::replace(&mut self.unresolved_imports, Vec::new()); | 198 | let mut imports = std::mem::replace(&mut self.unresolved_imports, Vec::new()); |
167 | let mut resolved = Vec::new(); | 199 | let mut resolved = Vec::new(); |
@@ -491,13 +523,31 @@ where | |||
491 | DB: DefDatabase, | 523 | DB: DefDatabase, |
492 | { | 524 | { |
493 | fn collect(&mut self, items: &[raw::RawItem]) { | 525 | fn collect(&mut self, items: &[raw::RawItem]) { |
526 | // Prelude module is always considered to be `#[macro_use]`. | ||
527 | if let Some(prelude_module) = self.def_collector.def_map.prelude { | ||
528 | tested_by!(prelude_is_macro_use); | ||
529 | self.def_collector.import_all_macros_exported(prelude_module); | ||
530 | } | ||
531 | |||
532 | // This should be processed eagerly instead of deferred to resolving. | ||
533 | // `#[macro_use] extern crate` is hoisted to imports macros before collecting | ||
534 | // any other items. | ||
535 | for item in items { | ||
536 | if let raw::RawItem::Import(import_id) = *item { | ||
537 | let import = self.raw_items[import_id].clone(); | ||
538 | if import.is_extern_crate && import.is_macro_use { | ||
539 | self.def_collector.import_macros_from_extern_crate(&import); | ||
540 | } | ||
541 | } | ||
542 | } | ||
543 | |||
494 | for item in items { | 544 | for item in items { |
495 | match *item { | 545 | match *item { |
496 | raw::RawItem::Module(m) => self.collect_module(&self.raw_items[m]), | 546 | raw::RawItem::Module(m) => self.collect_module(&self.raw_items[m]), |
497 | raw::RawItem::Import(import) => self.def_collector.unresolved_imports.push(( | 547 | raw::RawItem::Import(import_id) => self.def_collector.unresolved_imports.push(( |
498 | self.module_id, | 548 | self.module_id, |
499 | import, | 549 | import_id, |
500 | self.raw_items[import].clone(), | 550 | self.raw_items[import_id].clone(), |
501 | )), | 551 | )), |
502 | raw::RawItem::Def(def) => self.define_def(&self.raw_items[def]), | 552 | raw::RawItem::Def(def) => self.define_def(&self.raw_items[def]), |
503 | raw::RawItem::Macro(mac) => self.collect_macro(&self.raw_items[mac]), | 553 | raw::RawItem::Macro(mac) => self.collect_macro(&self.raw_items[mac]), |
@@ -531,7 +581,7 @@ where | |||
531 | name, | 581 | name, |
532 | is_root, | 582 | is_root, |
533 | attr_path.as_ref(), | 583 | attr_path.as_ref(), |
534 | self.parent_module.as_ref(), | 584 | self.parent_module, |
535 | ) { | 585 | ) { |
536 | Ok(file_id) => { | 586 | Ok(file_id) => { |
537 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); | 587 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); |
@@ -642,180 +692,6 @@ fn is_macro_rules(path: &Path) -> bool { | |||
642 | path.as_ident() == Some(&MACRO_RULES) | 692 | path.as_ident() == Some(&MACRO_RULES) |
643 | } | 693 | } |
644 | 694 | ||
645 | fn resolve_submodule( | ||
646 | db: &impl DefDatabase, | ||
647 | file_id: HirFileId, | ||
648 | name: &Name, | ||
649 | is_root: bool, | ||
650 | attr_path: Option<&SmolStr>, | ||
651 | parent_module: Option<&ParentModule>, | ||
652 | ) -> Result<FileId, RelativePathBuf> { | ||
653 | let file_id = file_id.original_file(db); | ||
654 | let source_root_id = db.file_source_root(file_id); | ||
655 | let path = db.file_relative_path(file_id); | ||
656 | let root = RelativePathBuf::default(); | ||
657 | let dir_path = path.parent().unwrap_or(&root); | ||
658 | let mod_name = path.file_stem().unwrap_or("unknown"); | ||
659 | |||
660 | let resolve_mode = match (attr_path.filter(|p| !p.is_empty()), parent_module) { | ||
661 | (Some(file_path), Some(parent_module)) => { | ||
662 | let file_path = normalize_attribute_path(file_path); | ||
663 | match parent_module.attribute_path() { | ||
664 | Some(parent_module_attr_path) => { | ||
665 | let path = dir_path | ||
666 | .join(format!( | ||
667 | "{}/{}", | ||
668 | normalize_attribute_path(parent_module_attr_path), | ||
669 | file_path | ||
670 | )) | ||
671 | .normalize(); | ||
672 | ResolutionMode::InlineModuleWithAttributePath( | ||
673 | InsideInlineModuleMode::WithAttributePath(path), | ||
674 | ) | ||
675 | } | ||
676 | None => { | ||
677 | let path = | ||
678 | dir_path.join(format!("{}/{}", parent_module.name, file_path)).normalize(); | ||
679 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::WithAttributePath( | ||
680 | path, | ||
681 | )) | ||
682 | } | ||
683 | } | ||
684 | } | ||
685 | (None, Some(parent_module)) => match parent_module.attribute_path() { | ||
686 | Some(parent_module_attr_path) => { | ||
687 | let path = dir_path.join(format!( | ||
688 | "{}/{}.rs", | ||
689 | normalize_attribute_path(parent_module_attr_path), | ||
690 | name | ||
691 | )); | ||
692 | ResolutionMode::InlineModuleWithAttributePath(InsideInlineModuleMode::File(path)) | ||
693 | } | ||
694 | None => { | ||
695 | let path = dir_path.join(format!("{}/{}.rs", parent_module.name, name)); | ||
696 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::File(path)) | ||
697 | } | ||
698 | }, | ||
699 | (Some(file_path), None) => { | ||
700 | let file_path = normalize_attribute_path(file_path); | ||
701 | let path = dir_path.join(file_path.as_ref()).normalize(); | ||
702 | ResolutionMode::OutOfLine(OutOfLineMode::WithAttributePath(path)) | ||
703 | } | ||
704 | _ => { | ||
705 | let is_dir_owner = is_root || mod_name == "mod"; | ||
706 | if is_dir_owner { | ||
707 | let file_mod = dir_path.join(format!("{}.rs", name)); | ||
708 | let dir_mod = dir_path.join(format!("{}/mod.rs", name)); | ||
709 | ResolutionMode::OutOfLine(OutOfLineMode::RootOrModRs { | ||
710 | file: file_mod, | ||
711 | directory: dir_mod, | ||
712 | }) | ||
713 | } else { | ||
714 | let path = dir_path.join(format!("{}/{}.rs", mod_name, name)); | ||
715 | ResolutionMode::OutOfLine(OutOfLineMode::FileInDirectory(path)) | ||
716 | } | ||
717 | } | ||
718 | }; | ||
719 | |||
720 | resolve_mode.resolve(db.source_root(source_root_id)) | ||
721 | } | ||
722 | |||
723 | fn normalize_attribute_path(file_path: &SmolStr) -> Cow<str> { | ||
724 | let current_dir = "./"; | ||
725 | let windows_path_separator = r#"\"#; | ||
726 | let current_dir_normalize = if file_path.starts_with(current_dir) { | ||
727 | &file_path[current_dir.len()..] | ||
728 | } else { | ||
729 | file_path.as_str() | ||
730 | }; | ||
731 | if current_dir_normalize.contains(windows_path_separator) { | ||
732 | Cow::Owned(current_dir_normalize.replace(windows_path_separator, "/")) | ||
733 | } else { | ||
734 | Cow::Borrowed(current_dir_normalize) | ||
735 | } | ||
736 | } | ||
737 | |||
738 | enum OutOfLineMode { | ||
739 | RootOrModRs { file: RelativePathBuf, directory: RelativePathBuf }, | ||
740 | FileInDirectory(RelativePathBuf), | ||
741 | WithAttributePath(RelativePathBuf), | ||
742 | } | ||
743 | |||
744 | impl OutOfLineMode { | ||
745 | pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { | ||
746 | match self { | ||
747 | OutOfLineMode::RootOrModRs { file, directory } => match source_root.files.get(file) { | ||
748 | None => resolve_simple_path(source_root, directory).map_err(|_| file.clone()), | ||
749 | file_id => resolve_find_result(file_id, file), | ||
750 | }, | ||
751 | OutOfLineMode::FileInDirectory(path) => resolve_simple_path(source_root, path), | ||
752 | OutOfLineMode::WithAttributePath(path) => resolve_simple_path(source_root, path), | ||
753 | } | ||
754 | } | ||
755 | } | ||
756 | |||
757 | enum InsideInlineModuleMode { | ||
758 | File(RelativePathBuf), | ||
759 | WithAttributePath(RelativePathBuf), | ||
760 | } | ||
761 | |||
762 | impl InsideInlineModuleMode { | ||
763 | pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { | ||
764 | match self { | ||
765 | InsideInlineModuleMode::File(path) => resolve_simple_path(source_root, path), | ||
766 | InsideInlineModuleMode::WithAttributePath(path) => { | ||
767 | resolve_simple_path(source_root, path) | ||
768 | } | ||
769 | } | ||
770 | } | ||
771 | } | ||
772 | |||
773 | enum ResolutionMode { | ||
774 | OutOfLine(OutOfLineMode), | ||
775 | InsideInlineModule(InsideInlineModuleMode), | ||
776 | InlineModuleWithAttributePath(InsideInlineModuleMode), | ||
777 | } | ||
778 | |||
779 | impl ResolutionMode { | ||
780 | pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { | ||
781 | use self::ResolutionMode::*; | ||
782 | |||
783 | match self { | ||
784 | OutOfLine(mode) => mode.resolve(source_root), | ||
785 | InsideInlineModule(mode) => mode.resolve(source_root), | ||
786 | InlineModuleWithAttributePath(mode) => mode.resolve(source_root), | ||
787 | } | ||
788 | } | ||
789 | } | ||
790 | |||
791 | fn resolve_simple_path( | ||
792 | source_root: Arc<SourceRoot>, | ||
793 | path: &RelativePathBuf, | ||
794 | ) -> Result<FileId, RelativePathBuf> { | ||
795 | resolve_find_result(source_root.files.get(path), path) | ||
796 | } | ||
797 | |||
798 | fn resolve_find_result( | ||
799 | file_id: Option<&FileId>, | ||
800 | path: &RelativePathBuf, | ||
801 | ) -> Result<FileId, RelativePathBuf> { | ||
802 | match file_id { | ||
803 | Some(file_id) => Ok(file_id.clone()), | ||
804 | None => Err(path.clone()), | ||
805 | } | ||
806 | } | ||
807 | |||
808 | struct ParentModule<'a> { | ||
809 | name: &'a Name, | ||
810 | attr_path: Option<&'a SmolStr>, | ||
811 | } | ||
812 | |||
813 | impl<'a> ParentModule<'a> { | ||
814 | pub fn attribute_path(&self) -> Option<&SmolStr> { | ||
815 | self.attr_path.filter(|p| !p.is_empty()) | ||
816 | } | ||
817 | } | ||
818 | |||
819 | #[cfg(test)] | 695 | #[cfg(test)] |
820 | mod tests { | 696 | mod tests { |
821 | use ra_db::SourceDatabase; | 697 | use ra_db::SourceDatabase; |
@@ -860,6 +736,7 @@ mod tests { | |||
860 | root, | 736 | root, |
861 | modules, | 737 | modules, |
862 | poison_macros: FxHashSet::default(), | 738 | poison_macros: FxHashSet::default(), |
739 | exported_macros: FxHashMap::default(), | ||
863 | diagnostics: Vec::new(), | 740 | diagnostics: Vec::new(), |
864 | } | 741 | } |
865 | }; | 742 | }; |
diff --git a/crates/ra_hir/src/nameres/mod_resolution.rs b/crates/ra_hir/src/nameres/mod_resolution.rs new file mode 100644 index 000000000..918c9591f --- /dev/null +++ b/crates/ra_hir/src/nameres/mod_resolution.rs | |||
@@ -0,0 +1,186 @@ | |||
1 | //! This module resolves `mod foo;` declaration to file. | ||
2 | |||
3 | use std::{borrow::Cow, sync::Arc}; | ||
4 | |||
5 | use ra_db::{FileId, SourceRoot}; | ||
6 | use ra_syntax::SmolStr; | ||
7 | use relative_path::RelativePathBuf; | ||
8 | |||
9 | use crate::{DefDatabase, HirFileId, Name}; | ||
10 | |||
11 | #[derive(Clone, Copy)] | ||
12 | pub(super) struct ParentModule<'a> { | ||
13 | pub(super) name: &'a Name, | ||
14 | pub(super) attr_path: Option<&'a SmolStr>, | ||
15 | } | ||
16 | |||
17 | impl<'a> ParentModule<'a> { | ||
18 | fn attribute_path(&self) -> Option<&SmolStr> { | ||
19 | self.attr_path.filter(|p| !p.is_empty()) | ||
20 | } | ||
21 | } | ||
22 | |||
23 | pub(super) fn resolve_submodule( | ||
24 | db: &impl DefDatabase, | ||
25 | file_id: HirFileId, | ||
26 | name: &Name, | ||
27 | is_root: bool, | ||
28 | attr_path: Option<&SmolStr>, | ||
29 | parent_module: Option<ParentModule<'_>>, | ||
30 | ) -> Result<FileId, RelativePathBuf> { | ||
31 | let file_id = file_id.original_file(db); | ||
32 | let source_root_id = db.file_source_root(file_id); | ||
33 | let path = db.file_relative_path(file_id); | ||
34 | let root = RelativePathBuf::default(); | ||
35 | let dir_path = path.parent().unwrap_or(&root); | ||
36 | let mod_name = path.file_stem().unwrap_or("unknown"); | ||
37 | |||
38 | let resolve_mode = match (attr_path.filter(|p| !p.is_empty()), parent_module) { | ||
39 | (Some(file_path), Some(parent_module)) => { | ||
40 | let file_path = normalize_attribute_path(file_path); | ||
41 | match parent_module.attribute_path() { | ||
42 | Some(parent_module_attr_path) => { | ||
43 | let path = dir_path | ||
44 | .join(format!( | ||
45 | "{}/{}", | ||
46 | normalize_attribute_path(parent_module_attr_path), | ||
47 | file_path | ||
48 | )) | ||
49 | .normalize(); | ||
50 | ResolutionMode::InlineModuleWithAttributePath( | ||
51 | InsideInlineModuleMode::WithAttributePath(path), | ||
52 | ) | ||
53 | } | ||
54 | None => { | ||
55 | let path = | ||
56 | dir_path.join(format!("{}/{}", parent_module.name, file_path)).normalize(); | ||
57 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::WithAttributePath( | ||
58 | path, | ||
59 | )) | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | (None, Some(parent_module)) => match parent_module.attribute_path() { | ||
64 | Some(parent_module_attr_path) => { | ||
65 | let path = dir_path.join(format!( | ||
66 | "{}/{}.rs", | ||
67 | normalize_attribute_path(parent_module_attr_path), | ||
68 | name | ||
69 | )); | ||
70 | ResolutionMode::InlineModuleWithAttributePath(InsideInlineModuleMode::File(path)) | ||
71 | } | ||
72 | None => { | ||
73 | let path = dir_path.join(format!("{}/{}.rs", parent_module.name, name)); | ||
74 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::File(path)) | ||
75 | } | ||
76 | }, | ||
77 | (Some(file_path), None) => { | ||
78 | let file_path = normalize_attribute_path(file_path); | ||
79 | let path = dir_path.join(file_path.as_ref()).normalize(); | ||
80 | ResolutionMode::OutOfLine(OutOfLineMode::WithAttributePath(path)) | ||
81 | } | ||
82 | (None, None) => { | ||
83 | let is_dir_owner = is_root || mod_name == "mod"; | ||
84 | if is_dir_owner { | ||
85 | let file_mod = dir_path.join(format!("{}.rs", name)); | ||
86 | let dir_mod = dir_path.join(format!("{}/mod.rs", name)); | ||
87 | ResolutionMode::OutOfLine(OutOfLineMode::RootOrModRs { | ||
88 | file: file_mod, | ||
89 | directory: dir_mod, | ||
90 | }) | ||
91 | } else { | ||
92 | let path = dir_path.join(format!("{}/{}.rs", mod_name, name)); | ||
93 | ResolutionMode::OutOfLine(OutOfLineMode::FileInDirectory(path)) | ||
94 | } | ||
95 | } | ||
96 | }; | ||
97 | |||
98 | resolve_mode.resolve(db.source_root(source_root_id)) | ||
99 | } | ||
100 | |||
101 | fn normalize_attribute_path(file_path: &SmolStr) -> Cow<str> { | ||
102 | let current_dir = "./"; | ||
103 | let windows_path_separator = r#"\"#; | ||
104 | let current_dir_normalize = if file_path.starts_with(current_dir) { | ||
105 | &file_path[current_dir.len()..] | ||
106 | } else { | ||
107 | file_path.as_str() | ||
108 | }; | ||
109 | if current_dir_normalize.contains(windows_path_separator) { | ||
110 | Cow::Owned(current_dir_normalize.replace(windows_path_separator, "/")) | ||
111 | } else { | ||
112 | Cow::Borrowed(current_dir_normalize) | ||
113 | } | ||
114 | } | ||
115 | |||
116 | enum OutOfLineMode { | ||
117 | RootOrModRs { file: RelativePathBuf, directory: RelativePathBuf }, | ||
118 | FileInDirectory(RelativePathBuf), | ||
119 | WithAttributePath(RelativePathBuf), | ||
120 | } | ||
121 | |||
122 | impl OutOfLineMode { | ||
123 | pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { | ||
124 | match self { | ||
125 | OutOfLineMode::RootOrModRs { file, directory } => { | ||
126 | match source_root.file_by_relative_path(file) { | ||
127 | None => resolve_simple_path(source_root, directory).map_err(|_| file.clone()), | ||
128 | file_id => resolve_find_result(file_id, file), | ||
129 | } | ||
130 | } | ||
131 | OutOfLineMode::FileInDirectory(path) => resolve_simple_path(source_root, path), | ||
132 | OutOfLineMode::WithAttributePath(path) => resolve_simple_path(source_root, path), | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | |||
137 | enum InsideInlineModuleMode { | ||
138 | File(RelativePathBuf), | ||
139 | WithAttributePath(RelativePathBuf), | ||
140 | } | ||
141 | |||
142 | impl InsideInlineModuleMode { | ||
143 | pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { | ||
144 | match self { | ||
145 | InsideInlineModuleMode::File(path) => resolve_simple_path(source_root, path), | ||
146 | InsideInlineModuleMode::WithAttributePath(path) => { | ||
147 | resolve_simple_path(source_root, path) | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | } | ||
152 | |||
153 | enum ResolutionMode { | ||
154 | OutOfLine(OutOfLineMode), | ||
155 | InsideInlineModule(InsideInlineModuleMode), | ||
156 | InlineModuleWithAttributePath(InsideInlineModuleMode), | ||
157 | } | ||
158 | |||
159 | impl ResolutionMode { | ||
160 | pub fn resolve(&self, source_root: Arc<SourceRoot>) -> Result<FileId, RelativePathBuf> { | ||
161 | use self::ResolutionMode::*; | ||
162 | |||
163 | match self { | ||
164 | OutOfLine(mode) => mode.resolve(source_root), | ||
165 | InsideInlineModule(mode) => mode.resolve(source_root), | ||
166 | InlineModuleWithAttributePath(mode) => mode.resolve(source_root), | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | |||
171 | fn resolve_simple_path( | ||
172 | source_root: Arc<SourceRoot>, | ||
173 | path: &RelativePathBuf, | ||
174 | ) -> Result<FileId, RelativePathBuf> { | ||
175 | resolve_find_result(source_root.file_by_relative_path(path), path) | ||
176 | } | ||
177 | |||
178 | fn resolve_find_result( | ||
179 | file_id: Option<FileId>, | ||
180 | path: &RelativePathBuf, | ||
181 | ) -> Result<FileId, RelativePathBuf> { | ||
182 | match file_id { | ||
183 | Some(file_id) => Ok(file_id.clone()), | ||
184 | None => Err(path.clone()), | ||
185 | } | ||
186 | } | ||
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 2f973359f..129b047eb 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -154,6 +154,7 @@ pub struct ImportData { | |||
154 | pub(super) is_glob: bool, | 154 | pub(super) is_glob: bool, |
155 | pub(super) is_prelude: bool, | 155 | pub(super) is_prelude: bool, |
156 | pub(super) is_extern_crate: bool, | 156 | pub(super) is_extern_crate: bool, |
157 | pub(super) is_macro_use: bool, | ||
157 | } | 158 | } |
158 | 159 | ||
159 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 160 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -293,8 +294,14 @@ impl RawItemsCollector { | |||
293 | let is_prelude = use_item.has_atom_attr("prelude_import"); | 294 | let is_prelude = use_item.has_atom_attr("prelude_import"); |
294 | 295 | ||
295 | Path::expand_use_item(&use_item, |path, use_tree, is_glob, alias| { | 296 | Path::expand_use_item(&use_item, |path, use_tree, is_glob, alias| { |
296 | let import_data = | 297 | let import_data = ImportData { |
297 | ImportData { path, alias, is_glob, is_prelude, is_extern_crate: false }; | 298 | path, |
299 | alias, | ||
300 | is_glob, | ||
301 | is_prelude, | ||
302 | is_extern_crate: false, | ||
303 | is_macro_use: false, | ||
304 | }; | ||
298 | self.push_import(current_module, import_data, Either::A(AstPtr::new(use_tree))); | 305 | self.push_import(current_module, import_data, Either::A(AstPtr::new(use_tree))); |
299 | }) | 306 | }) |
300 | } | 307 | } |
@@ -307,12 +314,14 @@ impl RawItemsCollector { | |||
307 | if let Some(name_ref) = extern_crate.name_ref() { | 314 | if let Some(name_ref) = extern_crate.name_ref() { |
308 | let path = Path::from_name_ref(&name_ref); | 315 | let path = Path::from_name_ref(&name_ref); |
309 | let alias = extern_crate.alias().and_then(|a| a.name()).map(|it| it.as_name()); | 316 | let alias = extern_crate.alias().and_then(|a| a.name()).map(|it| it.as_name()); |
317 | let is_macro_use = extern_crate.has_atom_attr("macro_use"); | ||
310 | let import_data = ImportData { | 318 | let import_data = ImportData { |
311 | path, | 319 | path, |
312 | alias, | 320 | alias, |
313 | is_glob: false, | 321 | is_glob: false, |
314 | is_prelude: false, | 322 | is_prelude: false, |
315 | is_extern_crate: true, | 323 | is_extern_crate: true, |
324 | is_macro_use, | ||
316 | }; | 325 | }; |
317 | self.push_import(current_module, import_data, Either::B(AstPtr::new(&extern_crate))); | 326 | self.push_import(current_module, import_data, Either::B(AstPtr::new(&extern_crate))); |
318 | } | 327 | } |
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index c1dbad283..4ff897ca5 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs | |||
@@ -2,7 +2,7 @@ mod macros; | |||
2 | mod globs; | 2 | mod globs; |
3 | mod incremental; | 3 | mod incremental; |
4 | mod primitives; | 4 | mod primitives; |
5 | mod mods; | 5 | mod mod_resolution; |
6 | 6 | ||
7 | use std::sync::Arc; | 7 | use std::sync::Arc; |
8 | 8 | ||
diff --git a/crates/ra_hir/src/nameres/tests/macros.rs b/crates/ra_hir/src/nameres/tests/macros.rs index 631df2cef..aece1515b 100644 --- a/crates/ra_hir/src/nameres/tests/macros.rs +++ b/crates/ra_hir/src/nameres/tests/macros.rs | |||
@@ -99,14 +99,14 @@ fn macro_rules_from_other_crates_are_visible() { | |||
99 | fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | 99 | fn unexpanded_macro_should_expand_by_fixedpoint_loop() { |
100 | let map = def_map_with_crate_graph( | 100 | let map = def_map_with_crate_graph( |
101 | " | 101 | " |
102 | //- /main.rs | 102 | //- /main.rs |
103 | macro_rules! baz { | 103 | macro_rules! baz { |
104 | () => { | 104 | () => { |
105 | use foo::bar; | 105 | use foo::bar; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | foo!(); | 109 | foo!(); |
110 | bar!(); | 110 | bar!(); |
111 | baz!(); | 111 | baz!(); |
112 | 112 | ||
@@ -114,7 +114,7 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | |||
114 | #[macro_export] | 114 | #[macro_export] |
115 | macro_rules! foo { | 115 | macro_rules! foo { |
116 | () => { | 116 | () => { |
117 | struct Foo { field: u32 } | 117 | struct Foo { field: u32 } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | #[macro_export] | 120 | #[macro_export] |
@@ -137,3 +137,114 @@ fn unexpanded_macro_should_expand_by_fixedpoint_loop() { | |||
137 | â‹®foo: m | 137 | â‹®foo: m |
138 | "###); | 138 | "###); |
139 | } | 139 | } |
140 | |||
141 | #[test] | ||
142 | fn macro_rules_from_other_crates_are_visible_with_macro_use() { | ||
143 | covers!(macro_rules_from_other_crates_are_visible_with_macro_use); | ||
144 | let map = def_map_with_crate_graph( | ||
145 | " | ||
146 | //- /main.rs | ||
147 | structs!(Foo); | ||
148 | structs_priv!(Bar); | ||
149 | structs_not_exported!(MacroNotResolved1); | ||
150 | crate::structs!(MacroNotResolved2); | ||
151 | |||
152 | mod bar; | ||
153 | |||
154 | #[macro_use] | ||
155 | extern crate foo; | ||
156 | |||
157 | //- /bar.rs | ||
158 | structs!(Baz); | ||
159 | crate::structs!(MacroNotResolved3); | ||
160 | |||
161 | //- /lib.rs | ||
162 | #[macro_export] | ||
163 | macro_rules! structs { | ||
164 | ($i:ident) => { struct $i; } | ||
165 | } | ||
166 | |||
167 | macro_rules! structs_not_exported { | ||
168 | ($i:ident) => { struct $i; } | ||
169 | } | ||
170 | |||
171 | mod priv_mod { | ||
172 | #[macro_export] | ||
173 | macro_rules! structs_priv { | ||
174 | ($i:ident) => { struct $i; } | ||
175 | } | ||
176 | } | ||
177 | ", | ||
178 | crate_graph! { | ||
179 | "main": ("/main.rs", ["foo"]), | ||
180 | "foo": ("/lib.rs", []), | ||
181 | }, | ||
182 | ); | ||
183 | assert_snapshot!(map, @r###" | ||
184 | â‹®crate | ||
185 | â‹®Bar: t v | ||
186 | â‹®Foo: t v | ||
187 | â‹®bar: t | ||
188 | â‹®foo: t | ||
189 | â‹® | ||
190 | â‹®crate::bar | ||
191 | â‹®Baz: t v | ||
192 | "###); | ||
193 | } | ||
194 | |||
195 | #[test] | ||
196 | fn prelude_is_macro_use() { | ||
197 | covers!(prelude_is_macro_use); | ||
198 | let map = def_map_with_crate_graph( | ||
199 | " | ||
200 | //- /main.rs | ||
201 | structs!(Foo); | ||
202 | structs_priv!(Bar); | ||
203 | structs_outside!(Out); | ||
204 | crate::structs!(MacroNotResolved2); | ||
205 | |||
206 | mod bar; | ||
207 | |||
208 | //- /bar.rs | ||
209 | structs!(Baz); | ||
210 | crate::structs!(MacroNotResolved3); | ||
211 | |||
212 | //- /lib.rs | ||
213 | #[prelude_import] | ||
214 | use self::prelude::*; | ||
215 | |||
216 | mod prelude { | ||
217 | #[macro_export] | ||
218 | macro_rules! structs { | ||
219 | ($i:ident) => { struct $i; } | ||
220 | } | ||
221 | |||
222 | mod priv_mod { | ||
223 | #[macro_export] | ||
224 | macro_rules! structs_priv { | ||
225 | ($i:ident) => { struct $i; } | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | #[macro_export] | ||
231 | macro_rules! structs_outside { | ||
232 | ($i:ident) => { struct $i; } | ||
233 | } | ||
234 | ", | ||
235 | crate_graph! { | ||
236 | "main": ("/main.rs", ["foo"]), | ||
237 | "foo": ("/lib.rs", []), | ||
238 | }, | ||
239 | ); | ||
240 | assert_snapshot!(map, @r###" | ||
241 | â‹®crate | ||
242 | â‹®Bar: t v | ||
243 | â‹®Foo: t v | ||
244 | â‹®Out: t v | ||
245 | â‹®bar: t | ||
246 | â‹® | ||
247 | â‹®crate::bar | ||
248 | â‹®Baz: t v | ||
249 | "###); | ||
250 | } | ||
diff --git a/crates/ra_hir/src/nameres/tests/mods.rs b/crates/ra_hir/src/nameres/tests/mod_resolution.rs index 4f8398460..4f8398460 100644 --- a/crates/ra_hir/src/nameres/tests/mods.rs +++ b/crates/ra_hir/src/nameres/tests/mod_resolution.rs | |||
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs index 5ee71e421..24316fc91 100644 --- a/crates/ra_hir/src/path.rs +++ b/crates/ra_hir/src/path.rs | |||
@@ -31,7 +31,8 @@ pub struct GenericArgs { | |||
31 | /// Self type. Otherwise, when we have a path `Trait<X, Y>`, the Self type | 31 | /// Self type. Otherwise, when we have a path `Trait<X, Y>`, the Self type |
32 | /// is left out. | 32 | /// is left out. |
33 | pub has_self_type: bool, | 33 | pub has_self_type: bool, |
34 | // someday also bindings | 34 | /// Associated type bindings like in `Iterator<Item = T>`. |
35 | pub bindings: Vec<(Name, TypeRef)>, | ||
35 | } | 36 | } |
36 | 37 | ||
37 | /// A single generic argument. | 38 | /// A single generic argument. |
@@ -170,16 +171,24 @@ impl GenericArgs { | |||
170 | let type_ref = TypeRef::from_ast_opt(type_arg.type_ref()); | 171 | let type_ref = TypeRef::from_ast_opt(type_arg.type_ref()); |
171 | args.push(GenericArg::Type(type_ref)); | 172 | args.push(GenericArg::Type(type_ref)); |
172 | } | 173 | } |
173 | // lifetimes and assoc type args ignored for now | 174 | // lifetimes ignored for now |
174 | if !args.is_empty() { | 175 | let mut bindings = Vec::new(); |
175 | Some(GenericArgs { args, has_self_type: false }) | 176 | for assoc_type_arg in node.assoc_type_args() { |
176 | } else { | 177 | if let Some(name_ref) = assoc_type_arg.name_ref() { |
178 | let name = name_ref.as_name(); | ||
179 | let type_ref = TypeRef::from_ast_opt(assoc_type_arg.type_ref()); | ||
180 | bindings.push((name, type_ref)); | ||
181 | } | ||
182 | } | ||
183 | if args.is_empty() && bindings.is_empty() { | ||
177 | None | 184 | None |
185 | } else { | ||
186 | Some(GenericArgs { args, has_self_type: false, bindings }) | ||
178 | } | 187 | } |
179 | } | 188 | } |
180 | 189 | ||
181 | pub(crate) fn empty() -> GenericArgs { | 190 | pub(crate) fn empty() -> GenericArgs { |
182 | GenericArgs { args: Vec::new(), has_self_type: false } | 191 | GenericArgs { args: Vec::new(), has_self_type: false, bindings: Vec::new() } |
183 | } | 192 | } |
184 | } | 193 | } |
185 | 194 | ||
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index e5f4d11a6..fdbe5e8b0 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -228,7 +228,7 @@ impl SourceAnalyzer { | |||
228 | let scopes = db.expr_scopes(def); | 228 | let scopes = db.expr_scopes(def); |
229 | let scope = match offset { | 229 | let scope = match offset { |
230 | None => scope_for(&scopes, &source_map, &node), | 230 | None => scope_for(&scopes, &source_map, &node), |
231 | Some(offset) => scope_for_offset(&scopes, &source_map, offset), | 231 | Some(offset) => scope_for_offset(&scopes, &source_map, file_id.into(), offset), |
232 | }; | 232 | }; |
233 | let resolver = expr::resolver_for_scope(def.body(db), db, scope); | 233 | let resolver = expr::resolver_for_scope(def.body(db), db, scope); |
234 | SourceAnalyzer { | 234 | SourceAnalyzer { |
@@ -330,6 +330,7 @@ impl SourceAnalyzer { | |||
330 | .body_source_map | 330 | .body_source_map |
331 | .as_ref()? | 331 | .as_ref()? |
332 | .pat_syntax(it)? | 332 | .pat_syntax(it)? |
333 | .ast // FIXME: ignoring file_id here is definitelly wrong | ||
333 | .map_a(|ptr| ptr.cast::<ast::BindPat>().unwrap()); | 334 | .map_a(|ptr| ptr.cast::<ast::BindPat>().unwrap()); |
334 | PathResolution::LocalBinding(pat_ptr) | 335 | PathResolution::LocalBinding(pat_ptr) |
335 | } | 336 | } |
@@ -354,7 +355,7 @@ impl SourceAnalyzer { | |||
354 | ret.and_then(|entry| { | 355 | ret.and_then(|entry| { |
355 | Some(ScopeEntryWithSyntax { | 356 | Some(ScopeEntryWithSyntax { |
356 | name: entry.name().clone(), | 357 | name: entry.name().clone(), |
357 | ptr: source_map.pat_syntax(entry.pat())?, | 358 | ptr: source_map.pat_syntax(entry.pat())?.ast, |
358 | }) | 359 | }) |
359 | }) | 360 | }) |
360 | } | 361 | } |
@@ -470,20 +471,27 @@ fn scope_for( | |||
470 | fn scope_for_offset( | 471 | fn scope_for_offset( |
471 | scopes: &ExprScopes, | 472 | scopes: &ExprScopes, |
472 | source_map: &BodySourceMap, | 473 | source_map: &BodySourceMap, |
474 | file_id: HirFileId, | ||
473 | offset: TextUnit, | 475 | offset: TextUnit, |
474 | ) -> Option<ScopeId> { | 476 | ) -> Option<ScopeId> { |
475 | scopes | 477 | scopes |
476 | .scope_by_expr() | 478 | .scope_by_expr() |
477 | .iter() | 479 | .iter() |
478 | .filter_map(|(id, scope)| { | 480 | .filter_map(|(id, scope)| { |
479 | let ast_ptr = source_map.expr_syntax(*id)?.a()?; | 481 | let source = source_map.expr_syntax(*id)?; |
480 | Some((ast_ptr.syntax_node_ptr(), scope)) | 482 | // FIXME: correctly handle macro expansion |
483 | if source.file_id != file_id { | ||
484 | return None; | ||
485 | } | ||
486 | let syntax_node_ptr = | ||
487 | source.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | ||
488 | Some((syntax_node_ptr, scope)) | ||
481 | }) | 489 | }) |
482 | // find containing scope | 490 | // find containing scope |
483 | .min_by_key(|(ptr, _scope)| { | 491 | .min_by_key(|(ptr, _scope)| { |
484 | (!(ptr.range().start() <= offset && offset <= ptr.range().end()), ptr.range().len()) | 492 | (!(ptr.range().start() <= offset && offset <= ptr.range().end()), ptr.range().len()) |
485 | }) | 493 | }) |
486 | .map(|(ptr, scope)| adjust(scopes, source_map, ptr, offset).unwrap_or(*scope)) | 494 | .map(|(ptr, scope)| adjust(scopes, source_map, ptr, file_id, offset).unwrap_or(*scope)) |
487 | } | 495 | } |
488 | 496 | ||
489 | // XXX: during completion, cursor might be outside of any particular | 497 | // XXX: during completion, cursor might be outside of any particular |
@@ -492,6 +500,7 @@ fn adjust( | |||
492 | scopes: &ExprScopes, | 500 | scopes: &ExprScopes, |
493 | source_map: &BodySourceMap, | 501 | source_map: &BodySourceMap, |
494 | ptr: SyntaxNodePtr, | 502 | ptr: SyntaxNodePtr, |
503 | file_id: HirFileId, | ||
495 | offset: TextUnit, | 504 | offset: TextUnit, |
496 | ) -> Option<ScopeId> { | 505 | ) -> Option<ScopeId> { |
497 | let r = ptr.range(); | 506 | let r = ptr.range(); |
@@ -499,8 +508,14 @@ fn adjust( | |||
499 | .scope_by_expr() | 508 | .scope_by_expr() |
500 | .iter() | 509 | .iter() |
501 | .filter_map(|(id, scope)| { | 510 | .filter_map(|(id, scope)| { |
502 | let ast_ptr = source_map.expr_syntax(*id)?.a()?; | 511 | let source = source_map.expr_syntax(*id)?; |
503 | Some((ast_ptr.syntax_node_ptr(), scope)) | 512 | // FIXME: correctly handle macro expansion |
513 | if source.file_id != file_id { | ||
514 | return None; | ||
515 | } | ||
516 | let syntax_node_ptr = | ||
517 | source.ast.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); | ||
518 | Some((syntax_node_ptr, scope)) | ||
504 | }) | 519 | }) |
505 | .map(|(ptr, scope)| (ptr.range(), scope)) | 520 | .map(|(ptr, scope)| (ptr.range(), scope)) |
506 | .filter(|(range, _)| range.start() <= offset && range.is_subrange(&r) && *range != r); | 521 | .filter(|(range, _)| range.start() <= offset && range.is_subrange(&r) && *range != r); |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index b54c80318..a3df08827 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -120,12 +120,44 @@ pub struct ProjectionTy { | |||
120 | pub parameters: Substs, | 120 | pub parameters: Substs, |
121 | } | 121 | } |
122 | 122 | ||
123 | impl ProjectionTy { | ||
124 | pub fn trait_ref(&self, db: &impl HirDatabase) -> TraitRef { | ||
125 | TraitRef { | ||
126 | trait_: self | ||
127 | .associated_ty | ||
128 | .parent_trait(db) | ||
129 | .expect("projection ty without parent trait"), | ||
130 | substs: self.parameters.clone(), | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | impl TypeWalk for ProjectionTy { | ||
136 | fn walk(&self, f: &mut impl FnMut(&Ty)) { | ||
137 | self.parameters.walk(f); | ||
138 | } | ||
139 | |||
140 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | ||
141 | self.parameters.walk_mut(f); | ||
142 | } | ||
143 | } | ||
144 | |||
123 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 145 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
124 | pub struct UnselectedProjectionTy { | 146 | pub struct UnselectedProjectionTy { |
125 | pub type_name: Name, | 147 | pub type_name: Name, |
126 | pub parameters: Substs, | 148 | pub parameters: Substs, |
127 | } | 149 | } |
128 | 150 | ||
151 | impl TypeWalk for UnselectedProjectionTy { | ||
152 | fn walk(&self, f: &mut impl FnMut(&Ty)) { | ||
153 | self.parameters.walk(f); | ||
154 | } | ||
155 | |||
156 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | ||
157 | self.parameters.walk_mut(f); | ||
158 | } | ||
159 | } | ||
160 | |||
129 | /// A type. | 161 | /// A type. |
130 | /// | 162 | /// |
131 | /// See also the `TyKind` enum in rustc (librustc/ty/sty.rs), which represents | 163 | /// See also the `TyKind` enum in rustc (librustc/ty/sty.rs), which represents |
@@ -282,20 +314,14 @@ impl TraitRef { | |||
282 | pub fn self_ty(&self) -> &Ty { | 314 | pub fn self_ty(&self) -> &Ty { |
283 | &self.substs[0] | 315 | &self.substs[0] |
284 | } | 316 | } |
317 | } | ||
285 | 318 | ||
286 | pub fn subst(mut self, substs: &Substs) -> TraitRef { | 319 | impl TypeWalk for TraitRef { |
287 | self.substs.walk_mut(&mut |ty_mut| { | 320 | fn walk(&self, f: &mut impl FnMut(&Ty)) { |
288 | let ty = mem::replace(ty_mut, Ty::Unknown); | ||
289 | *ty_mut = ty.subst(substs); | ||
290 | }); | ||
291 | self | ||
292 | } | ||
293 | |||
294 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { | ||
295 | self.substs.walk(f); | 321 | self.substs.walk(f); |
296 | } | 322 | } |
297 | 323 | ||
298 | pub fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | 324 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { |
299 | self.substs.walk_mut(f); | 325 | self.substs.walk_mut(f); |
300 | } | 326 | } |
301 | } | 327 | } |
@@ -306,6 +332,8 @@ impl TraitRef { | |||
306 | pub enum GenericPredicate { | 332 | pub enum GenericPredicate { |
307 | /// The given trait needs to be implemented for its type parameters. | 333 | /// The given trait needs to be implemented for its type parameters. |
308 | Implemented(TraitRef), | 334 | Implemented(TraitRef), |
335 | /// An associated type bindings like in `Iterator<Item = T>`. | ||
336 | Projection(ProjectionPredicate), | ||
309 | /// We couldn't resolve the trait reference. (If some type parameters can't | 337 | /// We couldn't resolve the trait reference. (If some type parameters can't |
310 | /// be resolved, they will just be Unknown). | 338 | /// be resolved, they will just be Unknown). |
311 | Error, | 339 | Error, |
@@ -319,25 +347,35 @@ impl GenericPredicate { | |||
319 | } | 347 | } |
320 | } | 348 | } |
321 | 349 | ||
322 | pub fn subst(self, substs: &Substs) -> GenericPredicate { | 350 | pub fn is_implemented(&self) -> bool { |
323 | match self { | 351 | match self { |
324 | GenericPredicate::Implemented(trait_ref) => { | 352 | GenericPredicate::Implemented(_) => true, |
325 | GenericPredicate::Implemented(trait_ref.subst(substs)) | 353 | _ => false, |
326 | } | ||
327 | GenericPredicate::Error => self, | ||
328 | } | 354 | } |
329 | } | 355 | } |
330 | 356 | ||
331 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { | 357 | pub fn trait_ref(&self, db: &impl HirDatabase) -> Option<TraitRef> { |
358 | match self { | ||
359 | GenericPredicate::Implemented(tr) => Some(tr.clone()), | ||
360 | GenericPredicate::Projection(proj) => Some(proj.projection_ty.trait_ref(db)), | ||
361 | GenericPredicate::Error => None, | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | |||
366 | impl TypeWalk for GenericPredicate { | ||
367 | fn walk(&self, f: &mut impl FnMut(&Ty)) { | ||
332 | match self { | 368 | match self { |
333 | GenericPredicate::Implemented(trait_ref) => trait_ref.walk(f), | 369 | GenericPredicate::Implemented(trait_ref) => trait_ref.walk(f), |
370 | GenericPredicate::Projection(projection_pred) => projection_pred.walk(f), | ||
334 | GenericPredicate::Error => {} | 371 | GenericPredicate::Error => {} |
335 | } | 372 | } |
336 | } | 373 | } |
337 | 374 | ||
338 | pub fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | 375 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { |
339 | match self { | 376 | match self { |
340 | GenericPredicate::Implemented(trait_ref) => trait_ref.walk_mut(f), | 377 | GenericPredicate::Implemented(trait_ref) => trait_ref.walk_mut(f), |
378 | GenericPredicate::Projection(projection_pred) => projection_pred.walk_mut(f), | ||
341 | GenericPredicate::Error => {} | 379 | GenericPredicate::Error => {} |
342 | } | 380 | } |
343 | } | 381 | } |
@@ -378,16 +416,16 @@ impl FnSig { | |||
378 | pub fn ret(&self) -> &Ty { | 416 | pub fn ret(&self) -> &Ty { |
379 | &self.params_and_return[self.params_and_return.len() - 1] | 417 | &self.params_and_return[self.params_and_return.len() - 1] |
380 | } | 418 | } |
419 | } | ||
381 | 420 | ||
382 | /// Applies the given substitutions to all types in this signature and | 421 | impl TypeWalk for FnSig { |
383 | /// returns the result. | 422 | fn walk(&self, f: &mut impl FnMut(&Ty)) { |
384 | pub fn subst(&self, substs: &Substs) -> FnSig { | 423 | for t in self.params_and_return.iter() { |
385 | let result: Vec<_> = | 424 | t.walk(f); |
386 | self.params_and_return.iter().map(|ty| ty.clone().subst(substs)).collect(); | 425 | } |
387 | FnSig { params_and_return: result.into() } | ||
388 | } | 426 | } |
389 | 427 | ||
390 | pub fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | 428 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { |
391 | // Without an Arc::make_mut_slice, we can't avoid the clone here: | 429 | // Without an Arc::make_mut_slice, we can't avoid the clone here: |
392 | let mut v: Vec<_> = self.params_and_return.iter().cloned().collect(); | 430 | let mut v: Vec<_> = self.params_and_return.iter().cloned().collect(); |
393 | for t in &mut v { | 431 | for t in &mut v { |
@@ -411,64 +449,6 @@ impl Ty { | |||
411 | Ty::apply(TypeCtor::Tuple { cardinality: 0 }, Substs::empty()) | 449 | Ty::apply(TypeCtor::Tuple { cardinality: 0 }, Substs::empty()) |
412 | } | 450 | } |
413 | 451 | ||
414 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { | ||
415 | match self { | ||
416 | Ty::Apply(a_ty) => { | ||
417 | for t in a_ty.parameters.iter() { | ||
418 | t.walk(f); | ||
419 | } | ||
420 | } | ||
421 | Ty::Projection(p_ty) => { | ||
422 | for t in p_ty.parameters.iter() { | ||
423 | t.walk(f); | ||
424 | } | ||
425 | } | ||
426 | Ty::UnselectedProjection(p_ty) => { | ||
427 | for t in p_ty.parameters.iter() { | ||
428 | t.walk(f); | ||
429 | } | ||
430 | } | ||
431 | Ty::Dyn(predicates) | Ty::Opaque(predicates) => { | ||
432 | for p in predicates.iter() { | ||
433 | p.walk(f); | ||
434 | } | ||
435 | } | ||
436 | Ty::Param { .. } | Ty::Bound(_) | Ty::Infer(_) | Ty::Unknown => {} | ||
437 | } | ||
438 | f(self); | ||
439 | } | ||
440 | |||
441 | fn walk_mut(&mut self, f: &mut impl FnMut(&mut Ty)) { | ||
442 | match self { | ||
443 | Ty::Apply(a_ty) => { | ||
444 | a_ty.parameters.walk_mut(f); | ||
445 | } | ||
446 | Ty::Projection(p_ty) => { | ||
447 | p_ty.parameters.walk_mut(f); | ||
448 | } | ||
449 | Ty::UnselectedProjection(p_ty) => { | ||
450 | p_ty.parameters.walk_mut(f); | ||
451 | } | ||
452 | Ty::Dyn(predicates) | Ty::Opaque(predicates) => { | ||
453 | let mut v: Vec<_> = predicates.iter().cloned().collect(); | ||
454 | for p in &mut v { | ||
455 | p.walk_mut(f); | ||
456 | } | ||
457 | *predicates = v.into(); | ||
458 | } | ||
459 | Ty::Param { .. } | Ty::Bound(_) | Ty::Infer(_) | Ty::Unknown => {} | ||
460 | } | ||
461 | f(self); | ||
462 | } | ||
463 | |||
464 | fn fold(mut self, f: &mut impl FnMut(Ty) -> Ty) -> Ty { | ||
465 | self.walk_mut(&mut |ty_mut| { | ||
466 | let ty = mem::replace(ty_mut, Ty::Unknown); | ||
467 | *ty_mut = f(ty); | ||
468 | }); | ||
469 | self | ||
470 | } | ||
471 | |||
472 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { | 452 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { |
473 | match self { | 453 | match self { |
474 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(mutability), parameters }) => { | 454 | Ty::Apply(ApplicationTy { ctor: TypeCtor::Ref(mutability), parameters }) => { |
@@ -544,10 +524,53 @@ impl Ty { | |||
544 | } | 524 | } |
545 | } | 525 | } |
546 | 526 | ||
527 | /// Returns the type parameters of this type if it has some (i.e. is an ADT | ||
528 | /// or function); so if `self` is `Option<u32>`, this returns the `u32`. | ||
529 | pub fn substs(&self) -> Option<Substs> { | ||
530 | match self { | ||
531 | Ty::Apply(ApplicationTy { parameters, .. }) => Some(parameters.clone()), | ||
532 | _ => None, | ||
533 | } | ||
534 | } | ||
535 | |||
536 | /// If this is an `impl Trait` or `dyn Trait`, returns that trait. | ||
537 | pub fn inherent_trait(&self) -> Option<Trait> { | ||
538 | match self { | ||