aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock175
-rw-r--r--crates/ra_assists/src/assist_ctx.rs4
-rw-r--r--crates/ra_assists/src/assists/add_new.rs6
-rw-r--r--crates/ra_cli/Cargo.toml2
-rw-r--r--crates/ra_cli/src/main.rs3
-rw-r--r--crates/ra_hir/src/code_model.rs6
-rw-r--r--crates/ra_hir/src/code_model/src.rs41
-rw-r--r--crates/ra_hir/src/from_source.rs62
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir/src/source_binder.rs30
-rw-r--r--crates/ra_hir_def/src/adt.rs8
-rw-r--r--crates/ra_hir_def/src/attr.rs9
-rw-r--r--crates/ra_hir_def/src/body.rs24
-rw-r--r--crates/ra_hir_def/src/body/lower.rs11
-rw-r--r--crates/ra_hir_def/src/body/scope.rs6
-rw-r--r--crates/ra_hir_def/src/data.rs5
-rw-r--r--crates/ra_hir_def/src/diagnostics.rs6
-rw-r--r--crates/ra_hir_def/src/docs.rs6
-rw-r--r--crates/ra_hir_def/src/expr.rs14
-rw-r--r--crates/ra_hir_def/src/generics.rs3
-rw-r--r--crates/ra_hir_def/src/lib.rs60
-rw-r--r--crates/ra_hir_def/src/nameres.rs45
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs4
-rw-r--r--crates/ra_hir_def/src/nameres/path_resolution.rs55
-rw-r--r--crates/ra_hir_def/src/nameres/raw.rs6
-rw-r--r--crates/ra_hir_def/src/nameres/tests/mod_resolution.rs4
-rw-r--r--crates/ra_hir_def/src/path.rs34
-rw-r--r--crates/ra_hir_def/src/resolver.rs38
-rw-r--r--crates/ra_hir_def/src/src.rs54
-rw-r--r--crates/ra_hir_expand/src/diagnostics.rs4
-rw-r--r--crates/ra_hir_expand/src/lib.rs81
-rw-r--r--crates/ra_hir_expand/src/name.rs6
-rw-r--r--crates/ra_hir_ty/src/db.rs12
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs14
-rw-r--r--crates/ra_hir_ty/src/infer.rs38
-rw-r--r--crates/ra_hir_ty/src/infer/coerce.rs7
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs39
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs2
-rw-r--r--crates/ra_hir_ty/src/lib.rs15
-rw-r--r--crates/ra_hir_ty/src/lower.rs49
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs9
-rw-r--r--crates/ra_hir_ty/src/tests.rs146
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs15
-rw-r--r--crates/ra_ide/src/call_info.rs2
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs4
-rw-r--r--crates/ra_ide/src/diagnostics.rs2
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs4
-rw-r--r--crates/ra_ide/src/expand.rs8
-rw-r--r--crates/ra_ide/src/expand_macro.rs8
-rw-r--r--crates/ra_ide/src/goto_definition.rs8
-rw-r--r--crates/ra_ide/src/hover.rs2
-rw-r--r--crates/ra_ide/src/impls.rs10
-rw-r--r--crates/ra_ide/src/inlay_hints.rs2
-rw-r--r--crates/ra_ide/src/parent_module.rs4
-rw-r--r--crates/ra_ide/src/references.rs8
-rw-r--r--crates/ra_ide/src/references/classify.rs6
-rw-r--r--crates/ra_ide/src/references/rename.rs54
-rw-r--r--crates/ra_ide/src/runnables.rs6
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs6
-rw-r--r--crates/ra_lsp_server/Cargo.toml2
-rw-r--r--crates/ra_lsp_server/src/main.rs7
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs2
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/main.rs1
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/support.rs3
-rw-r--r--crates/ra_tt/src/lib.rs16
-rw-r--r--docs/dev/README.md5
-rw-r--r--docs/user/README.md15
-rw-r--r--xtask/src/main.rs3
68 files changed, 836 insertions, 512 deletions
diff --git a/Cargo.lock b/Cargo.lock
index b0a0e841c..57cfde978 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -10,7 +10,7 @@ dependencies = [
10 10
11[[package]] 11[[package]]
12name = "anyhow" 12name = "anyhow"
13version = "1.0.23" 13version = "1.0.25"
14source = "registry+https://github.com/rust-lang/crates.io-index" 14source = "registry+https://github.com/rust-lang/crates.io-index"
15 15
16[[package]] 16[[package]]
@@ -23,7 +23,7 @@ name = "atty"
23version = "0.2.13" 23version = "0.2.13"
24source = "registry+https://github.com/rust-lang/crates.io-index" 24source = "registry+https://github.com/rust-lang/crates.io-index"
25dependencies = [ 25dependencies = [
26 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 26 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
27 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 27 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
28] 28]
29 29
@@ -39,7 +39,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
39dependencies = [ 39dependencies = [
40 "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", 40 "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
41 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 41 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
42 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 42 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
43 "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", 43 "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
44] 44]
45 45
@@ -49,7 +49,7 @@ version = "0.1.32"
49source = "registry+https://github.com/rust-lang/crates.io-index" 49source = "registry+https://github.com/rust-lang/crates.io-index"
50dependencies = [ 50dependencies = [
51 "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", 51 "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
52 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 52 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
53] 53]
54 54
55[[package]] 55[[package]]
@@ -101,7 +101,7 @@ dependencies = [
101 101
102[[package]] 102[[package]]
103name = "cargo_metadata" 103name = "cargo_metadata"
104version = "0.9.0" 104version = "0.9.1"
105source = "registry+https://github.com/rust-lang/crates.io-index" 105source = "registry+https://github.com/rust-lang/crates.io-index"
106dependencies = [ 106dependencies = [
107 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 107 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -127,7 +127,7 @@ source = "git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487
127dependencies = [ 127dependencies = [
128 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 128 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
129 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 129 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
130 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 130 "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
131] 131]
132 132
133[[package]] 133[[package]]
@@ -187,23 +187,13 @@ dependencies = [
187] 187]
188 188
189[[package]] 189[[package]]
190name = "chrono"
191version = "0.4.10"
192source = "registry+https://github.com/rust-lang/crates.io-index"
193dependencies = [
194 "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
195 "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
196 "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
197]
198
199[[package]]
200name = "clicolors-control" 190name = "clicolors-control"
201version = "1.0.1" 191version = "1.0.1"
202source = "registry+https://github.com/rust-lang/crates.io-index" 192source = "registry+https://github.com/rust-lang/crates.io-index"
203dependencies = [ 193dependencies = [
204 "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", 194 "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
205 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 195 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
206 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 196 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
207 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 197 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
208] 198]
209 199
@@ -223,7 +213,7 @@ dependencies = [
223 "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 213 "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
224 "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", 214 "encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
225 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 215 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
226 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 216 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
227 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 217 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
228 "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 218 "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
229 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 219 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -324,12 +314,21 @@ version = "0.3.6"
324source = "registry+https://github.com/rust-lang/crates.io-index" 314source = "registry+https://github.com/rust-lang/crates.io-index"
325 315
326[[package]] 316[[package]]
317name = "env_logger"
318version = "0.7.1"
319source = "registry+https://github.com/rust-lang/crates.io-index"
320dependencies = [
321 "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
322 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
323]
324
325[[package]]
327name = "filetime" 326name = "filetime"
328version = "0.2.8" 327version = "0.2.8"
329source = "registry+https://github.com/rust-lang/crates.io-index" 328source = "registry+https://github.com/rust-lang/crates.io-index"
330dependencies = [ 329dependencies = [
331 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 330 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
332 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 331 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
333 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 332 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
334 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 333 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
335] 334]
@@ -340,18 +339,6 @@ version = "0.1.9"
340source = "registry+https://github.com/rust-lang/crates.io-index" 339source = "registry+https://github.com/rust-lang/crates.io-index"
341 340
342[[package]] 341[[package]]
343name = "flexi_logger"
344version = "0.14.5"
345source = "registry+https://github.com/rust-lang/crates.io-index"
346dependencies = [
347 "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
348 "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
349 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
350 "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
351 "yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
352]
353
354[[package]]
355name = "fnv" 342name = "fnv"
356version = "1.0.6" 343version = "1.0.6"
357source = "registry+https://github.com/rust-lang/crates.io-index" 344source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -380,7 +367,7 @@ name = "fsevent-sys"
380version = "2.0.1" 367version = "2.0.1"
381source = "registry+https://github.com/rust-lang/crates.io-index" 368source = "registry+https://github.com/rust-lang/crates.io-index"
382dependencies = [ 369dependencies = [
383 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 370 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
384] 371]
385 372
386[[package]] 373[[package]]
@@ -416,16 +403,11 @@ version = "0.1.13"
416source = "registry+https://github.com/rust-lang/crates.io-index" 403source = "registry+https://github.com/rust-lang/crates.io-index"
417dependencies = [ 404dependencies = [
418 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 405 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
419 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 406 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
420 "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", 407 "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
421] 408]
422 409
423[[package]] 410[[package]]
424name = "glob"
425version = "0.3.0"
426source = "registry+https://github.com/rust-lang/crates.io-index"
427
428[[package]]
429name = "globset" 411name = "globset"
430version = "0.4.4" 412version = "0.4.4"
431source = "registry+https://github.com/rust-lang/crates.io-index" 413source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -450,7 +432,15 @@ name = "hermit-abi"
450version = "0.1.3" 432version = "0.1.3"
451source = "registry+https://github.com/rust-lang/crates.io-index" 433source = "registry+https://github.com/rust-lang/crates.io-index"
452dependencies = [ 434dependencies = [
453 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 435 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
436]
437
438[[package]]
439name = "humantime"
440version = "1.3.0"
441source = "registry+https://github.com/rust-lang/crates.io-index"
442dependencies = [
443 "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
454] 444]
455 445
456[[package]] 446[[package]]
@@ -478,7 +468,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
478dependencies = [ 468dependencies = [
479 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 469 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
480 "inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 470 "inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
481 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 471 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
482] 472]
483 473
484[[package]] 474[[package]]
@@ -486,7 +476,7 @@ name = "inotify-sys"
486version = "0.1.3" 476version = "0.1.3"
487source = "registry+https://github.com/rust-lang/crates.io-index" 477source = "registry+https://github.com/rust-lang/crates.io-index"
488dependencies = [ 478dependencies = [
489 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 479 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
490] 480]
491 481
492[[package]] 482[[package]]
@@ -508,7 +498,7 @@ name = "iovec"
508version = "0.1.4" 498version = "0.1.4"
509source = "registry+https://github.com/rust-lang/crates.io-index" 499source = "registry+https://github.com/rust-lang/crates.io-index"
510dependencies = [ 500dependencies = [
511 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 501 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
512] 502]
513 503
514[[package]] 504[[package]]
@@ -530,7 +520,7 @@ version = "0.3.3"
530source = "registry+https://github.com/rust-lang/crates.io-index" 520source = "registry+https://github.com/rust-lang/crates.io-index"
531dependencies = [ 521dependencies = [
532 "jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 522 "jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
533 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 523 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
534 "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 524 "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
535] 525]
536 526
@@ -541,7 +531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
541dependencies = [ 531dependencies = [
542 "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", 532 "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
543 "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 533 "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
544 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 534 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
545] 535]
546 536
547[[package]] 537[[package]]
@@ -550,7 +540,7 @@ version = "0.3.2"
550source = "registry+https://github.com/rust-lang/crates.io-index" 540source = "registry+https://github.com/rust-lang/crates.io-index"
551dependencies = [ 541dependencies = [
552 "jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 542 "jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
553 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 543 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
554] 544]
555 545
556[[package]] 546[[package]]
@@ -589,7 +579,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
589 579
590[[package]] 580[[package]]
591name = "libc" 581name = "libc"
592version = "0.2.65" 582version = "0.2.66"
593source = "registry+https://github.com/rust-lang/crates.io-index" 583source = "registry+https://github.com/rust-lang/crates.io-index"
594 584
595[[package]] 585[[package]]
@@ -656,14 +646,15 @@ dependencies = [
656 646
657[[package]] 647[[package]]
658name = "mio" 648name = "mio"
659version = "0.6.19" 649version = "0.6.21"
660source = "registry+https://github.com/rust-lang/crates.io-index" 650source = "registry+https://github.com/rust-lang/crates.io-index"
661dependencies = [ 651dependencies = [
652 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
662 "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 653 "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
663 "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 654 "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
664 "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 655 "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
665 "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 656 "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
666 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 657 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
667 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 658 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
668 "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 659 "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
669 "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", 660 "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -678,7 +669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
678dependencies = [ 669dependencies = [
679 "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 670 "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
680 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 671 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
681 "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", 672 "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)",
682 "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 673 "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
683] 674]
684 675
@@ -699,7 +690,7 @@ version = "0.2.33"
699source = "registry+https://github.com/rust-lang/crates.io-index" 690source = "registry+https://github.com/rust-lang/crates.io-index"
700dependencies = [ 691dependencies = [
701 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 692 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
702 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 693 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
703 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 694 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
704] 695]
705 696
@@ -714,23 +705,14 @@ dependencies = [
714 "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 705 "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
715 "inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", 706 "inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
716 "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 707 "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
717 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 708 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
718 "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", 709 "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)",
719 "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 710 "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
720 "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", 711 "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
721 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 712 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
722] 713]
723 714
724[[package]] 715[[package]]
725name = "num-integer"
726version = "0.1.41"
727source = "registry+https://github.com/rust-lang/crates.io-index"
728dependencies = [
729 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
730 "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
731]
732
733[[package]]
734name = "num-traits" 716name = "num-traits"
735version = "0.2.10" 717version = "0.2.10"
736source = "registry+https://github.com/rust-lang/crates.io-index" 718source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -744,7 +726,7 @@ version = "1.11.1"
744source = "registry+https://github.com/rust-lang/crates.io-index" 726source = "registry+https://github.com/rust-lang/crates.io-index"
745dependencies = [ 727dependencies = [
746 "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 728 "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
747 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 729 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
748] 730]
749 731
750[[package]] 732[[package]]
@@ -773,7 +755,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
773dependencies = [ 755dependencies = [
774 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 756 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
775 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 757 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
776 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 758 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
777 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 759 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
778 "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 760 "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
779 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 761 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -796,7 +778,7 @@ dependencies = [
796 "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", 778 "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)",
797 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 779 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
798 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 780 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
799 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 781 "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
800] 782]
801 783
802[[package]] 784[[package]]
@@ -830,7 +812,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
830dependencies = [ 812dependencies = [
831 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 813 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
832 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 814 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
833 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 815 "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
834] 816]
835 817
836[[package]] 818[[package]]
@@ -927,7 +909,7 @@ dependencies = [
927name = "ra_cli" 909name = "ra_cli"
928version = "0.1.0" 910version = "0.1.0"
929dependencies = [ 911dependencies = [
930 "flexi_logger 0.14.5 (registry+https://github.com/rust-lang/crates.io-index)", 912 "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
931 "pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 913 "pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
932 "ra_batch 0.1.0", 914 "ra_batch 0.1.0",
933 "ra_db 0.1.0", 915 "ra_db 0.1.0",
@@ -1059,7 +1041,7 @@ name = "ra_lsp_server"
1059version = "0.1.0" 1041version = "0.1.0"
1060dependencies = [ 1042dependencies = [
1061 "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 1043 "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1062 "flexi_logger 0.14.5 (registry+https://github.com/rust-lang/crates.io-index)", 1044 "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
1063 "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1045 "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1064 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 1046 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
1065 "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 1047 "lsp-server 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1116,7 +1098,7 @@ dependencies = [
1116name = "ra_project_model" 1098name = "ra_project_model"
1117version = "0.1.0" 1099version = "0.1.0"
1118dependencies = [ 1100dependencies = [
1119 "cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 1101 "cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
1120 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 1102 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
1121 "ra_arena 0.1.0", 1103 "ra_arena 0.1.0",
1122 "ra_cfg 0.1.0", 1104 "ra_cfg 0.1.0",
@@ -1188,7 +1170,7 @@ version = "0.6.5"
1188source = "registry+https://github.com/rust-lang/crates.io-index" 1170source = "registry+https://github.com/rust-lang/crates.io-index"
1189dependencies = [ 1171dependencies = [
1190 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", 1172 "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
1191 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1173 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1192 "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 1174 "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1193 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 1175 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
1194 "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1176 "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1206,7 +1188,7 @@ version = "0.7.2"
1206source = "registry+https://github.com/rust-lang/crates.io-index" 1188source = "registry+https://github.com/rust-lang/crates.io-index"
1207dependencies = [ 1189dependencies = [
1208 "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", 1190 "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
1209 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1191 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1210 "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 1192 "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
1211 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 1193 "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
1212 "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 1194 "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1281,7 +1263,7 @@ name = "rand_jitter"
1281version = "0.1.4" 1263version = "0.1.4"
1282source = "registry+https://github.com/rust-lang/crates.io-index" 1264source = "registry+https://github.com/rust-lang/crates.io-index"
1283dependencies = [ 1265dependencies = [
1284 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1266 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1285 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 1267 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
1286 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 1268 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
1287] 1269]
@@ -1293,7 +1275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1293dependencies = [ 1275dependencies = [
1294 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", 1276 "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
1295 "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 1277 "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
1296 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1278 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1297 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", 1279 "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
1298 "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 1280 "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1299 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 1281 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1466,7 +1448,7 @@ dependencies = [
1466 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1448 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1467 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 1449 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
1468 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1450 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1469 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 1451 "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
1470] 1452]
1471 1453
1472[[package]] 1454[[package]]
@@ -1511,7 +1493,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1511dependencies = [ 1493dependencies = [
1512 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 1494 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
1513 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1495 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1514 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 1496 "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
1515] 1497]
1516 1498
1517[[package]] 1499[[package]]
@@ -1531,7 +1513,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1531dependencies = [ 1513dependencies = [
1532 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 1514 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
1533 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1515 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1534 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", 1516 "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)",
1535] 1517]
1536 1518
1537[[package]] 1519[[package]]
@@ -1570,7 +1552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1570dependencies = [ 1552dependencies = [
1571 "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", 1553 "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)",
1572 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 1554 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
1573 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1555 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1574 "psm 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 1556 "psm 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
1575 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 1557 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
1576] 1558]
@@ -1582,7 +1564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1582 1564
1583[[package]] 1565[[package]]
1584name = "syn" 1566name = "syn"
1585version = "1.0.8" 1567version = "1.0.11"
1586source = "registry+https://github.com/rust-lang/crates.io-index" 1568source = "registry+https://github.com/rust-lang/crates.io-index"
1587dependencies = [ 1569dependencies = [
1588 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 1570 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1596,7 +1578,7 @@ version = "3.1.0"
1596source = "registry+https://github.com/rust-lang/crates.io-index" 1578source = "registry+https://github.com/rust-lang/crates.io-index"
1597dependencies = [ 1579dependencies = [
1598 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", 1580 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
1599 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1581 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1600 "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 1582 "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
1601 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", 1583 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
1602 "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 1584 "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1608,7 +1590,7 @@ name = "termios"
1608version = "0.3.1" 1590version = "0.3.1"
1609source = "registry+https://github.com/rust-lang/crates.io-index" 1591source = "registry+https://github.com/rust-lang/crates.io-index"
1610dependencies = [ 1592dependencies = [
1611 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", 1593 "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
1612] 1594]
1613 1595
1614[[package]] 1596[[package]]
@@ -1647,16 +1629,6 @@ dependencies = [
1647] 1629]
1648 1630
1649[[package]] 1631[[package]]
1650name = "time"
1651version = "0.1.42"
1652source = "registry+https://github.com/rust-lang/crates.io-index"
1653dependencies = [
1654 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
1655 "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
1656 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
1657]
1658
1659[[package]]
1660name = "unicase" 1632name = "unicase"
1661version = "2.6.0" 1633version = "2.6.0"
1662source = "registry+https://github.com/rust-lang/crates.io-index" 1634source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1780,7 +1752,7 @@ dependencies = [
1780name = "xtask" 1752name = "xtask"
1781version = "0.1.0" 1753version = "0.1.0"
1782dependencies = [ 1754dependencies = [
1783 "anyhow 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", 1755 "anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
1784 "pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 1756 "pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
1785 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 1757 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
1786 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1758 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1797,14 +1769,9 @@ dependencies = [
1797 "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", 1769 "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
1798] 1770]
1799 1771
1800[[package]]
1801name = "yansi"
1802version = "0.5.0"
1803source = "registry+https://github.com/rust-lang/crates.io-index"
1804
1805[metadata] 1772[metadata]
1806"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" 1773"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
1807"checksum anyhow 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1072d8f55592084072d2d3cb23a4b680a8543c00f10d446118e85ad3718142" 1774"checksum anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14"
1808"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" 1775"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
1809"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" 1776"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"
1810"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" 1777"checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
@@ -1817,7 +1784,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1817"checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" 1784"checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245"
1818"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" 1785"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
1819"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" 1786"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
1820"checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d" 1787"checksum cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202"
1821"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" 1788"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8"
1822"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 1789"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
1823"checksum chalk-derive 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" 1790"checksum chalk-derive 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>"
@@ -1826,7 +1793,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1826"checksum chalk-macros 0.1.1 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" 1793"checksum chalk-macros 0.1.1 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>"
1827"checksum chalk-rust-ir 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" 1794"checksum chalk-rust-ir 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>"
1828"checksum chalk-solve 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>" 1795"checksum chalk-solve 0.1.0 (git+https://github.com/jackh726/chalk.git?rev=095cd38a4f16337913bba487f2055b9ca0179f30)" = "<none>"
1829"checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01"
1830"checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" 1796"checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e"
1831"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 1797"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
1832"checksum console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f" 1798"checksum console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f"
@@ -1842,9 +1808,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1842"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" 1808"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
1843"checksum ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" 1809"checksum ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36"
1844"checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 1810"checksum encode_unicode 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
1811"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
1845"checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" 1812"checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d"
1846"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" 1813"checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33"
1847"checksum flexi_logger 0.14.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a13ea6b8a4debecf47bf3966d56db0e21366bc3a3649ba159e1a9e6fdd36a4f4"
1848"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" 1814"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
1849"checksum format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7aea5a5909a74969507051a3b17adc84737e31a5f910559892aedce026f4d53" 1815"checksum format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f7aea5a5909a74969507051a3b17adc84737e31a5f910559892aedce026f4d53"
1850"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" 1816"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
@@ -1855,10 +1821,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1855"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 1821"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
1856"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 1822"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
1857"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" 1823"checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407"
1858"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
1859"checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" 1824"checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2"
1860"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" 1825"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
1861"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" 1826"checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120"
1827"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
1862"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" 1828"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
1863"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2" 1829"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2"
1864"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" 1830"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718"
@@ -1876,7 +1842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1876"checksum lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4fd87be4a815fd373e02773983940f0d75fb26fde8c098e9e45f7af03154c0" 1842"checksum lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc4fd87be4a815fd373e02773983940f0d75fb26fde8c098e9e45f7af03154c0"
1877"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 1843"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
1878"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" 1844"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
1879"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" 1845"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
1880"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" 1846"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
1881"checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" 1847"checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586"
1882"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 1848"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
@@ -1885,12 +1851,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1885"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 1851"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
1886"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" 1852"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e"
1887"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" 1853"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
1888"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" 1854"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
1889"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" 1855"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40"
1890"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" 1856"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
1891"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" 1857"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
1892"checksum notify 4.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "199628fc33b21bc767baa057490b00b382ecbae030803a7b36292422d15b778b" 1858"checksum notify 4.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "199628fc33b21bc767baa057490b00b382ecbae030803a7b36292422d15b778b"
1893"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
1894"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" 1859"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4"
1895"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" 1860"checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72"
1896"checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" 1861"checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed"
@@ -1956,14 +1921,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1956"checksum smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34836c9a295c62c2ce3514471117c5cb269891e8421b2aafdd910050576c4d8b" 1921"checksum smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34836c9a295c62c2ce3514471117c5cb269891e8421b2aafdd910050576c4d8b"
1957"checksum stacker 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d96fc4f13a0ac088e9a3cd9af1cc8c5cc1ab5deb2145cef661267dfc9c542f8a" 1922"checksum stacker 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d96fc4f13a0ac088e9a3cd9af1cc8c5cc1ab5deb2145cef661267dfc9c542f8a"
1958"checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" 1923"checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
1959"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" 1924"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238"
1960"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" 1925"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
1961"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" 1926"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625"
1962"checksum text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e08bbcb7a3adbda0eb23431206b653bdad3d8dea311e72d36bf2215e27a42579" 1927"checksum text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e08bbcb7a3adbda0eb23431206b653bdad3d8dea311e72d36bf2215e27a42579"
1963"checksum thin-dst 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c52fd98a9e4913c466d83381a59245691875d2f3e04611fca57f964bd8aa96e1" 1928"checksum thin-dst 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c52fd98a9e4913c466d83381a59245691875d2f3e04611fca57f964bd8aa96e1"
1964"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" 1929"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
1965"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" 1930"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"
1966"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
1967"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" 1931"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
1968"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" 1932"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
1969"checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" 1933"checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf"
@@ -1982,4 +1946,3 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1982"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1946"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
1983"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" 1947"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
1984"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" 1948"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d"
1985"checksum yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71"
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index 0ea84d548..993aebc47 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -1,5 +1,5 @@
1//! This module defines `AssistCtx` -- the API surface that is exposed to assists. 1//! This module defines `AssistCtx` -- the API surface that is exposed to assists.
2use hir::{db::HirDatabase, SourceAnalyzer}; 2use hir::{db::HirDatabase, InFile, SourceAnalyzer};
3use ra_db::FileRange; 3use ra_db::FileRange;
4use ra_fmt::{leading_indent, reindent}; 4use ra_fmt::{leading_indent, reindent};
5use ra_syntax::{ 5use ra_syntax::{
@@ -117,7 +117,7 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
117 node: &SyntaxNode, 117 node: &SyntaxNode,
118 offset: Option<TextUnit>, 118 offset: Option<TextUnit>,
119 ) -> SourceAnalyzer { 119 ) -> SourceAnalyzer {
120 SourceAnalyzer::new(self.db, hir::Source::new(self.frange.file_id.into(), node), offset) 120 SourceAnalyzer::new(self.db, InFile::new(self.frange.file_id.into(), node), offset)
121 } 121 }
122 122
123 pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement { 123 pub(crate) fn covering_node_for_range(&self, range: TextRange) -> SyntaxElement {
diff --git a/crates/ra_assists/src/assists/add_new.rs b/crates/ra_assists/src/assists/add_new.rs
index 8f68bd5fb..f977547fb 100644
--- a/crates/ra_assists/src/assists/add_new.rs
+++ b/crates/ra_assists/src/assists/add_new.rs
@@ -1,5 +1,5 @@
1use format_buf::format; 1use format_buf::format;
2use hir::{db::HirDatabase, FromSource}; 2use hir::{db::HirDatabase, FromSource, InFile};
3use join_to_string::join; 3use join_to_string::join;
4use ra_syntax::{ 4use ra_syntax::{
5 ast::{ 5 ast::{
@@ -141,7 +141,7 @@ fn find_struct_impl(
141 })?; 141 })?;
142 142
143 let struct_ty = { 143 let struct_ty = {
144 let src = hir::Source { file_id: ctx.frange.file_id.into(), value: strukt.clone() }; 144 let src = InFile { file_id: ctx.frange.file_id.into(), value: strukt.clone() };
145 hir::Struct::from_source(db, src).unwrap().ty(db) 145 hir::Struct::from_source(db, src).unwrap().ty(db)
146 }; 146 };
147 147
@@ -152,7 +152,7 @@ fn find_struct_impl(
152 return false; 152 return false;
153 } 153 }
154 154
155 let src = hir::Source { file_id: ctx.frange.file_id.into(), value: impl_blk.clone() }; 155 let src = InFile { file_id: ctx.frange.file_id.into(), value: impl_blk.clone() };
156 let blk = hir::ImplBlock::from_source(db, src).unwrap(); 156 let blk = hir::ImplBlock::from_source(db, src).unwrap();
157 157
158 let same_ty = blk.target_ty(db) == struct_ty; 158 let same_ty = blk.target_ty(db) == struct_ty;
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
index c7e0d0f0f..21a37c7bf 100644
--- a/crates/ra_cli/Cargo.toml
+++ b/crates/ra_cli/Cargo.toml
@@ -7,7 +7,7 @@ publish = false
7 7
8[dependencies] 8[dependencies]
9pico-args = "0.3.0" 9pico-args = "0.3.0"
10flexi_logger = "0.14.0" 10env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] }
11 11
12ra_syntax = { path = "../ra_syntax" } 12ra_syntax = { path = "../ra_syntax" }
13ra_ide = { path = "../ra_ide" } 13ra_ide = { path = "../ra_ide" }
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs
index fe847e611..3808590ab 100644
--- a/crates/ra_cli/src/main.rs
+++ b/crates/ra_cli/src/main.rs
@@ -7,7 +7,6 @@ mod progress_report;
7 7
8use std::{error::Error, fmt::Write, io::Read}; 8use std::{error::Error, fmt::Write, io::Read};
9 9
10use flexi_logger::Logger;
11use pico_args::Arguments; 10use pico_args::Arguments;
12use ra_ide::{file_structure, Analysis}; 11use ra_ide::{file_structure, Analysis};
13use ra_prof::profile; 12use ra_prof::profile;
@@ -32,7 +31,7 @@ impl Verbosity {
32} 31}
33 32
34fn main() -> Result<()> { 33fn main() -> Result<()> {
35 Logger::with_env_or_str("error").start()?; 34 env_logger::try_init()?;
36 35
37 let subcommand = match std::env::args_os().nth(1) { 36 let subcommand = match std::env::args_os().nth(1) {
38 None => { 37 None => {
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 38d66c2a7..dddac915b 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -30,7 +30,7 @@ use crate::{
30 db::{DefDatabase, HirDatabase}, 30 db::{DefDatabase, HirDatabase},
31 ty::display::HirFormatter, 31 ty::display::HirFormatter,
32 ty::{self, InEnvironment, InferenceResult, TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk}, 32 ty::{self, InEnvironment, InferenceResult, TraitEnvironment, Ty, TyDefId, TypeCtor, TypeWalk},
33 CallableDef, Either, HirDisplay, Name, Source, 33 CallableDef, Either, HirDisplay, InFile, Name,
34}; 34};
35 35
36/// hir::Crate describes a single crate. It's the main interface with which 36/// hir::Crate describes a single crate. It's the main interface with which
@@ -118,7 +118,7 @@ impl ModuleSource {
118 } 118 }
119 } 119 }
120 120
121 pub fn from_child_node(db: &impl DefDatabase, child: Source<&SyntaxNode>) -> ModuleSource { 121 pub fn from_child_node(db: &impl DefDatabase, child: InFile<&SyntaxNode>) -> ModuleSource {
122 if let Some(m) = 122 if let Some(m) =
123 child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) 123 child.value.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi())
124 { 124 {
@@ -901,7 +901,7 @@ impl Local {
901 Type { krate, ty: InEnvironment { value: ty, environment } } 901 Type { krate, ty: InEnvironment { value: ty, environment } }
902 } 902 }
903 903
904 pub fn source(self, db: &impl HirDatabase) -> Source<Either<ast::BindPat, ast::SelfParam>> { 904 pub fn source(self, db: &impl HirDatabase) -> InFile<Either<ast::BindPat, ast::SelfParam>> {
905 let (_body, source_map) = db.body_with_source_map(self.parent.into()); 905 let (_body, source_map) = db.body_with_source_map(self.parent.into());
906 let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm... 906 let src = source_map.pat_syntax(self.pat_id).unwrap(); // Hmm...
907 let root = src.file_syntax(db); 907 let root = src.file_syntax(db);
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs
index bf3ee0834..2cf210349 100644
--- a/crates/ra_hir/src/code_model/src.rs
+++ b/crates/ra_hir/src/code_model/src.rs
@@ -1,6 +1,9 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_def::{AstItemDef, HasChildSource, HasSource as _, Lookup, VariantId}; 3use hir_def::{
4 src::{HasChildSource, HasSource as _},
5 AstItemDef, Lookup, VariantId,
6};
4use hir_expand::either::Either; 7use hir_expand::either::Either;
5use ra_syntax::ast; 8use ra_syntax::ast;
6 9
@@ -9,18 +12,18 @@ use crate::{
9 Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union, 12 Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
10}; 13};
11 14
12pub use hir_expand::Source; 15pub use hir_expand::InFile;
13 16
14pub trait HasSource { 17pub trait HasSource {
15 type Ast; 18 type Ast;
16 fn source(self, db: &impl DefDatabase) -> Source<Self::Ast>; 19 fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast>;
17} 20}
18 21
19/// NB: Module is !HasSource, because it has two source nodes at the same time: 22/// NB: Module is !HasSource, because it has two source nodes at the same time:
20/// definition and declaration. 23/// definition and declaration.
21impl Module { 24impl Module {
22 /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items. 25 /// Returns a node which defines this module. That is, a file or a `mod foo {}` with items.
23 pub fn definition_source(self, db: &impl DefDatabase) -> Source<ModuleSource> { 26 pub fn definition_source(self, db: &impl DefDatabase) -> InFile<ModuleSource> {
24 let def_map = db.crate_def_map(self.id.krate); 27 let def_map = db.crate_def_map(self.id.krate);
25 let src = def_map[self.id.local_id].definition_source(db); 28 let src = def_map[self.id.local_id].definition_source(db);
26 src.map(|it| match it { 29 src.map(|it| match it {
@@ -31,7 +34,7 @@ impl Module {
31 34
32 /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. 35 /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
33 /// `None` for the crate root. 36 /// `None` for the crate root.
34 pub fn declaration_source(self, db: &impl DefDatabase) -> Option<Source<ast::Module>> { 37 pub fn declaration_source(self, db: &impl DefDatabase) -> Option<InFile<ast::Module>> {
35 let def_map = db.crate_def_map(self.id.krate); 38 let def_map = db.crate_def_map(self.id.krate);
36 def_map[self.id.local_id].declaration_source(db) 39 def_map[self.id.local_id].declaration_source(db)
37 } 40 }
@@ -39,7 +42,7 @@ impl Module {
39 42
40impl HasSource for StructField { 43impl HasSource for StructField {
41 type Ast = FieldSource; 44 type Ast = FieldSource;
42 fn source(self, db: &impl DefDatabase) -> Source<FieldSource> { 45 fn source(self, db: &impl DefDatabase) -> InFile<FieldSource> {
43 let var = VariantId::from(self.parent); 46 let var = VariantId::from(self.parent);
44 let src = var.child_source(db); 47 let src = var.child_source(db);
45 src.map(|it| match it[self.id].clone() { 48 src.map(|it| match it[self.id].clone() {
@@ -50,67 +53,67 @@ impl HasSource for StructField {
50} 53}
51impl HasSource for Struct { 54impl HasSource for Struct {
52 type Ast = ast::StructDef; 55 type Ast = ast::StructDef;
53 fn source(self, db: &impl DefDatabase) -> Source<ast::StructDef> { 56 fn source(self, db: &impl DefDatabase) -> InFile<ast::StructDef> {
54 self.id.source(db) 57 self.id.source(db)
55 } 58 }
56} 59}
57impl HasSource for Union { 60impl HasSource for Union {
58 type Ast = ast::UnionDef; 61 type Ast = ast::UnionDef;
59 fn source(self, db: &impl DefDatabase) -> Source<ast::UnionDef> { 62 fn source(self, db: &impl DefDatabase) -> InFile<ast::UnionDef> {
60 self.id.source(db) 63 self.id.source(db)
61 } 64 }
62} 65}
63impl HasSource for Enum { 66impl HasSource for Enum {
64 type Ast = ast::EnumDef; 67 type Ast = ast::EnumDef;
65 fn source(self, db: &impl DefDatabase) -> Source<ast::EnumDef> { 68 fn source(self, db: &impl DefDatabase) -> InFile<ast::EnumDef> {
66 self.id.source(db) 69 self.id.source(db)
67 } 70 }
68} 71}
69impl HasSource for EnumVariant { 72impl HasSource for EnumVariant {
70 type Ast = ast::EnumVariant; 73 type Ast = ast::EnumVariant;
71 fn source(self, db: &impl DefDatabase) -> Source<ast::EnumVariant> { 74 fn source(self, db: &impl DefDatabase) -> InFile<ast::EnumVariant> {
72 self.parent.id.child_source(db).map(|map| map[self.id].clone()) 75 self.parent.id.child_source(db).map(|map| map[self.id].clone())
73 } 76 }
74} 77}
75impl HasSource for Function { 78impl HasSource for Function {
76 type Ast = ast::FnDef; 79 type Ast = ast::FnDef;
77 fn source(self, db: &impl DefDatabase) -> Source<ast::FnDef> { 80 fn source(self, db: &impl DefDatabase) -> InFile<ast::FnDef> {
78 self.id.lookup(db).source(db) 81 self.id.lookup(db).source(db)
79 } 82 }
80} 83}
81impl HasSource for Const { 84impl HasSource for Const {
82 type Ast = ast::ConstDef; 85 type Ast = ast::ConstDef;
83 fn source(self, db: &impl DefDatabase) -> Source<ast::ConstDef> { 86 fn source(self, db: &impl DefDatabase) -> InFile<ast::ConstDef> {
84 self.id.lookup(db).source(db) 87 self.id.lookup(db).source(db)
85 } 88 }
86} 89}
87impl HasSource for Static { 90impl HasSource for Static {
88 type Ast = ast::StaticDef; 91 type Ast = ast::StaticDef;
89 fn source(self, db: &impl DefDatabase) -> Source<ast::StaticDef> { 92 fn source(self, db: &impl DefDatabase) -> InFile<ast::StaticDef> {
90 self.id.lookup(db).source(db) 93 self.id.lookup(db).source(db)
91 } 94 }
92} 95}
93impl HasSource for Trait { 96impl HasSource for Trait {
94 type Ast = ast::TraitDef; 97 type Ast = ast::TraitDef;
95 fn source(self, db: &impl DefDatabase) -> Source<ast::TraitDef> { 98 fn source(self, db: &impl DefDatabase) -> InFile<ast::TraitDef> {
96 self.id.source(db) 99 self.id.source(db)
97 } 100 }
98} 101}
99impl HasSource for TypeAlias { 102impl HasSource for TypeAlias {
100 type Ast = ast::TypeAliasDef; 103 type Ast = ast::TypeAliasDef;
101 fn source(self, db: &impl DefDatabase) -> Source<ast::TypeAliasDef> { 104 fn source(self, db: &impl DefDatabase) -> InFile<ast::TypeAliasDef> {
102 self.id.lookup(db).source(db) 105 self.id.lookup(db).source(db)
103 } 106 }
104} 107}
105impl HasSource for MacroDef { 108impl HasSource for MacroDef {
106 type Ast = ast::MacroCall; 109 type Ast = ast::MacroCall;
107 fn source(self, db: &impl DefDatabase) -> Source<ast::MacroCall> { 110 fn source(self, db: &impl DefDatabase) -> InFile<ast::MacroCall> {
108 Source { file_id: self.id.ast_id.file_id(), value: self.id.ast_id.to_node(db) } 111 InFile { file_id: self.id.ast_id.file_id, value: self.id.ast_id.to_node(db) }
109 } 112 }
110} 113}
111impl HasSource for ImplBlock { 114impl HasSource for ImplBlock {
112 type Ast = ast::ImplBlock; 115 type Ast = ast::ImplBlock;
113 fn source(self, db: &impl DefDatabase) -> Source<ast::ImplBlock> { 116 fn source(self, db: &impl DefDatabase) -> InFile<ast::ImplBlock> {
114 self.id.source(db) 117 self.id.source(db)
115 } 118 }
116} 119}
@@ -118,7 +121,7 @@ impl HasSource for Import {
118 type Ast = Either<ast::UseTree, ast::ExternCrateItem>; 121 type Ast = Either<ast::UseTree, ast::ExternCrateItem>;
119 122
120 /// Returns the syntax of the last path segment corresponding to this import 123 /// Returns the syntax of the last path segment corresponding to this import
121 fn source(self, db: &impl DefDatabase) -> Source<Self::Ast> { 124 fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast> {
122 let src = self.parent.definition_source(db); 125 let src = self.parent.definition_source(db);
123 let (_, source_map) = db.raw_items_with_source_map(src.file_id); 126 let (_, source_map) = db.raw_items_with_source_map(src.file_id);
124 let root = db.parse_or_expand(src.file_id).unwrap(); 127 let root = db.parse_or_expand(src.file_id).unwrap();
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index 9f7c22b21..82bf641dc 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -10,46 +10,46 @@ use ra_syntax::{
10use crate::{ 10use crate::{
11 db::{AstDatabase, DefDatabase, HirDatabase}, 11 db::{AstDatabase, DefDatabase, HirDatabase},
12 AssocItem, Const, DefWithBody, Enum, EnumVariant, FieldSource, Function, HasSource, ImplBlock, 12 AssocItem, Const, DefWithBody, Enum, EnumVariant, FieldSource, Function, HasSource, ImplBlock,
13 Local, MacroDef, Module, ModuleDef, ModuleSource, Source, Static, Struct, StructField, Trait, 13 InFile, Local, MacroDef, Module, ModuleDef, ModuleSource, Static, Struct, StructField, Trait,
14 TypeAlias, Union, VariantDef, 14 TypeAlias, Union, VariantDef,
15}; 15};
16 16
17pub trait FromSource: Sized { 17pub trait FromSource: Sized {
18 type Ast; 18 type Ast;
19 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self>; 19 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self>;
20} 20}
21 21
22impl FromSource for Struct { 22impl FromSource for Struct {
23 type Ast = ast::StructDef; 23 type Ast = ast::StructDef;
24 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 24 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
25 let id = from_source(db, src)?; 25 let id = from_source(db, src)?;
26 Some(Struct { id }) 26 Some(Struct { id })
27 } 27 }
28} 28}
29impl FromSource for Union { 29impl FromSource for Union {
30 type Ast = ast::UnionDef; 30 type Ast = ast::UnionDef;
31 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 31 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
32 let id = from_source(db, src)?; 32 let id = from_source(db, src)?;
33 Some(Union { id }) 33 Some(Union { id })
34 } 34 }
35} 35}
36impl FromSource for Enum { 36impl FromSource for Enum {
37 type Ast = ast::EnumDef; 37 type Ast = ast::EnumDef;
38 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 38 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
39 let id = from_source(db, src)?; 39 let id = from_source(db, src)?;
40 Some(Enum { id }) 40 Some(Enum { id })
41 } 41 }
42} 42}
43impl FromSource for Trait { 43impl FromSource for Trait {
44 type Ast = ast::TraitDef; 44 type Ast = ast::TraitDef;
45 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 45 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
46 let id = from_source(db, src)?; 46 let id = from_source(db, src)?;
47 Some(Trait { id }) 47 Some(Trait { id })
48 } 48 }
49} 49}
50impl FromSource for Function { 50impl FromSource for Function {
51 type Ast = ast::FnDef; 51 type Ast = ast::FnDef;
52 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 52 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
53 let items = match Container::find(db, src.as_ref().map(|it| it.syntax()))? { 53 let items = match Container::find(db, src.as_ref().map(|it| it.syntax()))? {
54 Container::Trait(it) => it.items(db), 54 Container::Trait(it) => it.items(db),
55 Container::ImplBlock(it) => it.items(db), 55 Container::ImplBlock(it) => it.items(db),
@@ -76,7 +76,7 @@ impl FromSource for Function {
76 76
77impl FromSource for Const { 77impl FromSource for Const {
78 type Ast = ast::ConstDef; 78 type Ast = ast::ConstDef;
79 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 79 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
80 let items = match Container::find(db, src.as_ref().map(|it| it.syntax()))? { 80 let items = match Container::find(db, src.as_ref().map(|it| it.syntax()))? {
81 Container::Trait(it) => it.items(db), 81 Container::Trait(it) => it.items(db),
82 Container::ImplBlock(it) => it.items(db), 82 Container::ImplBlock(it) => it.items(db),
@@ -102,7 +102,7 @@ impl FromSource for Const {
102} 102}
103impl FromSource for Static { 103impl FromSource for Static {
104 type Ast = ast::StaticDef; 104 type Ast = ast::StaticDef;
105 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 105 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
106 let module = match Container::find(db, src.as_ref().map(|it| it.syntax()))? { 106 let module = match Container::find(db, src.as_ref().map(|it| it.syntax()))? {
107 Container::Module(it) => it, 107 Container::Module(it) => it,
108 Container::Trait(_) | Container::ImplBlock(_) => return None, 108 Container::Trait(_) | Container::ImplBlock(_) => return None,
@@ -120,7 +120,7 @@ impl FromSource for Static {
120 120
121impl FromSource for TypeAlias { 121impl FromSource for TypeAlias {
122 type Ast = ast::TypeAliasDef; 122 type Ast = ast::TypeAliasDef;
123 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 123 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
124 let items = match Container::find(db, src.as_ref().map(|it| it.syntax()))? { 124 let items = match Container::find(db, src.as_ref().map(|it| it.syntax()))? {
125 Container::Trait(it) => it.items(db), 125 Container::Trait(it) => it.items(db),
126 Container::ImplBlock(it) => it.items(db), 126 Container::ImplBlock(it) => it.items(db),
@@ -147,11 +147,11 @@ impl FromSource for TypeAlias {
147 147
148impl FromSource for MacroDef { 148impl FromSource for MacroDef {
149 type Ast = ast::MacroCall; 149 type Ast = ast::MacroCall;
150 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 150 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
151 let kind = MacroDefKind::Declarative; 151 let kind = MacroDefKind::Declarative;
152 152
153 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax())); 153 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax()));
154 let module = Module::from_definition(db, Source::new(src.file_id, module_src))?; 154 let module = Module::from_definition(db, InFile::new(src.file_id, module_src))?;
155 let krate = module.krate().crate_id(); 155 let krate = module.krate().crate_id();
156 156
157 let ast_id = AstId::new(src.file_id, db.ast_id_map(src.file_id).ast_id(&src.value)); 157 let ast_id = AstId::new(src.file_id, db.ast_id_map(src.file_id).ast_id(&src.value));
@@ -163,7 +163,7 @@ impl FromSource for MacroDef {
163 163
164impl FromSource for ImplBlock { 164impl FromSource for ImplBlock {
165 type Ast = ast::ImplBlock; 165 type Ast = ast::ImplBlock;
166 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 166 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
167 let id = from_source(db, src)?; 167 let id = from_source(db, src)?;
168 Some(ImplBlock { id }) 168 Some(ImplBlock { id })
169 } 169 }
@@ -171,9 +171,9 @@ impl FromSource for ImplBlock {
171 171
172impl FromSource for EnumVariant { 172impl FromSource for EnumVariant {
173 type Ast = ast::EnumVariant; 173 type Ast = ast::EnumVariant;
174 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 174 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
175 let parent_enum = src.value.parent_enum(); 175 let parent_enum = src.value.parent_enum();
176 let src_enum = Source { file_id: src.file_id, value: parent_enum }; 176 let src_enum = InFile { file_id: src.file_id, value: parent_enum };
177 let variants = Enum::from_source(db, src_enum)?.variants(db); 177 let variants = Enum::from_source(db, src_enum)?.variants(db);
178 variants.into_iter().find(|v| same_source(&v.source(db), &src)) 178 variants.into_iter().find(|v| same_source(&v.source(db), &src))
179 } 179 }
@@ -181,17 +181,17 @@ impl FromSource for EnumVariant {
181 181
182impl FromSource for StructField { 182impl FromSource for StructField {
183 type Ast = FieldSource; 183 type Ast = FieldSource;
184 fn from_source(db: &(impl DefDatabase + AstDatabase), src: Source<Self::Ast>) -> Option<Self> { 184 fn from_source(db: &(impl DefDatabase + AstDatabase), src: InFile<Self::Ast>) -> Option<Self> {
185 let variant_def: VariantDef = match src.value { 185 let variant_def: VariantDef = match src.value {
186 FieldSource::Named(ref field) => { 186 FieldSource::Named(ref field) => {
187 let value = field.syntax().ancestors().find_map(ast::StructDef::cast)?; 187 let value = field.syntax().ancestors().find_map(ast::StructDef::cast)?;
188 let src = Source { file_id: src.file_id, value }; 188 let src = InFile { file_id: src.file_id, value };
189 let def = Struct::from_source(db, src)?; 189 let def = Struct::from_source(db, src)?;
190 VariantDef::from(def) 190 VariantDef::from(def)
191 } 191 }
192 FieldSource::Pos(ref field) => { 192 FieldSource::Pos(ref field) => {
193 let value = field.syntax().ancestors().find_map(ast::EnumVariant::cast)?; 193 let value = field.syntax().ancestors().find_map(ast::EnumVariant::cast)?;
194 let src = Source { file_id: src.file_id, value }; 194 let src = InFile { file_id: src.file_id, value };
195 let def = EnumVariant::from_source(db, src)?; 195 let def = EnumVariant::from_source(db, src)?;
196 VariantDef::from(def) 196 VariantDef::from(def)
197 } 197 }
@@ -206,14 +206,14 @@ impl FromSource for StructField {
206} 206}
207 207
208impl Local { 208impl Local {
209 pub fn from_source(db: &impl HirDatabase, src: Source<ast::BindPat>) -> Option<Self> { 209 pub fn from_source(db: &impl HirDatabase, src: InFile<ast::BindPat>) -> Option<Self> {
210 let file_id = src.file_id; 210 let file_id = src.file_id;
211 let parent: DefWithBody = src.value.syntax().ancestors().find_map(|it| { 211 let parent: DefWithBody = src.value.syntax().ancestors().find_map(|it| {
212 let res = match_ast! { 212 let res = match_ast! {
213 match it { 213 match it {
214 ast::ConstDef(value) => { Const::from_source(db, Source { value, file_id})?.into() }, 214 ast::ConstDef(value) => { Const::from_source(db, InFile { value, file_id})?.into() },
215 ast::StaticDef(value) => { Static::from_source(db, Source { value, file_id})?.into() }, 215 ast::StaticDef(value) => { Static::from_source(db, InFile { value, file_id})?.into() },
216 ast::FnDef(value) => { Function::from_source(db, Source { value, file_id})?.into() }, 216 ast::FnDef(value) => { Function::from_source(db, InFile { value, file_id})?.into() },
217 _ => return None, 217 _ => return None,
218 } 218 }
219 }; 219 };
@@ -227,16 +227,16 @@ impl Local {
227} 227}
228 228
229impl Module { 229impl Module {
230 pub fn from_declaration(db: &impl DefDatabase, src: Source<ast::Module>) -> Option<Self> { 230 pub fn from_declaration(db: &impl DefDatabase, src: InFile<ast::Module>) -> Option<Self> {
231 let parent_declaration = src.value.syntax().ancestors().skip(1).find_map(ast::Module::cast); 231 let parent_declaration = src.value.syntax().ancestors().skip(1).find_map(ast::Module::cast);
232 232
233 let parent_module = match parent_declaration { 233 let parent_module = match parent_declaration {
234 Some(parent_declaration) => { 234 Some(parent_declaration) => {
235 let src_parent = Source { file_id: src.file_id, value: parent_declaration }; 235 let src_parent = InFile { file_id: src.file_id, value: parent_declaration };
236 Module::from_declaration(db, src_parent) 236 Module::from_declaration(db, src_parent)
237 } 237 }
238 _ => { 238 _ => {
239 let src_parent = Source { 239 let src_parent = InFile {
240 file_id: src.file_id, 240 file_id: src.file_id,
241 value: ModuleSource::new(db, Some(src.file_id.original_file(db)), None), 241 value: ModuleSource::new(db, Some(src.file_id.original_file(db)), None),
242 }; 242 };
@@ -248,13 +248,13 @@ impl Module {
248 parent_module.child(db, &child_name.as_name()) 248 parent_module.child(db, &child_name.as_name())
249 } 249 }
250 250
251 pub fn from_definition(db: &impl DefDatabase, src: Source<ModuleSource>) -> Option<Self> { 251 pub fn from_definition(db: &impl DefDatabase, src: InFile<ModuleSource>) -> Option<Self> {
252 match src.value { 252 match src.value {
253 ModuleSource::Module(ref module) => { 253 ModuleSource::Module(ref module) => {
254 assert!(!module.has_semi()); 254 assert!(!module.has_semi());
255 return Module::from_declaration( 255 return Module::from_declaration(
256 db, 256 db,
257 Source { file_id: src.file_id, value: module.clone() }, 257 InFile { file_id: src.file_id, value: module.clone() },
258 ); 258 );
259 } 259 }
260 ModuleSource::SourceFile(_) => (), 260 ModuleSource::SourceFile(_) => (),
@@ -271,13 +271,13 @@ impl Module {
271 } 271 }
272} 272}
273 273
274fn from_source<N, DEF>(db: &(impl DefDatabase + AstDatabase), src: Source<N>) -> Option<DEF> 274fn from_source<N, DEF>(db: &(impl DefDatabase + AstDatabase), src: InFile<N>) -> Option<DEF>
275where 275where
276 N: AstNode, 276 N: AstNode,
277 DEF: AstItemDef<N>, 277 DEF: AstItemDef<N>,
278{ 278{
279 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax())); 279 let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax()));
280 let module = Module::from_definition(db, Source::new(src.file_id, module_src))?; 280 let module = Module::from_definition(db, InFile::new(src.file_id, module_src))?;
281 let ctx = LocationCtx::new(db, module.id, src.file_id); 281 let ctx = LocationCtx::new(db, module.id, src.file_id);
282 let items = db.ast_id_map(src.file_id); 282 let items = db.ast_id_map(src.file_id);
283 let item_id = items.ast_id(&src.value); 283 let item_id = items.ast_id(&src.value);
@@ -291,7 +291,7 @@ enum Container {
291} 291}
292 292
293impl Container { 293impl Container {
294 fn find(db: &impl DefDatabase, src: Source<&SyntaxNode>) -> Option<Container> { 294 fn find(db: &impl DefDatabase, src: InFile<&SyntaxNode>) -> Option<Container> {
295 // FIXME: this doesn't try to handle nested declarations 295 // FIXME: this doesn't try to handle nested declarations
296 for container in src.value.ancestors() { 296 for container in src.value.ancestors() {
297 let res = match_ast! { 297 let res = match_ast! {
@@ -322,6 +322,6 @@ impl Container {
322/// In general, we do not guarantee that we have exactly one instance of a 322/// In general, we do not guarantee that we have exactly one instance of a
323/// syntax tree for each file. We probably should add such guarantee, but, for 323/// syntax tree for each file. We probably should add such guarantee, but, for
324/// the time being, we will use identity-less AstPtr comparison. 324/// the time being, we will use identity-less AstPtr comparison.
325fn same_source<N: AstNode>(s1: &Source<N>, s2: &Source<N>) -> bool { 325fn same_source<N: AstNode>(s1: &InFile<N>, s2: &InFile<N>) -> bool {
326 s1.as_ref().map(AstPtr::new) == s2.as_ref().map(AstPtr::new) 326 s1.as_ref().map(AstPtr::new) == s2.as_ref().map(AstPtr::new)
327} 327}
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 3c12c61f0..88d2f6e02 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -63,5 +63,5 @@ pub use hir_def::{
63 type_ref::Mutability, 63 type_ref::Mutability,
64}; 64};
65pub use hir_expand::{ 65pub use hir_expand::{
66 either::Either, name::Name, HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, Source, 66 either::Either, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile,
67}; 67};
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 76c493f1a..0df7a7cb4 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -18,7 +18,7 @@ use hir_def::{
18 AssocItemId, DefWithBodyId, 18 AssocItemId, DefWithBodyId,
19}; 19};
20use hir_expand::{ 20use hir_expand::{
21 hygiene::Hygiene, name::AsName, AstId, HirFileId, MacroCallId, MacroFileKind, Source, 21 hygiene::Hygiene, name::AsName, AstId, HirFileId, InFile, MacroCallId, MacroFileKind,
22}; 22};
23use ra_syntax::{ 23use ra_syntax::{
24 ast::{self, AstNode}, 24 ast::{self, AstNode},
@@ -37,7 +37,7 @@ use crate::{
37 GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias, 37 GenericParam, Local, MacroDef, Name, Path, ScopeDef, Static, Struct, Trait, Type, TypeAlias,
38}; 38};
39 39
40fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -> Option<Resolver> { 40fn try_get_resolver_for_node(db: &impl HirDatabase, node: InFile<&SyntaxNode>) -> Option<Resolver> {
41 match_ast! { 41 match_ast! {
42 match (node.value) { 42 match (node.value) {
43 ast::Module(it) => { 43 ast::Module(it) => {
@@ -71,7 +71,7 @@ fn try_get_resolver_for_node(db: &impl HirDatabase, node: Source<&SyntaxNode>) -
71 71
72fn def_with_body_from_child_node( 72fn def_with_body_from_child_node(
73 db: &impl HirDatabase, 73 db: &impl HirDatabase,
74 child: Source<&SyntaxNode>, 74 child: InFile<&SyntaxNode>,
75) -> Option<DefWithBody> { 75) -> Option<DefWithBody> {
76 child.value.ancestors().find_map(|node| { 76 child.value.ancestors().find_map(|node| {
77 match_ast! { 77 match_ast! {
@@ -141,8 +141,8 @@ impl Expansion {
141 pub fn map_token_down( 141 pub fn map_token_down(
142 &self, 142 &self,
143 db: &impl HirDatabase, 143 db: &impl HirDatabase,
144 token: Source<&SyntaxToken>, 144 token: InFile<&SyntaxToken>,
145 ) -> Option<Source<SyntaxToken>> { 145 ) -> Option<InFile<SyntaxToken>> {
146 let exp_info = self.file_id().expansion_info(db)?; 146 let exp_info = self.file_id().expansion_info(db)?;
147 exp_info.map_token_down(token) 147 exp_info.map_token_down(token)
148 } 148 }
@@ -155,7 +155,7 @@ impl Expansion {
155impl SourceAnalyzer { 155impl SourceAnalyzer {
156 pub fn new( 156 pub fn new(
157 db: &impl HirDatabase, 157 db: &impl HirDatabase,
158 node: Source<&SyntaxNode>, 158 node: InFile<&SyntaxNode>,
159 offset: Option<TextUnit>, 159 offset: Option<TextUnit>,
160 ) -> SourceAnalyzer { 160 ) -> SourceAnalyzer {
161 let def_with_body = def_with_body_from_child_node(db, node); 161 let def_with_body = def_with_body_from_child_node(db, node);
@@ -192,12 +192,12 @@ impl SourceAnalyzer {
192 } 192 }
193 193
194 fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> { 194 fn expr_id(&self, expr: &ast::Expr) -> Option<ExprId> {
195 let src = Source { file_id: self.file_id, value: expr }; 195 let src = InFile { file_id: self.file_id, value: expr };
196 self.body_source_map.as_ref()?.node_expr(src) 196 self.body_source_map.as_ref()?.node_expr(src)
197 } 197 }
198 198
199 fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { 199 fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> {
200 let src = Source { file_id: self.file_id, value: pat }; 200 let src = InFile { file_id: self.file_id, value: pat };
201 self.body_source_map.as_ref()?.node_pat(src) 201 self.body_source_map.as_ref()?.node_pat(src)
202 } 202 }
203 203
@@ -243,7 +243,7 @@ impl SourceAnalyzer {
243 pub fn resolve_macro_call( 243 pub fn resolve_macro_call(
244 &self, 244 &self,
245 db: &impl HirDatabase, 245 db: &impl HirDatabase,
246 macro_call: Source<&ast::MacroCall>, 246 macro_call: InFile<&ast::MacroCall>,
247 ) -> Option<MacroDef> { 247 ) -> Option<MacroDef> {
248 let hygiene = Hygiene::new(db, macro_call.file_id); 248 let hygiene = Hygiene::new(db, macro_call.file_id);
249 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?; 249 let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?;
@@ -286,7 +286,7 @@ impl SourceAnalyzer {
286 286
287 let items = self 287 let items = self
288 .resolver 288 .resolver
289 .resolve_module_path(db, &path) 289 .resolve_module_path_in_items(db, &path)
290 .take_types() 290 .take_types()
291 .map(|it| PathResolution::Def(it.into())); 291 .map(|it| PathResolution::Def(it.into()));
292 types.or(values).or(items).or_else(|| { 292 types.or(values).or(items).or_else(|| {
@@ -318,7 +318,7 @@ impl SourceAnalyzer {
318 let name = name_ref.as_name(); 318 let name = name_ref.as_name();
319 let source_map = self.body_source_map.as_ref()?; 319 let source_map = self.body_source_map.as_ref()?;
320 let scopes = self.scopes.as_ref()?; 320 let scopes = self.scopes.as_ref()?;
321 let scope = scope_for(scopes, source_map, Source::new(self.file_id, name_ref.syntax()))?; 321 let scope = scope_for(scopes, source_map, InFile::new(self.file_id, name_ref.syntax()))?;
322 let entry = scopes.resolve_name_in_scope(scope, &name)?; 322 let entry = scopes.resolve_name_in_scope(scope, &name)?;
323 Some(ScopeEntryWithSyntax { 323 Some(ScopeEntryWithSyntax {
324 name: entry.name().clone(), 324 name: entry.name().clone(),
@@ -446,7 +446,7 @@ impl SourceAnalyzer {
446 pub fn expand( 446 pub fn expand(
447 &self, 447 &self,
448 db: &impl HirDatabase, 448 db: &impl HirDatabase,
449 macro_call: Source<&ast::MacroCall>, 449 macro_call: InFile<&ast::MacroCall>,
450 ) -> Option<Expansion> { 450 ) -> Option<Expansion> {
451 let def = self.resolve_macro_call(db, macro_call)?.id; 451 let def = self.resolve_macro_call(db, macro_call)?.id;
452 let ast_id = AstId::new( 452 let ast_id = AstId::new(
@@ -463,19 +463,19 @@ impl SourceAnalyzer {
463fn scope_for( 463fn scope_for(
464 scopes: &ExprScopes, 464 scopes: &ExprScopes,
465 source_map: &BodySourceMap, 465 source_map: &BodySourceMap,
466 node: Source<&SyntaxNode>, 466 node: InFile<&SyntaxNode>,
467) -> Option<ScopeId> { 467) -> Option<ScopeId> {
468 node.value 468 node.value
469 .ancestors() 469 .ancestors()
470 .filter_map(ast::Expr::cast) 470 .filter_map(ast::Expr::cast)
471 .filter_map(|it| source_map.node_expr(Source::new(node.file_id, &it))) 471 .filter_map(|it| source_map.node_expr(InFile::new(node.file_id, &it)))
472 .find_map(|it| scopes.scope_for(it)) 472 .find_map(|it| scopes.scope_for(it))
473} 473}
474 474
475fn scope_for_offset( 475fn scope_for_offset(
476 scopes: &ExprScopes, 476 scopes: &ExprScopes,
477 source_map: &BodySourceMap, 477 source_map: &BodySourceMap,
478 offset: Source<TextUnit>, 478 offset: InFile<TextUnit>,
479) -> Option<ScopeId> { 479) -> Option<ScopeId> {
480 scopes 480 scopes
481 .scope_by_expr() 481 .scope_by_expr()
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs
index 3666529b0..9ab829aab 100644
--- a/crates/ra_hir_def/src/adt.rs
+++ b/crates/ra_hir_def/src/adt.rs
@@ -5,13 +5,13 @@ use std::sync::Arc;
5use hir_expand::{ 5use hir_expand::{
6 either::Either, 6 either::Either,
7 name::{AsName, Name}, 7 name::{AsName, Name},
8 Source, 8 InFile,
9}; 9};
10use ra_arena::{map::ArenaMap, Arena}; 10use ra_arena::{map::ArenaMap, Arena};
11use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; 11use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
12 12
13use crate::{ 13use crate::{
14 db::DefDatabase, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId, HasChildSource, 14 db::DefDatabase, src::HasChildSource, trace::Trace, type_ref::TypeRef, AstItemDef, EnumId,
15 LocalEnumVariantId, LocalStructFieldId, StructId, UnionId, VariantId, 15 LocalEnumVariantId, LocalStructFieldId, StructId, UnionId, VariantId,
16}; 16};
17 17
@@ -88,7 +88,7 @@ impl EnumData {
88impl HasChildSource for EnumId { 88impl HasChildSource for EnumId {
89 type ChildId = LocalEnumVariantId; 89 type ChildId = LocalEnumVariantId;
90 type Value = ast::EnumVariant; 90 type Value = ast::EnumVariant;
91 fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> { 91 fn child_source(&self, db: &impl DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> {
92 let src = self.source(db); 92 let src = self.source(db);
93 let mut trace = Trace::new_for_map(); 93 let mut trace = Trace::new_for_map();
94 lower_enum(&mut trace, &src.value); 94 lower_enum(&mut trace, &src.value);
@@ -145,7 +145,7 @@ impl HasChildSource for VariantId {
145 type ChildId = LocalStructFieldId; 145 type ChildId = LocalStructFieldId;
146 type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; 146 type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>;
147 147
148 fn child_source(&self, db: &impl DefDatabase) -> Source<ArenaMap<Self::ChildId, Self::Value>> { 148 fn child_source(&self, db: &impl DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> {
149 let src = match self { 149 let src = match self {
150 VariantId::EnumVariantId(it) => { 150 VariantId::EnumVariantId(it) => {
151 // I don't really like the fact that we call into parent source 151 // I don't really like the fact that we call into parent source
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs
index fffb22201..bc7ade921 100644
--- a/crates/ra_hir_def/src/attr.rs
+++ b/crates/ra_hir_def/src/attr.rs
@@ -2,7 +2,7 @@
2 2
3use std::{ops, sync::Arc}; 3use std::{ops, sync::Arc};
4 4
5use hir_expand::{either::Either, hygiene::Hygiene, AstId, Source}; 5use hir_expand::{either::Either, hygiene::Hygiene, AstId, InFile};
6use mbe::ast_to_token_tree; 6use mbe::ast_to_token_tree;
7use ra_syntax::{ 7use ra_syntax::{
8 ast::{self, AstNode, AttrsOwner}, 8 ast::{self, AstNode, AttrsOwner},
@@ -11,7 +11,8 @@ use ra_syntax::{
11use tt::Subtree; 11use tt::Subtree;
12 12
13use crate::{ 13use crate::{
14 db::DefDatabase, path::Path, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup, 14 db::DefDatabase, path::Path, src::HasChildSource, src::HasSource, AdtId, AstItemDef, AttrDefId,
15 Lookup,
15}; 16};
16 17
17#[derive(Default, Debug, Clone, PartialEq, Eq)] 18#[derive(Default, Debug, Clone, PartialEq, Eq)]
@@ -68,7 +69,7 @@ impl Attrs {
68 } 69 }
69 } 70 }
70 71
71 fn from_attrs_owner(db: &impl DefDatabase, owner: Source<&dyn AttrsOwner>) -> Attrs { 72 fn from_attrs_owner(db: &impl DefDatabase, owner: InFile<&dyn AttrsOwner>) -> Attrs {
72 let hygiene = Hygiene::new(db, owner.file_id); 73 let hygiene = Hygiene::new(db, owner.file_id);
73 Attrs::new(owner.value, &hygiene) 74 Attrs::new(owner.value, &hygiene)
74 } 75 }
@@ -157,7 +158,7 @@ where
157 N: ast::AttrsOwner, 158 N: ast::AttrsOwner,
158 D: DefDatabase, 159 D: DefDatabase,
159{ 160{
160 let src = Source::new(src.file_id(), src.to_node(db)); 161 let src = InFile::new(src.file_id, src.to_node(db));
161 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner)) 162 Attrs::from_attrs_owner(db, src.as_ref().map(|it| it as &dyn AttrsOwner))
162} 163}
163 164
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index a57a0176d..239f35229 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -6,7 +6,7 @@ pub mod scope;
6use std::{ops::Index, sync::Arc}; 6use std::{ops::Index, sync::Arc};
7 7
8use hir_expand::{ 8use hir_expand::{
9 either::Either, hygiene::Hygiene, AstId, HirFileId, MacroDefId, MacroFileKind, Source, 9 either::Either, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId, MacroFileKind,
10}; 10};
11use ra_arena::{map::ArenaMap, Arena}; 11use ra_arena::{map::ArenaMap, Arena};
12use ra_syntax::{ast, AstNode, AstPtr}; 12use ra_syntax::{ast, AstNode, AstPtr};
@@ -15,9 +15,10 @@ use rustc_hash::FxHashMap;
15use crate::{ 15use crate::{
16 db::DefDatabase, 16 db::DefDatabase,
17 expr::{Expr, ExprId, Pat, PatId}, 17 expr::{Expr, ExprId, Pat, PatId},
18 nameres::CrateDefMap, 18 nameres::{BuiltinShadowMode, CrateDefMap},
19 path::Path, 19 path::Path,
20 DefWithBodyId, HasModule, HasSource, Lookup, ModuleId, 20 src::HasSource,
21 DefWithBodyId, HasModule, Lookup, ModuleId,
21}; 22};
22 23
23struct Expander { 24struct Expander {
@@ -73,8 +74,8 @@ impl Expander {
73 std::mem::forget(mark); 74 std::mem::forget(mark);
74 } 75 }
75 76
76 fn to_source<T>(&self, value: T) -> Source<T> { 77 fn to_source<T>(&self, value: T) -> InFile<T> {
77 Source { file_id: self.current_file_id, value } 78 InFile { file_id: self.current_file_id, value }
78 } 79 }
79 80
80 fn parse_path(&mut self, path: ast::Path) -> Option<Path> { 81 fn parse_path(&mut self, path: ast::Path) -> Option<Path> {
@@ -82,7 +83,10 @@ impl Expander {
82 } 83 }
83 84
84 fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { 85 fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
85 self.crate_def_map.resolve_path(db, self.module.local_id, path).0.take_macros() 86 self.crate_def_map
87 .resolve_path(db, self.module.local_id, path, BuiltinShadowMode::Other)
88 .0
89 .take_macros()
86 } 90 }
87} 91}
88 92
@@ -115,10 +119,10 @@ pub struct Body {
115} 119}
116 120
117pub type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>; 121pub type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>;
118pub type ExprSource = Source<ExprPtr>; 122pub type ExprSource = InFile<ExprPtr>;
119 123
120pub type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>; 124pub type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>;
121pub type PatSource = Source<PatPtr>; 125pub type PatSource = InFile<PatPtr>;
122 126
123/// An item body together with the mapping from syntax nodes to HIR expression 127/// An item body together with the mapping from syntax nodes to HIR expression
124/// IDs. This is needed to go from e.g. a position in a file to the HIR 128/// IDs. This is needed to go from e.g. a position in a file to the HIR
@@ -205,7 +209,7 @@ impl BodySourceMap {
205 self.expr_map_back.get(expr).copied() 209 self.expr_map_back.get(expr).copied()
206 } 210 }
207 211
208 pub fn node_expr(&self, node: Source<&ast::Expr>) -> Option<ExprId> { 212 pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> {
209 let src = node.map(|it| Either::A(AstPtr::new(it))); 213 let src = node.map(|it| Either::A(AstPtr::new(it)));
210 self.expr_map.get(&src).cloned() 214 self.expr_map.get(&src).cloned()
211 } 215 }
@@ -214,7 +218,7 @@ impl BodySourceMap {
214 self.pat_map_back.get(pat).copied() 218 self.pat_map_back.get(pat).copied()
215 } 219 }
216 220
217 pub fn node_pat(&self, node: Source<&ast::Pat>) -> Option<PatId> { 221 pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> {
218 let src = node.map(|it| Either::A(AstPtr::new(it))); 222 let src = node.map(|it| Either::A(AstPtr::new(it)));
219 self.pat_map.get(&src).cloned() 223 self.pat_map.get(&src).cloned()
220 } 224 }
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index 331736cb2..be1eaa523 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -429,10 +429,19 @@ where
429 let index = self.collect_expr_opt(e.index()); 429 let index = self.collect_expr_opt(e.index());
430 self.alloc_expr(Expr::Index { base, index }, syntax_ptr) 430 self.alloc_expr(Expr::Index { base, index }, syntax_ptr)
431 } 431 }
432 ast::Expr::RangeExpr(e) => {
433 let lhs = e.start().map(|lhs| self.collect_expr(lhs));
434 let rhs = e.end().map(|rhs| self.collect_expr(rhs));
435 match e.op_kind() {
436 Some(range_type) => {
437 self.alloc_expr(Expr::Range { lhs, rhs, range_type }, syntax_ptr)
438 }
439 None => self.alloc_expr(Expr::Missing, syntax_ptr),
440 }
441 }
432 442
433 // FIXME implement HIR for these: 443 // FIXME implement HIR for these:
434 ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 444 ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
435 ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
436 ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) { 445 ast::Expr::MacroCall(e) => match self.expander.enter_expand(self.db, e) {
437 Some((mark, expansion)) => { 446 Some((mark, expansion)) => {
438 let id = self.collect_expr(expansion); 447 let id = self.collect_expr(expansion);
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs
index 625aa39dd..ab6599b23 100644
--- a/crates/ra_hir_def/src/body/scope.rs
+++ b/crates/ra_hir_def/src/body/scope.rs
@@ -171,7 +171,7 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
171 171
172#[cfg(test)] 172#[cfg(test)]
173mod tests { 173mod tests {
174 use hir_expand::{name::AsName, Source}; 174 use hir_expand::{name::AsName, InFile};
175 use ra_db::{fixture::WithFixture, FileId, SourceDatabase}; 175 use ra_db::{fixture::WithFixture, FileId, SourceDatabase};
176 use ra_syntax::{algo::find_node_at_offset, ast, AstNode}; 176 use ra_syntax::{algo::find_node_at_offset, ast, AstNode};
177 use test_utils::{assert_eq_text, covers, extract_offset}; 177 use test_utils::{assert_eq_text, covers, extract_offset};
@@ -211,7 +211,7 @@ mod tests {
211 let (_body, source_map) = db.body_with_source_map(function.into()); 211 let (_body, source_map) = db.body_with_source_map(function.into());
212 212
213 let expr_id = source_map 213 let expr_id = source_map
214 .node_expr(Source { file_id: file_id.into(), value: &marker.into() }) 214 .node_expr(InFile { file_id: file_id.into(), value: &marker.into() })
215 .unwrap(); 215 .unwrap();
216 let scope = scopes.scope_for(expr_id); 216 let scope = scopes.scope_for(expr_id);
217 217
@@ -318,7 +318,7 @@ mod tests {
318 let expr_scope = { 318 let expr_scope = {
319 let expr_ast = name_ref.syntax().ancestors().find_map(ast::Expr::cast).unwrap(); 319 let expr_ast = name_ref.syntax().ancestors().find_map(ast::Expr::cast).unwrap();
320 let expr_id = 320 let expr_id =
321 source_map.node_expr(Source { file_id: file_id.into(), value: &expr_ast }).unwrap(); 321 source_map.node_expr(InFile { file_id: file_id.into(), value: &expr_ast }).unwrap();
322 scopes.scope_for(expr_id).unwrap() 322 scopes.scope_for(expr_id).unwrap()
323 }; 323 };
324 324
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index fee10b237..095d7064a 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -10,9 +10,10 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
10 10
11use crate::{ 11use crate::{
12 db::DefDatabase, 12 db::DefDatabase,
13 src::HasSource,
13 type_ref::{Mutability, TypeRef}, 14 type_ref::{Mutability, TypeRef},
14 AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, HasSource, 15 AssocItemId, AstItemDef, ConstId, ConstLoc, ContainerId, FunctionId, FunctionLoc, ImplId,
15 ImplId, Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc, 16 Intern, Lookup, StaticId, TraitId, TypeAliasId, TypeAliasLoc,
16}; 17};
17 18
18#[derive(Debug, Clone, PartialEq, Eq)] 19#[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/crates/ra_hir_def/src/diagnostics.rs b/crates/ra_hir_def/src/diagnostics.rs
index eda9b2269..095498429 100644
--- a/crates/ra_hir_def/src/diagnostics.rs
+++ b/crates/ra_hir_def/src/diagnostics.rs
@@ -6,7 +6,7 @@ use hir_expand::diagnostics::Diagnostic;
6use ra_db::RelativePathBuf; 6use ra_db::RelativePathBuf;
7use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; 7use ra_syntax::{ast, AstPtr, SyntaxNodePtr};
8 8
9use hir_expand::{HirFileId, Source}; 9use hir_expand::{HirFileId, InFile};
10 10
11#[derive(Debug)] 11#[derive(Debug)]
12pub struct UnresolvedModule { 12pub struct UnresolvedModule {
@@ -19,8 +19,8 @@ impl Diagnostic for UnresolvedModule {
19 fn message(&self) -> String { 19 fn message(&self) -> String {
20 "unresolved module".to_string() 20 "unresolved module".to_string()
21 } 21 }
22 fn source(&self) -> Source<SyntaxNodePtr> { 22 fn source(&self) -> InFile<SyntaxNodePtr> {
23 Source { file_id: self.file, value: self.decl.into() } 23 InFile { file_id: self.file, value: self.decl.into() }
24 } 24 }
25 fn as_any(&self) -> &(dyn Any + Send + 'static) { 25 fn as_any(&self) -> &(dyn Any + Send + 'static) {
26 self 26 self
diff --git a/crates/ra_hir_def/src/docs.rs b/crates/ra_hir_def/src/docs.rs
index 34ed9b7a5..ec944373d 100644
--- a/crates/ra_hir_def/src/docs.rs
+++ b/crates/ra_hir_def/src/docs.rs
@@ -8,7 +8,11 @@ use std::sync::Arc;
8use hir_expand::either::Either; 8use hir_expand::either::Either;
9use ra_syntax::ast; 9use ra_syntax::ast;
10 10
11use crate::{db::DefDatabase, AdtId, AstItemDef, AttrDefId, HasChildSource, HasSource, Lookup}; 11use crate::{
12 db::DefDatabase,
13 src::{HasChildSource, HasSource},
14 AdtId, AstItemDef, AttrDefId, Lookup,
15};
12 16
13/// Holds documentation 17/// Holds documentation
14#[derive(Debug, Clone, PartialEq, Eq)] 18#[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs
index 04c1d8f69..6fad80a8d 100644
--- a/crates/ra_hir_def/src/expr.rs
+++ b/crates/ra_hir_def/src/expr.rs
@@ -14,6 +14,7 @@
14 14
15use hir_expand::name::Name; 15use hir_expand::name::Name;
16use ra_arena::{impl_arena_id, RawId}; 16use ra_arena::{impl_arena_id, RawId};
17use ra_syntax::ast::RangeOp;
17 18
18use crate::{ 19use crate::{
19 builtin_type::{BuiltinFloat, BuiltinInt}, 20 builtin_type::{BuiltinFloat, BuiltinInt},
@@ -130,6 +131,11 @@ pub enum Expr {
130 rhs: ExprId, 131 rhs: ExprId,
131 op: Option<BinaryOp>, 132 op: Option<BinaryOp>,
132 }, 133 },
134 Range {
135 lhs: Option<ExprId>,
136 rhs: Option<ExprId>,
137 range_type: RangeOp,
138 },
133 Index { 139 Index {
134 base: ExprId, 140 base: ExprId,
135 index: ExprId, 141 index: ExprId,
@@ -288,6 +294,14 @@ impl Expr {
288 f(*lhs); 294 f(*lhs);
289 f(*rhs); 295 f(*rhs);
290 } 296 }
297 Expr::Range { lhs, rhs, .. } => {
298 if let Some(lhs) = rhs {
299 f(*lhs);
300 }
301 if let Some(rhs) = lhs {
302 f(*rhs);
303 }
304 }
291 Expr::Index { base, index } => { 305 Expr::Index { base, index } => {
292 f(*base); 306 f(*base);
293 f(*index); 307 f(*index);
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 3f94e40e4..5f648ffc3 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -9,8 +9,9 @@ use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner};
9 9
10use crate::{ 10use crate::{
11 db::DefDatabase, 11 db::DefDatabase,
12 src::HasSource,
12 type_ref::{TypeBound, TypeRef}, 13 type_ref::{TypeBound, TypeRef},
13 AdtId, AstItemDef, ContainerId, GenericDefId, HasSource, Lookup, 14 AdtId, AstItemDef, ContainerId, GenericDefId, Lookup,
14}; 15};
15 16
16/// Data about a generic parameter (to a function, struct, impl, ...). 17/// Data about a generic parameter (to a function, struct, impl, ...).
diff --git a/crates/ra_hir_def/src/lib.rs b/crates/ra_hir_def/src/lib.rs
index bc5530896..cfeacfded 100644
--- a/crates/ra_hir_def/src/lib.rs
+++ b/crates/ra_hir_def/src/lib.rs
@@ -29,6 +29,8 @@ pub mod resolver;
29mod trace; 29mod trace;
30pub mod nameres; 30pub mod nameres;
31 31
32pub mod src;
33
32#[cfg(test)] 34#[cfg(test)]
33mod test_db; 35mod test_db;
34#[cfg(test)] 36#[cfg(test)]
@@ -36,8 +38,8 @@ mod marks;
36 38
37use std::hash::{Hash, Hasher}; 39use std::hash::{Hash, Hasher};
38 40
39use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, MacroDefId, Source}; 41use hir_expand::{ast_id_map::FileAstId, db::AstDatabase, AstId, HirFileId, InFile, MacroDefId};
40use ra_arena::{impl_arena_id, map::ArenaMap, RawId}; 42use ra_arena::{impl_arena_id, RawId};
41use ra_db::{impl_intern_key, salsa, CrateId}; 43use ra_db::{impl_intern_key, salsa, CrateId};
42use ra_syntax::{ast, AstNode}; 44use ra_syntax::{ast, AstNode};
43 45
@@ -105,10 +107,10 @@ pub trait AstItemDef<N: AstNode>: salsa::InternKey + Clone {
105 let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) }; 107 let loc = ItemLoc { module: ctx.module, ast_id: AstId::new(ctx.file_id, ast_id) };
106 Self::intern(ctx.db, loc) 108 Self::intern(ctx.db, loc)
107 } 109 }
108 fn source(self, db: &(impl AstDatabase + InternDatabase)) -> Source<N> { 110 fn source(self, db: &(impl AstDatabase + InternDatabase)) -> InFile<N> {
109 let loc = self.lookup_intern(db); 111 let loc = self.lookup_intern(db);
110 let value = loc.ast_id.to_node(db); 112 let value = loc.ast_id.to_node(db);
111 Source { file_id: loc.ast_id.file_id(), value } 113 InFile { file_id: loc.ast_id.file_id, value }
112 } 114 }
113 fn module(self, db: &impl InternDatabase) -> ModuleId { 115 fn module(self, db: &impl InternDatabase) -> ModuleId {
114 let loc = self.lookup_intern(db); 116 let loc = self.lookup_intern(db);
@@ -514,53 +516,3 @@ impl HasModule for StaticLoc {
514 self.container 516 self.container
515 } 517 }
516} 518}
517
518pub trait HasSource {
519 type Value;
520 fn source(&self, db: &impl db::DefDatabase) -> Source<Self::Value>;
521}
522
523impl HasSource for FunctionLoc {
524 type Value = ast::FnDef;
525
526 fn source(&self, db: &impl db::DefDatabase) -> Source<ast::FnDef> {
527 let node = self.ast_id.to_node(db);
528 Source::new(self.ast_id.file_id(), node)
529 }
530}
531
532impl HasSource for TypeAliasLoc {
533 type Value = ast::TypeAliasDef;
534
535 fn source(&self, db: &impl db::DefDatabase) -> Source<ast::TypeAliasDef> {
536 let node = self.ast_id.to_node(db);
537 Source::new(self.ast_id.file_id(), node)
538 }
539}
540
541impl HasSource for ConstLoc {
542 type Value = ast::ConstDef;
543
544 fn source(&self, db: &impl db::DefDatabase) -> Source<ast::ConstDef> {
545 let node = self.ast_id.to_node(db);
546 Source::new(self.ast_id.file_id(), node)
547 }
548}
549
550impl HasSource for StaticLoc {
551 type Value = ast::StaticDef;
552
553 fn source(&self, db: &impl db::DefDatabase) -> Source<ast::StaticDef> {
554 let node = self.ast_id.to_node(db);
555 Source::new(self.ast_id.file_id(), node)
556 }
557}
558
559pub trait HasChildSource {
560 type ChildId;
561 type Value;
562 fn child_source(
563 &self,
564 db: &impl db::DefDatabase,
565 ) -> Source<ArenaMap<Self::ChildId, Self::Value>>;
566}
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 2359386c2..3e1521870 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -58,8 +58,8 @@ mod tests;
58use std::sync::Arc; 58use std::sync::Arc;
59 59
60use hir_expand::{ 60use hir_expand::{
61 ast_id_map::FileAstId, diagnostics::DiagnosticSink, either::Either, name::Name, MacroDefId, 61 ast_id_map::FileAstId, diagnostics::DiagnosticSink, either::Either, name::Name, InFile,
62 Source, 62 MacroDefId,
63}; 63};
64use once_cell::sync::Lazy; 64use once_cell::sync::Lazy;
65use ra_arena::Arena; 65use ra_arena::Arena;
@@ -149,6 +149,15 @@ static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| {
149 .collect() 149 .collect()
150}); 150});
151 151
152/// Shadow mode for builtin type which can be shadowed by module.
153#[derive(Debug, Copy, Clone, PartialEq, Eq)]
154pub enum BuiltinShadowMode {
155 // Prefer Module
156 Module,
157 // Prefer Other Types
158 Other,
159}
160
152/// Legacy macros can only be accessed through special methods like `get_legacy_macros`. 161/// Legacy macros can only be accessed through special methods like `get_legacy_macros`.
153/// Other methods will only resolve values, types and module scoped macros only. 162/// Other methods will only resolve values, types and module scoped macros only.
154impl ModuleScope { 163impl ModuleScope {
@@ -178,8 +187,20 @@ impl ModuleScope {
178 } 187 }
179 188
180 /// Get a name from current module scope, legacy macros are not included 189 /// Get a name from current module scope, legacy macros are not included
181 pub fn get(&self, name: &Name) -> Option<&Resolution> { 190 pub fn get(&self, name: &Name, shadow: BuiltinShadowMode) -> Option<&Resolution> {
182 self.items.get(name).or_else(|| BUILTIN_SCOPE.get(name)) 191 match shadow {
192 BuiltinShadowMode::Module => self.items.get(name).or_else(|| BUILTIN_SCOPE.get(name)),
193 BuiltinShadowMode::Other => {
194 let item = self.items.get(name);
195 if let Some(res) = item {
196 if let Some(ModuleDefId::ModuleId(_)) = res.def.take_types() {
197 return BUILTIN_SCOPE.get(name).or(item);
198 }
199 }
200
201 item.or_else(|| BUILTIN_SCOPE.get(name))
202 }
203 }
183 } 204 }
184 205
185 pub fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a { 206 pub fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a {
@@ -250,8 +271,10 @@ impl CrateDefMap {
250 db: &impl DefDatabase, 271 db: &impl DefDatabase,
251 original_module: LocalModuleId, 272 original_module: LocalModuleId,
252 path: &Path, 273 path: &Path,
274 shadow: BuiltinShadowMode,
253 ) -> (PerNs, Option<usize>) { 275 ) -> (PerNs, Option<usize>) {
254 let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path); 276 let res =
277 self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path, shadow);
255 (res.resolved_def, res.segment_index) 278 (res.resolved_def, res.segment_index)
256 } 279 }
257} 280}
@@ -261,21 +284,21 @@ impl ModuleData {
261 pub fn definition_source( 284 pub fn definition_source(
262 &self, 285 &self,
263 db: &impl DefDatabase, 286 db: &impl DefDatabase,
264 ) -> Source<Either<ast::SourceFile, ast::Module>> { 287 ) -> InFile<Either<ast::SourceFile, ast::Module>> {
265 if let Some(file_id) = self.definition { 288 if let Some(file_id) = self.definition {
266 let sf = db.parse(file_id).tree(); 289 let sf = db.parse(file_id).tree();
267 return Source::new(file_id.into(), Either::A(sf)); 290 return InFile::new(file_id.into(), Either::A(sf));
268 } 291 }
269 let decl = self.declaration.unwrap(); 292 let decl = self.declaration.unwrap();
270 Source::new(decl.file_id(), Either::B(decl.to_node(db))) 293 InFile::new(decl.file_id, Either::B(decl.to_node(db)))
271 } 294 }
272 295
273 /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`. 296 /// Returns a node which declares this module, either a `mod foo;` or a `mod foo {}`.
274 /// `None` for the crate root. 297 /// `None` for the crate root.
275 pub fn declaration_source(&self, db: &impl DefDatabase) -> Option<Source<ast::Module>> { 298 pub fn declaration_source(&self, db: &impl DefDatabase) -> Option<InFile<ast::Module>> {
276 let decl = self.declaration?; 299 let decl = self.declaration?;
277 let value = decl.to_node(db); 300 let value = decl.to_node(db);
278 Some(Source { file_id: decl.file_id(), value }) 301 Some(InFile { file_id: decl.file_id, value })
279 } 302 }
280} 303}
281 304
@@ -309,7 +332,7 @@ mod diagnostics {
309 } 332 }
310 let decl = declaration.to_node(db); 333 let decl = declaration.to_node(db);
311 sink.push(UnresolvedModule { 334 sink.push(UnresolvedModule {
312 file: declaration.file_id(), 335 file: declaration.file_id,
313 decl: AstPtr::new(&decl), 336 decl: AstPtr::new(&decl),
314 candidate: candidate.clone(), 337 candidate: candidate.clone(),
315 }) 338 })
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index fd8245113..d4bfcae1d 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -19,7 +19,7 @@ use crate::{
19 db::DefDatabase, 19 db::DefDatabase,
20 nameres::{ 20 nameres::{
21 diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, 21 diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint,
22 raw, CrateDefMap, ModuleData, Resolution, ResolveMode, 22 raw, BuiltinShadowMode, CrateDefMap, ModuleData, Resolution, ResolveMode,
23 }, 23 },
24 path::{Path, PathKind}, 24 path::{Path, PathKind},
25 per_ns::PerNs, 25 per_ns::PerNs,
@@ -299,6 +299,7 @@ where
299 ResolveMode::Import, 299 ResolveMode::Import,
300 module_id, 300 module_id,
301 &import.path, 301 &import.path,
302 BuiltinShadowMode::Module,
302 ); 303 );
303 304
304 (res.resolved_def, res.reached_fixedpoint) 305 (res.resolved_def, res.reached_fixedpoint)
@@ -477,6 +478,7 @@ where
477 ResolveMode::Other, 478 ResolveMode::Other,
478 *module_id, 479 *module_id,
479 path, 480 path,
481 BuiltinShadowMode::Module,
480 ); 482 );
481 483
482 if let Some(def) = resolved_res.resolved_def.take_macros() { 484 if let Some(def) = resolved_res.resolved_def.take_macros() {
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs
index b72c55bd1..42a75226b 100644
--- a/crates/ra_hir_def/src/nameres/path_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/path_resolution.rs
@@ -16,7 +16,7 @@ use test_utils::tested_by;
16 16
17use crate::{ 17use crate::{
18 db::DefDatabase, 18 db::DefDatabase,
19 nameres::CrateDefMap, 19 nameres::{BuiltinShadowMode, CrateDefMap},
20 path::{Path, PathKind}, 20 path::{Path, PathKind},
21 per_ns::PerNs, 21 per_ns::PerNs,
22 AdtId, EnumVariantId, LocalModuleId, ModuleDefId, ModuleId, 22 AdtId, EnumVariantId, LocalModuleId, ModuleDefId, ModuleId,
@@ -68,7 +68,17 @@ impl CrateDefMap {
68 mode: ResolveMode, 68 mode: ResolveMode,
69 original_module: LocalModuleId, 69 original_module: LocalModuleId,
70 path: &Path, 70 path: &Path,
71 shadow: BuiltinShadowMode,
71 ) -> ResolvePathResult { 72 ) -> ResolvePathResult {
73 // if it is not the last segment, we prefer the module to the builtin
74 let prefer_module = |index| {
75 if index == path.segments.len() - 1 {
76 shadow
77 } else {
78 BuiltinShadowMode::Module
79 }
80 };
81
72 let mut segments = path.segments.iter().enumerate(); 82 let mut segments = path.segments.iter().enumerate();
73 let mut curr_per_ns: PerNs = match path.kind { 83 let mut curr_per_ns: PerNs = match path.kind {
74 PathKind::DollarCrate(krate) => { 84 PathKind::DollarCrate(krate) => {
@@ -96,20 +106,20 @@ impl CrateDefMap {
96 if self.edition == Edition::Edition2015 106 if self.edition == Edition::Edition2015
97 && (path.kind == PathKind::Abs || mode == ResolveMode::Import) => 107 && (path.kind == PathKind::Abs || mode == ResolveMode::Import) =>
98 { 108 {
99 let segment = match segments.next() { 109 let (idx, segment) = match segments.next() {
100 Some((_, segment)) => segment, 110 Some((idx, segment)) => (idx, segment),
101 None => return ResolvePathResult::empty(ReachedFixedPoint::Yes), 111 None => return ResolvePathResult::empty(ReachedFixedPoint::Yes),
102 }; 112 };
103 log::debug!("resolving {:?} in crate root (+ extern prelude)", segment); 113 log::debug!("resolving {:?} in crate root (+ extern prelude)", segment);
104 self.resolve_name_in_crate_root_or_extern_prelude(&segment.name) 114 self.resolve_name_in_crate_root_or_extern_prelude(&segment.name, prefer_module(idx))
105 } 115 }
106 PathKind::Plain => { 116 PathKind::Plain => {
107 let segment = match segments.next() { 117 let (idx, segment) = match segments.next() {
108 Some((_, segment)) => segment, 118 Some((idx, segment)) => (idx, segment),
109 None => return ResolvePathResult::empty(ReachedFixedPoint::Yes), 119 None => return ResolvePathResult::empty(ReachedFixedPoint::Yes),
110 }; 120 };
111 log::debug!("resolving {:?} in module", segment); 121 log::debug!("resolving {:?} in module", segment);
112 self.resolve_name_in_module(db, original_module, &segment.name) 122 self.resolve_name_in_module(db, original_module, &segment.name, prefer_module(idx))
113 } 123 }
114 PathKind::Super => { 124 PathKind::Super => {
115 if let Some(p) = self.modules[original_module].parent { 125 if let Some(p) = self.modules[original_module].parent {
@@ -160,7 +170,7 @@ impl CrateDefMap {
160 Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ }; 170 Path { segments: path.segments[i..].to_vec(), kind: PathKind::Self_ };
161 log::debug!("resolving {:?} in other crate", path); 171 log::debug!("resolving {:?} in other crate", path);
162 let defp_map = db.crate_def_map(module.krate); 172 let defp_map = db.crate_def_map(module.krate);
163 let (def, s) = defp_map.resolve_path(db, module.local_id, &path); 173 let (def, s) = defp_map.resolve_path(db, module.local_id, &path, shadow);
164 return ResolvePathResult::with( 174 return ResolvePathResult::with(
165 def, 175 def,
166 ReachedFixedPoint::Yes, 176 ReachedFixedPoint::Yes,
@@ -169,7 +179,7 @@ impl CrateDefMap {
169 } 179 }
170 180
171 // Since it is a qualified path here, it should not contains legacy macros 181 // Since it is a qualified path here, it should not contains legacy macros
172 match self[module.local_id].scope.get(&segment.name) { 182 match self[module.local_id].scope.get(&segment.name, prefer_module(i)) {
173 Some(res) => res.def, 183 Some(res) => res.def,
174 _ => { 184 _ => {
175 log::debug!("path segment {:?} not found", segment.name); 185 log::debug!("path segment {:?} not found", segment.name);
@@ -212,6 +222,7 @@ impl CrateDefMap {
212 } 222 }
213 }; 223 };
214 } 224 }
225
215 ResolvePathResult::with(curr_per_ns, ReachedFixedPoint::Yes, None) 226 ResolvePathResult::with(curr_per_ns, ReachedFixedPoint::Yes, None)
216 } 227 }
217 228
@@ -220,6 +231,7 @@ impl CrateDefMap {
220 db: &impl DefDatabase, 231 db: &impl DefDatabase,
221 module: LocalModuleId, 232 module: LocalModuleId,
222 name: &Name, 233 name: &Name,
234 shadow: BuiltinShadowMode,
223 ) -> PerNs { 235 ) -> PerNs {
224 // Resolve in: 236 // Resolve in:
225 // - legacy scope of macro 237 // - legacy scope of macro
@@ -228,23 +240,33 @@ impl CrateDefMap {
228 // - std prelude 240 // - std prelude
229 let from_legacy_macro = 241 let from_legacy_macro =
230 self[module].scope.get_legacy_macro(name).map_or_else(PerNs::none, PerNs::macros); 242 self[module].scope.get_legacy_macro(name).map_or_else(PerNs::none, PerNs::macros);
231 let from_scope = self[module].scope.get(name).map_or_else(PerNs::none, |res| res.def); 243 let from_scope =
244 self[module].scope.get(name, shadow).map_or_else(PerNs::none, |res| res.def);
232 let from_extern_prelude = 245 let from_extern_prelude =
233 self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it)); 246 self.extern_prelude.get(name).map_or(PerNs::none(), |&it| PerNs::types(it));
234 let from_prelude = self.resolve_in_prelude(db, name); 247 let from_prelude = self.resolve_in_prelude(db, name, shadow);
235 248
236 from_legacy_macro.or(from_scope).or(from_extern_prelude).or(from_prelude) 249 from_legacy_macro.or(from_scope).or(from_extern_prelude).or(from_prelude)
237 } 250 }
238 251
239 fn resolve_name_in_crate_root_or_extern_prelude(&self, name: &Name) -> PerNs { 252 fn resolve_name_in_crate_root_or_extern_prelude(
253 &self,
254 name: &Name,
255 shadow: BuiltinShadowMode,
256 ) -> PerNs {
240 let from_crate_root = 257 let from_crate_root =
241 self[self.root].scope.get(name).map_or_else(PerNs::none, |res| res.def); 258 self[self.root].scope.get(name, shadow).map_or_else(PerNs::none, |res| res.def);
242 let from_extern_prelude = self.resolve_name_in_extern_prelude(name); 259 let from_extern_prelude = self.resolve_name_in_extern_prelude(name);
243 260
244 from_crate_root.or(from_extern_prelude) 261 from_crate_root.or(from_extern_prelude)
245 } 262 }
246 263
247 fn resolve_in_prelude(&self, db: &impl DefDatabase, name: &Name) -> PerNs { 264 fn resolve_in_prelude(
265 &self,
266 db: &impl DefDatabase,
267 name: &Name,
268 shadow: BuiltinShadowMode,
269 ) -> PerNs {
248 if let Some(prelude) = self.prelude { 270 if let Some(prelude) = self.prelude {
249 let keep; 271 let keep;
250 let def_map = if prelude.krate == self.krate { 272 let def_map = if prelude.krate == self.krate {
@@ -254,7 +276,10 @@ impl CrateDefMap {
254 keep = db.crate_def_map(prelude.krate); 276 keep = db.crate_def_map(prelude.krate);
255 &keep 277 &keep
256 }; 278 };
257 def_map[prelude.local_id].scope.get(name).map_or_else(PerNs::none, |res| res.def) 279 def_map[prelude.local_id]
280 .scope
281 .get(name, shadow)
282 .map_or_else(PerNs::none, |res| res.def)
258 } else { 283 } else {
259 PerNs::none() 284 PerNs::none()
260 } 285 }
diff --git a/crates/ra_hir_def/src/nameres/raw.rs b/crates/ra_hir_def/src/nameres/raw.rs
index 6eb106094..5196b67ca 100644
--- a/crates/ra_hir_def/src/nameres/raw.rs
+++ b/crates/ra_hir_def/src/nameres/raw.rs
@@ -22,8 +22,8 @@ use ra_syntax::{
22use test_utils::tested_by; 22use test_utils::tested_by;
23 23
24use crate::{ 24use crate::{
25 attr::Attrs, db::DefDatabase, path::Path, trace::Trace, FileAstId, HirFileId, LocalImportId, 25 attr::Attrs, db::DefDatabase, path::Path, trace::Trace, FileAstId, HirFileId, InFile,
26 Source, 26 LocalImportId,
27}; 27};
28 28
29/// `RawItems` is a set of top-level items in a file (except for impls). 29/// `RawItems` is a set of top-level items in a file (except for impls).
@@ -313,7 +313,7 @@ impl RawItemsCollector {
313 313
314 let mut buf = Vec::new(); 314 let mut buf = Vec::new();
315 Path::expand_use_item( 315 Path::expand_use_item(
316 Source { value: use_item, file_id: self.file_id }, 316 InFile { value: use_item, file_id: self.file_id },
317 &self.hygiene, 317 &self.hygiene,
318 |path, use_tree, is_glob, alias| { 318 |path, use_tree, is_glob, alias| {
319 let import_data = ImportData { 319 let import_data = ImportData {
diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
index e11530062..e800cc68e 100644
--- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs
@@ -668,7 +668,7 @@ fn unresolved_module_diagnostics() {
668 module: LocalModuleId( 668 module: LocalModuleId(
669 0, 669 0,
670 ), 670 ),
671 declaration: AstId { 671 declaration: InFile {
672 file_id: HirFileId( 672 file_id: HirFileId(
673 FileId( 673 FileId(
674 FileId( 674 FileId(
@@ -676,7 +676,7 @@ fn unresolved_module_diagnostics() {
676 ), 676 ),
677 ), 677 ),
678 ), 678 ),
679 file_ast_id: FileAstId { 679 value: FileAstId {
680 raw: ErasedFileAstId( 680 raw: ErasedFileAstId(
681 1, 681 1,
682 ), 682 ),
diff --git a/crates/ra_hir_def/src/path.rs b/crates/ra_hir_def/src/path.rs
index 6810a26db..ff252fe44 100644
--- a/crates/ra_hir_def/src/path.rs
+++ b/crates/ra_hir_def/src/path.rs
@@ -13,7 +13,7 @@ use ra_syntax::{
13 AstNode, 13 AstNode,
14}; 14};
15 15
16use crate::{type_ref::TypeRef, Source}; 16use crate::{type_ref::TypeRef, InFile};
17 17
18#[derive(Debug, Clone, PartialEq, Eq, Hash)] 18#[derive(Debug, Clone, PartialEq, Eq, Hash)]
19pub struct Path { 19pub struct Path {
@@ -67,7 +67,7 @@ pub enum PathKind {
67impl Path { 67impl Path {
68 /// Calls `cb` with all paths, represented by this use item. 68 /// Calls `cb` with all paths, represented by this use item.
69 pub(crate) fn expand_use_item( 69 pub(crate) fn expand_use_item(
70 item_src: Source<ast::UseItem>, 70 item_src: InFile<ast::UseItem>,
71 hygiene: &Hygiene, 71 hygiene: &Hygiene,
72 mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>), 72 mut cb: impl FnMut(Path, &ast::UseTree, bool, Option<Name>),
73 ) { 73 ) {
@@ -409,6 +409,36 @@ pub mod known {
409 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::TRY_TYPE]) 409 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::TRY_TYPE])
410 } 410 }
411 411
412 pub fn std_ops_range() -> Path {
413 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_TYPE])
414 }
415
416 pub fn std_ops_range_from() -> Path {
417 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_FROM_TYPE])
418 }
419
420 pub fn std_ops_range_full() -> Path {
421 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_FULL_TYPE])
422 }
423
424 pub fn std_ops_range_inclusive() -> Path {
425 Path::from_simple_segments(
426 PathKind::Abs,
427 vec![name::STD, name::OPS, name::RANGE_INCLUSIVE_TYPE],
428 )
429 }
430
431 pub fn std_ops_range_to() -> Path {
432 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::RANGE_TO_TYPE])
433 }
434
435 pub fn std_ops_range_to_inclusive() -> Path {
436 Path::from_simple_segments(
437 PathKind::Abs,
438 vec![name::STD, name::OPS, name::RANGE_TO_INCLUSIVE_TYPE],
439 )
440 }
441
412 pub fn std_result_result() -> Path { 442 pub fn std_result_result() -> Path {
413 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::RESULT, name::RESULT_TYPE]) 443 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::RESULT, name::RESULT_TYPE])
414 } 444 }
diff --git a/crates/ra_hir_def/src/resolver.rs b/crates/ra_hir_def/src/resolver.rs
index 0847f6dcf..7d4df222e 100644
--- a/crates/ra_hir_def/src/resolver.rs
+++ b/crates/ra_hir_def/src/resolver.rs
@@ -14,7 +14,7 @@ use crate::{
14 db::DefDatabase, 14 db::DefDatabase,
15 expr::{ExprId, PatId}, 15 expr::{ExprId, PatId},
16 generics::GenericParams, 16 generics::GenericParams,
17 nameres::CrateDefMap, 17 nameres::{BuiltinShadowMode, CrateDefMap},
18 path::{Path, PathKind}, 18 path::{Path, PathKind},
19 per_ns::PerNs, 19 per_ns::PerNs,
20 AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, 20 AdtId, AstItemDef, ConstId, ContainerId, DefWithBodyId, EnumId, EnumVariantId, FunctionId,
@@ -91,7 +91,7 @@ pub enum ValueNs {
91impl Resolver { 91impl Resolver {
92 /// Resolve known trait from std, like `std::futures::Future` 92 /// Resolve known trait from std, like `std::futures::Future`
93 pub fn resolve_known_trait(&self, db: &impl DefDatabase, path: &Path) -> Option<TraitId> { 93 pub fn resolve_known_trait(&self, db: &impl DefDatabase, path: &Path) -> Option<TraitId> {
94 let res = self.resolve_module_path(db, path).take_types()?; 94 let res = self.resolve_module_path(db, path, BuiltinShadowMode::Other).take_types()?;
95 match res { 95 match res {
96 ModuleDefId::TraitId(it) => Some(it), 96 ModuleDefId::TraitId(it) => Some(it),
97 _ => None, 97 _ => None,
@@ -100,7 +100,7 @@ impl Resolver {
100 100
101 /// Resolve known struct from std, like `std::boxed::Box` 101 /// Resolve known struct from std, like `std::boxed::Box`
102 pub fn resolve_known_struct(&self, db: &impl DefDatabase, path: &Path) -> Option<StructId> { 102 pub fn resolve_known_struct(&self, db: &impl DefDatabase, path: &Path) -> Option<StructId> {
103 let res = self.resolve_module_path(db, path).take_types()?; 103 let res = self.resolve_module_path(db, path, BuiltinShadowMode::Other).take_types()?;
104 match res { 104 match res {
105 ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it), 105 ModuleDefId::AdtId(AdtId::StructId(it)) => Some(it),
106 _ => None, 106 _ => None,
@@ -109,26 +109,34 @@ impl Resolver {
109 109
110 /// Resolve known enum from std, like `std::result::Result` 110 /// Resolve known enum from std, like `std::result::Result`
111 pub fn resolve_known_enum(&self, db: &impl DefDatabase, path: &Path) -> Option<EnumId> { 111 pub fn resolve_known_enum(&self, db: &impl DefDatabase, path: &Path) -> Option<EnumId> {
112 let res = self.resolve_module_path(db, path).take_types()?; 112 let res = self.resolve_module_path(db, path, BuiltinShadowMode::Other).take_types()?;
113 match res { 113 match res {
114 ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it), 114 ModuleDefId::AdtId(AdtId::EnumId(it)) => Some(it),
115 _ => None, 115 _ => None,
116 } 116 }
117 } 117 }
118 118
119 /// pub only for source-binder 119 fn resolve_module_path(
120 pub fn resolve_module_path(&self, db: &impl DefDatabase, path: &Path) -> PerNs { 120 &self,
121 db: &impl DefDatabase,
122 path: &Path,
123 shadow: BuiltinShadowMode,
124 ) -> PerNs {
121 let (item_map, module) = match self.module() { 125 let (item_map, module) = match self.module() {
122 Some(it) => it, 126 Some(it) => it,
123 None => return PerNs::none(), 127 None => return PerNs::none(),
124 }; 128 };
125 let (module_res, segment_index) = item_map.resolve_path(db, module, path); 129 let (module_res, segment_index) = item_map.resolve_path(db, module, path, shadow);
126 if segment_index.is_some() { 130 if segment_index.is_some() {
127 return PerNs::none(); 131 return PerNs::none();
128 } 132 }
129 module_res 133 module_res
130 } 134 }
131 135
136 pub fn resolve_module_path_in_items(&self, db: &impl DefDatabase, path: &Path) -> PerNs {
137 self.resolve_module_path(db, path, BuiltinShadowMode::Module)
138 }
139
132 pub fn resolve_path_in_type_ns( 140 pub fn resolve_path_in_type_ns(
133 &self, 141 &self,
134 db: &impl DefDatabase, 142 db: &impl DefDatabase,
@@ -163,7 +171,12 @@ impl Resolver {
163 } 171 }
164 } 172 }
165 Scope::ModuleScope(m) => { 173 Scope::ModuleScope(m) => {
166 let (module_def, idx) = m.crate_def_map.resolve_path(db, m.module_id, path); 174 let (module_def, idx) = m.crate_def_map.resolve_path(
175 db,
176 m.module_id,
177 path,
178 BuiltinShadowMode::Other,
179 );
167 let res = match module_def.take_types()? { 180 let res = match module_def.take_types()? {
168 ModuleDefId::AdtId(it) => TypeNs::AdtId(it), 181 ModuleDefId::AdtId(it) => TypeNs::AdtId(it),
169 ModuleDefId::EnumVariantId(it) => TypeNs::EnumVariantId(it), 182 ModuleDefId::EnumVariantId(it) => TypeNs::EnumVariantId(it),
@@ -256,7 +269,12 @@ impl Resolver {
256 Scope::ImplBlockScope(_) | Scope::AdtScope(_) => continue, 269 Scope::ImplBlockScope(_) | Scope::AdtScope(_) => continue,
257 270
258 Scope::ModuleScope(m) => { 271 Scope::ModuleScope(m) => {
259 let (module_def, idx) = m.crate_def_map.resolve_path(db, m.module_id, path); 272 let (module_def, idx) = m.crate_def_map.resolve_path(
273 db,
274 m.module_id,
275 path,
276 BuiltinShadowMode::Other,
277 );
260 return match idx { 278 return match idx {
261 None => { 279 None => {
262 let value = match module_def.take_values()? { 280 let value = match module_def.take_values()? {
@@ -310,7 +328,7 @@ impl Resolver {
310 328
311 pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> { 329 pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
312 let (item_map, module) = self.module()?; 330 let (item_map, module) = self.module()?;
313 item_map.resolve_path(db, module, path).0.take_macros() 331 item_map.resolve_path(db, module, path, BuiltinShadowMode::Other).0.take_macros()
314 } 332 }
315 333
316 pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) { 334 pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
diff --git a/crates/ra_hir_def/src/src.rs b/crates/ra_hir_def/src/src.rs
new file mode 100644
index 000000000..27caa02cc
--- /dev/null
+++ b/crates/ra_hir_def/src/src.rs
@@ -0,0 +1,54 @@
1//! Utilities for mapping between hir IDs and the surface syntax.
2
3use hir_expand::InFile;
4use ra_arena::map::ArenaMap;
5use ra_syntax::ast;
6
7use crate::{db::DefDatabase, ConstLoc, FunctionLoc, StaticLoc, TypeAliasLoc};
8
9pub trait HasSource {
10 type Value;
11 fn source(&self, db: &impl DefDatabase) -> InFile<Self::Value>;
12}
13
14impl HasSource for FunctionLoc {
15 type Value = ast::FnDef;
16
17 fn source(&self, db: &impl DefDatabase) -> InFile<ast::FnDef> {
18 let node = self.ast_id.to_node(db);
19 InFile::new(self.ast_id.file_id, node)
20 }
21}
22
23impl HasSource for TypeAliasLoc {
24 type Value = ast::TypeAliasDef;
25
26 fn source(&self, db: &impl DefDatabase) -> InFile<ast::TypeAliasDef> {
27 let node = self.ast_id.to_node(db);
28 InFile::new(self.ast_id.file_id, node)
29 }
30}
31
32impl HasSource for ConstLoc {
33 type Value = ast::ConstDef;
34
35 fn source(&self, db: &impl DefDatabase) -> InFile<ast::ConstDef> {
36 let node = self.ast_id.to_node(db);
37 InFile::new(self.ast_id.file_id, node)
38 }
39}
40
41impl HasSource for StaticLoc {
42 type Value = ast::StaticDef;
43
44 fn source(&self, db: &impl DefDatabase) -> InFile<ast::StaticDef> {
45 let node = self.ast_id.to_node(db);
46 InFile::new(self.ast_id.file_id, node)
47 }
48}
49
50pub trait HasChildSource {
51 type ChildId;
52 type Value;
53 fn child_source(&self, db: &impl DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>>;
54}
diff --git a/crates/ra_hir_expand/src/diagnostics.rs b/crates/ra_hir_expand/src/diagnostics.rs
index 3d37e9335..108c1e38c 100644
--- a/crates/ra_hir_expand/src/diagnostics.rs
+++ b/crates/ra_hir_expand/src/diagnostics.rs
@@ -18,11 +18,11 @@ use std::{any::Any, fmt};
18 18
19use ra_syntax::{SyntaxNode, SyntaxNodePtr, TextRange}; 19use ra_syntax::{SyntaxNode, SyntaxNodePtr, TextRange};
20 20
21use crate::{db::AstDatabase, Source}; 21use crate::{db::AstDatabase, InFile};
22 22
23pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static { 23pub trait Diagnostic: Any + Send + Sync + fmt::Debug + 'static {
24 fn message(&self) -> String; 24 fn message(&self) -> String;
25 fn source(&self) -> Source<SyntaxNodePtr>; 25 fn source(&self) -> InFile<SyntaxNodePtr>;
26 fn highlight_range(&self) -> TextRange { 26 fn highlight_range(&self) -> TextRange {
27 self.source().value.range() 27 self.source().value.range()
28 } 28 }
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index b6a739cda..fb88d2ac2 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -13,7 +13,7 @@ pub mod diagnostics;
13pub mod builtin_macro; 13pub mod builtin_macro;
14pub mod quote; 14pub mod quote;
15 15
16use std::hash::{Hash, Hasher}; 16use std::hash::Hash;
17use std::sync::Arc; 17use std::sync::Arc;
18 18
19use ra_db::{salsa, CrateId, FileId}; 19use ra_db::{salsa, CrateId, FileId};
@@ -70,7 +70,7 @@ impl HirFileId {
70 HirFileIdRepr::FileId(file_id) => file_id, 70 HirFileIdRepr::FileId(file_id) => file_id,
71 HirFileIdRepr::MacroFile(macro_file) => { 71 HirFileIdRepr::MacroFile(macro_file) => {
72 let loc = db.lookup_intern_macro(macro_file.macro_call_id); 72 let loc = db.lookup_intern_macro(macro_file.macro_call_id);
73 loc.ast_id.file_id().original_file(db) 73 loc.ast_id.file_id.original_file(db)
74 } 74 }
75 } 75 }
76 } 76 }
@@ -90,9 +90,9 @@ impl HirFileId {
90 let macro_arg = db.macro_arg(macro_file.macro_call_id)?; 90 let macro_arg = db.macro_arg(macro_file.macro_call_id)?;
91 91
92 Some(ExpansionInfo { 92 Some(ExpansionInfo {
93 expanded: Source::new(self, parse.syntax_node()), 93 expanded: InFile::new(self, parse.syntax_node()),
94 arg: Source::new(loc.ast_id.file_id, arg_tt), 94 arg: InFile::new(loc.ast_id.file_id, arg_tt),
95 def: Source::new(loc.ast_id.file_id, def_tt), 95 def: InFile::new(loc.ast_id.file_id, def_tt),
96 macro_arg, 96 macro_arg,
97 macro_def, 97 macro_def,
98 exp_map, 98 exp_map,
@@ -167,9 +167,9 @@ impl MacroCallId {
167/// ExpansionInfo mainly describes how to map text range between src and expanded macro 167/// ExpansionInfo mainly describes how to map text range between src and expanded macro
168#[derive(Debug, Clone, PartialEq, Eq)] 168#[derive(Debug, Clone, PartialEq, Eq)]
169pub struct ExpansionInfo { 169pub struct ExpansionInfo {
170 expanded: Source<SyntaxNode>, 170 expanded: InFile<SyntaxNode>,
171 arg: Source<ast::TokenTree>, 171 arg: InFile<ast::TokenTree>,
172 def: Source<ast::TokenTree>, 172 def: InFile<ast::TokenTree>,
173 173
174 macro_def: Arc<(db::TokenExpander, mbe::TokenMap)>, 174 macro_def: Arc<(db::TokenExpander, mbe::TokenMap)>,
175 macro_arg: Arc<(tt::Subtree, mbe::TokenMap)>, 175 macro_arg: Arc<(tt::Subtree, mbe::TokenMap)>,
@@ -177,7 +177,7 @@ pub struct ExpansionInfo {
177} 177}
178 178
179impl ExpansionInfo { 179impl ExpansionInfo {
180 pub fn map_token_down(&self, token: Source<&SyntaxToken>) -> Option<Source<SyntaxToken>> { 180 pub fn map_token_down(&self, token: InFile<&SyntaxToken>) -> Option<InFile<SyntaxToken>> {
181 assert_eq!(token.file_id, self.arg.file_id); 181 assert_eq!(token.file_id, self.arg.file_id);
182 let range = 182 let range =
183 token.value.text_range().checked_sub(self.arg.value.syntax().text_range().start())?; 183 token.value.text_range().checked_sub(self.arg.value.syntax().text_range().start())?;
@@ -191,7 +191,7 @@ impl ExpansionInfo {
191 Some(self.expanded.with_value(token)) 191 Some(self.expanded.with_value(token))
192 } 192 }
193 193
194 pub fn map_token_up(&self, token: Source<&SyntaxToken>) -> Option<Source<SyntaxToken>> { 194 pub fn map_token_up(&self, token: InFile<&SyntaxToken>) -> Option<InFile<SyntaxToken>> {
195 let token_id = self.exp_map.token_by_range(token.value.text_range())?; 195 let token_id = self.exp_map.token_by_range(token.value.text_range())?;
196 196
197 let (token_id, origin) = self.macro_def.0.map_id_up(token_id); 197 let (token_id, origin) = self.macro_def.0.map_id_up(token_id);
@@ -214,73 +214,42 @@ impl ExpansionInfo {
214/// 214///
215/// It is stable across reparses, and can be used as salsa key/value. 215/// It is stable across reparses, and can be used as salsa key/value.
216// FIXME: isn't this just a `Source<FileAstId<N>>` ? 216// FIXME: isn't this just a `Source<FileAstId<N>>` ?
217#[derive(Debug)] 217pub type AstId<N> = InFile<FileAstId<N>>;
218pub struct AstId<N: AstNode> {
219 file_id: HirFileId,
220 file_ast_id: FileAstId<N>,
221}
222
223impl<N: AstNode> Clone for AstId<N> {
224 fn clone(&self) -> AstId<N> {
225 *self
226 }
227}
228impl<N: AstNode> Copy for AstId<N> {}
229
230impl<N: AstNode> PartialEq for AstId<N> {
231 fn eq(&self, other: &Self) -> bool {
232 (self.file_id, self.file_ast_id) == (other.file_id, other.file_ast_id)
233 }
234}
235impl<N: AstNode> Eq for AstId<N> {}
236impl<N: AstNode> Hash for AstId<N> {
237 fn hash<H: Hasher>(&self, hasher: &mut H) {
238 (self.file_id, self.file_ast_id).hash(hasher);
239 }
240}
241 218
242impl<N: AstNode> AstId<N> { 219impl<N: AstNode> AstId<N> {
243 pub fn new(file_id: HirFileId, file_ast_id: FileAstId<N>) -> AstId<N> {
244 AstId { file_id, file_ast_id }
245 }
246
247 pub fn file_id(&self) -> HirFileId {
248 self.file_id
249 }
250
251 pub fn to_node(&self, db: &dyn db::AstDatabase) -> N { 220 pub fn to_node(&self, db: &dyn db::AstDatabase) -> N {
252 let root = db.parse_or_expand(self.file_id).unwrap(); 221 let root = db.parse_or_expand(self.file_id).unwrap();
253 db.ast_id_map(self.file_id).get(self.file_ast_id).to_node(&root) 222 db.ast_id_map(self.file_id).get(self.value).to_node(&root)
254 } 223 }
255} 224}
256 225
257/// `Source<T>` stores a value of `T` inside a particular file/syntax tree. 226/// `InFile<T>` stores a value of `T` inside a particular file/syntax tree.
258/// 227///
259/// Typical usages are: 228/// Typical usages are:
260/// 229///
261/// * `Source<SyntaxNode>` -- syntax node in a file 230/// * `InFile<SyntaxNode>` -- syntax node in a file
262/// * `Source<ast::FnDef>` -- ast node in a file 231/// * `InFile<ast::FnDef>` -- ast node in a file
263/// * `Source<TextUnit>` -- offset in a file 232/// * `InFile<TextUnit>` -- offset in a file
264#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] 233#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
265pub struct Source<T> { 234pub struct InFile<T> {
266 pub file_id: HirFileId, 235 pub file_id: HirFileId,
267 pub value: T, 236 pub value: T,
268} 237}
269 238
270impl<T> Source<T> { 239impl<T> InFile<T> {
271 pub fn new(file_id: HirFileId, value: T) -> Source<T> { 240 pub fn new(file_id: HirFileId, value: T) -> InFile<T> {
272 Source { file_id, value } 241 InFile { file_id, value }
273 } 242 }
274 243
275 // Similarly, naming here is stupid... 244 // Similarly, naming here is stupid...
276 pub fn with_value<U>(&self, value: U) -> Source<U> { 245 pub fn with_value<U>(&self, value: U) -> InFile<U> {
277 Source::new(self.file_id, value) 246 InFile::new(self.file_id, value)
278 } 247 }
279 248
280 pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { 249 pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> InFile<U> {
281 Source::new(self.file_id, f(self.value)) 250 InFile::new(self.file_id, f(self.value))
282 } 251 }
283 pub fn as_ref(&self) -> Source<&T> { 252 pub fn as_ref(&self) -> InFile<&T> {
284 self.with_value(&self.value) 253 self.with_value(&self.value)
285 } 254 }
286 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { 255 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode {
diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs
index 7824489d7..05ba37070 100644
--- a/crates/ra_hir_expand/src/name.rs
+++ b/crates/ra_hir_expand/src/name.rs
@@ -140,6 +140,12 @@ pub const RESULT_TYPE: Name = Name::new_inline_ascii(6, b"Result");
140pub const OUTPUT_TYPE: Name = Name::new_inline_ascii(6, b"Output"); 140pub const OUTPUT_TYPE: Name = Name::new_inline_ascii(6, b"Output");
141pub const TARGET_TYPE: Name = Name::new_inline_ascii(6, b"Target"); 141pub const TARGET_TYPE: Name = Name::new_inline_ascii(6, b"Target");
142pub const BOX_TYPE: Name = Name::new_inline_ascii(3, b"Box"); 142pub const BOX_TYPE: Name = Name::new_inline_ascii(3, b"Box");
143pub const RANGE_FROM_TYPE: Name = Name::new_inline_ascii(9, b"RangeFrom");
144pub const RANGE_FULL_TYPE: Name = Name::new_inline_ascii(9, b"RangeFull");
145pub const RANGE_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(14, b"RangeInclusive");
146pub const RANGE_TO_INCLUSIVE_TYPE: Name = Name::new_inline_ascii(16, b"RangeToInclusive");
147pub const RANGE_TO_TYPE: Name = Name::new_inline_ascii(7, b"RangeTo");
148pub const RANGE_TYPE: Name = Name::new_inline_ascii(5, b"Range");
143 149
144// Builtin Macros 150// Builtin Macros
145pub const FILE_MACRO: Name = Name::new_inline_ascii(4, b"file"); 151pub const FILE_MACRO: Name = Name::new_inline_ascii(4, b"file");
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index 9ce154593..222a36a9f 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -11,7 +11,7 @@ use ra_db::{salsa, CrateId};
11use crate::{ 11use crate::{
12 method_resolution::CrateImplBlocks, 12 method_resolution::CrateImplBlocks,
13 traits::{AssocTyValue, Impl}, 13 traits::{AssocTyValue, Impl},
14 CallableDef, FnSig, GenericPredicate, ImplTy, InferenceResult, Substs, Ty, TyDefId, TypeCtor, 14 CallableDef, FnSig, GenericPredicate, InferenceResult, Substs, TraitRef, Ty, TyDefId, TypeCtor,
15 ValueTyDefId, 15 ValueTyDefId,
16}; 16};
17 17
@@ -22,13 +22,18 @@ pub trait HirDatabase: DefDatabase {
22 fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>; 22 fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
23 23
24 #[salsa::invoke(crate::lower::ty_query)] 24 #[salsa::invoke(crate::lower::ty_query)]
25 #[salsa::cycle(crate::lower::ty_recover)]
25 fn ty(&self, def: TyDefId) -> Ty; 26 fn ty(&self, def: TyDefId) -> Ty;
26 27
27 #[salsa::invoke(crate::lower::value_ty_query)] 28 #[salsa::invoke(crate::lower::value_ty_query)]
28 fn value_ty(&self, def: ValueTyDefId) -> Ty; 29 fn value_ty(&self, def: ValueTyDefId) -> Ty;
29 30
30 #[salsa::invoke(crate::lower::impl_ty_query)] 31 #[salsa::invoke(crate::lower::impl_self_ty_query)]
31 fn impl_ty(&self, def: ImplId) -> ImplTy; 32 #[salsa::cycle(crate::lower::impl_self_ty_recover)]
33 fn impl_self_ty(&self, def: ImplId) -> Ty;
34
35 #[salsa::invoke(crate::lower::impl_trait_query)]
36 fn impl_trait(&self, def: ImplId) -> Option<TraitRef>;
32 37
33 #[salsa::invoke(crate::lower::field_types_query)] 38 #[salsa::invoke(crate::lower::field_types_query)]
34 fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>; 39 fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalStructFieldId, Ty>>;
@@ -37,6 +42,7 @@ pub trait HirDatabase: DefDatabase {
37 fn callable_item_signature(&self, def: CallableDef) -> FnSig; 42 fn callable_item_signature(&self, def: CallableDef) -> FnSig;
38 43
39 #[salsa::invoke(crate::lower::generic_predicates_for_param_query)] 44 #[salsa::invoke(crate::lower::generic_predicates_for_param_query)]
45 #[salsa::cycle(crate::lower::generic_predicates_for_param_recover)]
40 fn generic_predicates_for_param( 46 fn generic_predicates_for_param(
41 &self, 47 &self,
42 def: GenericDefId, 48 def: GenericDefId,
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 4a13fac23..5054189cc 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -2,7 +2,7 @@
2 2
3use std::any::Any; 3use std::any::Any;
4 4
5use hir_expand::{db::AstDatabase, name::Name, HirFileId, Source}; 5use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile};
6use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; 6use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr};
7 7
8pub use hir_def::diagnostics::UnresolvedModule; 8pub use hir_def::diagnostics::UnresolvedModule;
@@ -19,8 +19,8 @@ impl Diagnostic for NoSuchField {
19 "no such field".to_string() 19 "no such field".to_string()
20 } 20 }
21 21
22 fn source(&self) -> Source<SyntaxNodePtr> { 22 fn source(&self) -> InFile<SyntaxNodePtr> {
23 Source { file_id: self.file, value: self.field.into() } 23 InFile { file_id: self.file, value: self.field.into() }
24 } 24 }
25 25
26 fn as_any(&self) -> &(dyn Any + Send + 'static) { 26 fn as_any(&self) -> &(dyn Any + Send + 'static) {
@@ -44,8 +44,8 @@ impl Diagnostic for MissingFields {
44 } 44 }
45 message 45 message
46 } 46 }
47 fn source(&self) -> Source<SyntaxNodePtr> { 47 fn source(&self) -> InFile<SyntaxNodePtr> {
48 Source { file_id: self.file, value: self.field_list.into() } 48 InFile { file_id: self.file, value: self.field_list.into() }
49 } 49 }
50 fn as_any(&self) -> &(dyn Any + Send + 'static) { 50 fn as_any(&self) -> &(dyn Any + Send + 'static) {
51 self 51 self
@@ -72,8 +72,8 @@ impl Diagnostic for MissingOkInTailExpr {
72 fn message(&self) -> String { 72 fn message(&self) -> String {
73 "wrap return expression in Ok".to_string() 73 "wrap return expression in Ok".to_string()
74 } 74 }
75 fn source(&self) -> Source<SyntaxNodePtr> { 75 fn source(&self) -> InFile<SyntaxNodePtr> {
76 Source { file_id: self.file, value: self.expr.into() } 76 InFile { file_id: self.file, value: self.expr.into() }
77 } 77 }
78 fn as_any(&self) -> &(dyn Any + Send + 'static) { 78 fn as_any(&self) -> &(dyn Any + Send + 'static) {
79 self 79 self
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index 1e9f4b208..fe259371f 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -577,6 +577,42 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
577 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?; 577 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
578 Some(struct_.into()) 578 Some(struct_.into())
579 } 579 }
580
581 fn resolve_range_full(&self) -> Option<AdtId> {
582 let path = known::std_ops_range_full();
583 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
584 Some(struct_.into())
585 }
586
587 fn resolve_range(&self) -> Option<AdtId> {
588 let path = known::std_ops_range();
589 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
590 Some(struct_.into())
591 }
592
593 fn resolve_range_inclusive(&self) -> Option<AdtId> {
594 let path = known::std_ops_range_inclusive();
595 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
596 Some(struct_.into())
597 }
598
599 fn resolve_range_from(&self) -> Option<AdtId> {
600 let path = known::std_ops_range_from();
601 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
602 Some(struct_.into())
603 }
604
605 fn resolve_range_to(&self) -> Option<AdtId> {
606 let path = known::std_ops_range_to();
607 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
608 Some(struct_.into())
609 }
610
611 fn resolve_range_to_inclusive(&self) -> Option<AdtId> {
612 let path = known::std_ops_range_to_inclusive();
613 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
614 Some(struct_.into())
615 }
580} 616}
581 617
582/// The ID of a type variable. 618/// The ID of a type variable.
@@ -693,7 +729,7 @@ impl Expectation {
693} 729}
694 730
695mod diagnostics { 731mod diagnostics {
696 use hir_def::{expr::ExprId, FunctionId, HasSource, Lookup}; 732 use hir_def::{expr::ExprId, src::HasSource, FunctionId, Lookup};
697 use hir_expand::diagnostics::DiagnosticSink; 733 use hir_expand::diagnostics::DiagnosticSink;
698 734
699 use crate::{db::HirDatabase, diagnostics::NoSuchField}; 735 use crate::{db::HirDatabase, diagnostics::NoSuchField};
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs
index 719a0f395..064993d34 100644
--- a/crates/ra_hir_ty/src/infer/coerce.rs
+++ b/crates/ra_hir_ty/src/infer/coerce.rs
@@ -8,7 +8,7 @@ use hir_def::{lang_item::LangItemTarget, resolver::Resolver, type_ref::Mutabilit
8use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
9use test_utils::tested_by; 9use test_utils::tested_by;
10 10
11use crate::{autoderef, db::HirDatabase, ImplTy, Substs, Ty, TypeCtor, TypeWalk}; 11use crate::{autoderef, db::HirDatabase, Substs, Ty, TypeCtor, TypeWalk};
12 12
13use super::{InEnvironment, InferTy, InferenceContext, TypeVarValue}; 13use super::{InEnvironment, InferTy, InferenceContext, TypeVarValue};
14 14
@@ -54,10 +54,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
54 impls 54 impls
55 .iter() 55 .iter()
56 .filter_map(|&impl_id| { 56 .filter_map(|&impl_id| {
57 let trait_ref = match db.impl_ty(impl_id) { 57 let trait_ref = db.impl_trait(impl_id)?;
58 ImplTy::TraitRef(it) => it,
59 ImplTy::Inherent(_) => return None,
60 };
61 58
62 // `CoerseUnsized` has one generic parameter for the target type. 59 // `CoerseUnsized` has one generic parameter for the target type.
63 let cur_from_ty = trait_ref.substs.0.get(0)?; 60 let cur_from_ty = trait_ref.substs.0.get(0)?;
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 2f9ca4bbb..4014f4732 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -12,6 +12,7 @@ use hir_def::{
12 AdtId, ContainerId, Lookup, StructFieldId, 12 AdtId, ContainerId, Lookup, StructFieldId,
13}; 13};
14use hir_expand::name::{self, Name}; 14use hir_expand::name::{self, Name};
15use ra_syntax::ast::RangeOp;
15 16
16use crate::{ 17use crate::{
17 autoderef, db::HirDatabase, method_resolution, op, traits::InEnvironment, utils::variant_data, 18 autoderef, db::HirDatabase, method_resolution, op, traits::InEnvironment, utils::variant_data,
@@ -415,6 +416,44 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
415 } 416 }
416 _ => Ty::Unknown, 417 _ => Ty::Unknown,
417 }, 418 },
419 Expr::Range { lhs, rhs, range_type } => {
420 let lhs_ty = lhs.map(|e| self.infer_expr(e, &Expectation::none()));
421 let rhs_expect = lhs_ty
422 .as_ref()
423 .map_or_else(Expectation::none, |ty| Expectation::has_type(ty.clone()));
424 let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect));
425 match (range_type, lhs_ty, rhs_ty) {
426 (RangeOp::Exclusive, None, None) => match self.resolve_range_full() {
427 Some(adt) => Ty::simple(TypeCtor::Adt(adt)),
428 None => Ty::Unknown,
429 },
430 (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() {
431 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
432 None => Ty::Unknown,
433 },
434 (RangeOp::Inclusive, None, Some(ty)) => {
435 match self.resolve_range_to_inclusive() {
436 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
437 None => Ty::Unknown,
438 }
439 }
440 (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() {
441 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
442 None => Ty::Unknown,
443 },
444 (RangeOp::Inclusive, Some(_), Some(ty)) => {
445 match self.resolve_range_inclusive() {
446 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
447 None => Ty::Unknown,
448 }
449 }
450 (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() {
451 Some(adt) => Ty::apply_one(TypeCtor::Adt(adt), ty),
452 None => Ty::Unknown,
453 },
454 (RangeOp::Inclusive, _, None) => Ty::Unknown,
455 }
456 }
418 Expr::Index { base, index } => { 457 Expr::Index { base, index } => {
419 let _base_ty = self.infer_expr(*base, &Expectation::none()); 458 let _base_ty = self.infer_expr(*base, &Expectation::none());
420 let _index_ty = self.infer_expr(*index, &Expectation::none()); 459 let _index_ty = self.infer_expr(*index, &Expectation::none());
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index 14be66836..bbf146418 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -244,7 +244,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
244 ContainerId::ImplId(it) => it, 244 ContainerId::ImplId(it) => it,
245 _ => return None, 245 _ => return None,
246 }; 246 };
247 let self_ty = self.db.impl_ty(impl_id).self_type().clone(); 247 let self_ty = self.db.impl_self_ty(impl_id).clone();
248 let self_ty_substs = self_ty.substs()?; 248 let self_ty_substs = self_ty.substs()?;
249 let actual_substs = actual_def_ty.substs()?; 249 let actual_substs = actual_def_ty.substs()?;
250 250
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index b45c8f82f..3c1f738df 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -486,21 +486,6 @@ impl TypeWalk for TraitRef {
486 } 486 }
487} 487}
488 488
489#[derive(Clone, PartialEq, Eq, Debug)]
490pub enum ImplTy {
491 Inherent(Ty),
492 TraitRef(TraitRef),
493}
494
495impl ImplTy {
496 pub(crate) fn self_type(&self) -> &Ty {
497 match self {
498 ImplTy::Inherent(it) => it,
499 ImplTy::TraitRef(tr) => &tr.substs[0],
500 }
501 }
502}
503
504/// Like `generics::WherePredicate`, but with resolved types: A condition on the 489/// Like `generics::WherePredicate`, but with resolved types: A condition on the
505/// parameters of a generic item. 490/// parameters of a generic item.
506#[derive(Debug, Clone, PartialEq, Eq, Hash)] 491#[derive(Debug, Clone, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 091c60f4f..32569ac66 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -27,8 +27,8 @@ use crate::{
27 all_super_traits, associated_type_by_name_including_super_traits, make_mut_slice, 27 all_super_traits, associated_type_by_name_including_super_traits, make_mut_slice,
28 variant_data, 28 variant_data,
29 }, 29 },
30 FnSig, GenericPredicate, ImplTy, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, 30 FnSig, GenericPredicate, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, TraitRef,
31 TraitRef, Ty, TypeCtor, TypeWalk, 31 Ty, TypeCtor, TypeWalk,
32}; 32};
33 33
34impl Ty { 34impl Ty {
@@ -179,7 +179,7 @@ impl Ty {
179 let name = resolved_segment.name.clone(); 179 let name = resolved_segment.name.clone();
180 Ty::Param { idx, name } 180 Ty::Param { idx, name }
181 } 181 }
182 TypeNs::SelfType(impl_id) => db.impl_ty(impl_id).self_type().clone(), 182 TypeNs::SelfType(impl_id) => db.impl_self_ty(impl_id).clone(),
183 TypeNs::AdtSelfType(adt) => db.ty(adt.into()), 183 TypeNs::AdtSelfType(adt) => db.ty(adt.into()),
184 184
185 TypeNs::AdtId(it) => Ty::from_hir_path_inner(db, resolver, resolved_segment, it.into()), 185 TypeNs::AdtId(it) => Ty::from_hir_path_inner(db, resolver, resolved_segment, it.into()),
@@ -532,6 +532,15 @@ pub(crate) fn generic_predicates_for_param_query(
532 .collect() 532 .collect()
533} 533}
534 534
535pub(crate) fn generic_predicates_for_param_recover(
536 _db: &impl HirDatabase,
537 _cycle: &[String],
538 _def: &GenericDefId,
539 _param_idx: &u32,
540) -> Arc<[GenericPredicate]> {
541 Arc::new([])
542}
543
535impl TraitEnvironment { 544impl TraitEnvironment {
536 pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc<TraitEnvironment> { 545 pub fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc<TraitEnvironment> {
537 let predicates = resolver 546 let predicates = resolver
@@ -733,6 +742,11 @@ pub(crate) fn ty_query(db: &impl HirDatabase, def: TyDefId) -> Ty {
733 TyDefId::TypeAliasId(it) => type_for_type_alias(db, it), 742 TyDefId::TypeAliasId(it) => type_for_type_alias(db, it),
734 } 743 }
735} 744}
745
746pub(crate) fn ty_recover(_db: &impl HirDatabase, _cycle: &[String], _def: &TyDefId) -> Ty {
747 Ty::Unknown
748}
749
736pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty { 750pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty {
737 match def { 751 match def {
738 ValueTyDefId::FunctionId(it) => type_for_fn(db, it), 752 ValueTyDefId::FunctionId(it) => type_for_fn(db, it),
@@ -743,17 +757,24 @@ pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty {
743 } 757 }
744} 758}
745 759
746pub(crate) fn impl_ty_query(db: &impl HirDatabase, impl_id: ImplId) -> ImplTy { 760pub(crate) fn impl_self_ty_query(db: &impl HirDatabase, impl_id: ImplId) -> Ty {
747 let impl_data = db.impl_data(impl_id); 761 let impl_data = db.impl_data(impl_id);
748 let resolver = impl_id.resolver(db); 762 let resolver = impl_id.resolver(db);
749 let self_ty = Ty::from_hir(db, &resolver, &impl_data.target_type); 763 Ty::from_hir(db, &resolver, &impl_data.target_type)
750 match impl_data.target_trait.as_ref() { 764}
751 Some(trait_ref) => { 765
752 match TraitRef::from_hir(db, &resolver, trait_ref, Some(self_ty.clone())) { 766pub(crate) fn impl_self_ty_recover(
753 Some(it) => ImplTy::TraitRef(it), 767 _db: &impl HirDatabase,
754 None => ImplTy::Inherent(self_ty), 768 _cycle: &[String],
755 } 769 _impl_id: &ImplId,
756 } 770) -> Ty {
757 None => ImplTy::Inherent(self_ty), 771 Ty::Unknown
758 } 772}
773
774pub(crate) fn impl_trait_query(db: &impl HirDatabase, impl_id: ImplId) -> Option<TraitRef> {
775 let impl_data = db.impl_data(impl_id);
776 let resolver = impl_id.resolver(db);
777 let self_ty = db.impl_self_ty(impl_id);
778 let target_trait = impl_data.target_trait.as_ref()?;
779 TraitRef::from_hir(db, &resolver, target_trait, Some(self_ty.clone()))
759} 780}
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index ee1936b0e..2bded3dbd 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -19,7 +19,7 @@ use crate::{
19 db::HirDatabase, 19 db::HirDatabase,
20 primitive::{FloatBitness, Uncertain}, 20 primitive::{FloatBitness, Uncertain},
21 utils::all_super_traits, 21 utils::all_super_traits,
22 Canonical, ImplTy, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor, 22 Canonical, InEnvironment, TraitEnvironment, TraitRef, Ty, TypeCtor,
23}; 23};
24 24
25/// This is used as a key for indexing impls. 25/// This is used as a key for indexing impls.
@@ -58,11 +58,12 @@ impl CrateImplBlocks {
58 let crate_def_map = db.crate_def_map(krate); 58 let crate_def_map = db.crate_def_map(krate);
59 for (_module_id, module_data) in crate_def_map.modules.iter() { 59 for (_module_id, module_data) in crate_def_map.modules.iter() {
60 for &impl_id in module_data.impls.iter() { 60 for &impl_id in module_data.impls.iter() {
61 match db.impl_ty(impl_id) { 61 match db.impl_trait(impl_id) {
62 ImplTy::TraitRef(tr) => { 62 Some(tr) => {
63 res.impls_by_trait.entry(tr.trait_).or_default().push(impl_id); 63 res.impls_by_trait.entry(tr.trait_).or_default().push(impl_id);
64 } 64 }
65 ImplTy::Inherent(self_ty) => { 65 None => {
66 let self_ty = db.impl_self_ty(impl_id);
66 if let Some(self_ty_fp) = TyFingerprint::for_impl(&self_ty) { 67 if let Some(self_ty_fp) = TyFingerprint::for_impl(&self_ty) {
67 res.impls.entry(self_ty_fp).or_default().push(impl_id); 68 res.impls.entry(self_ty_fp).or_default().push(impl_id);
68 } 69 }
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index c8461b447..a3cc5cf95 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -8,7 +8,7 @@ use hir_def::{
8 body::BodySourceMap, db::DefDatabase, nameres::CrateDefMap, AssocItemId, DefWithBodyId, 8 body::BodySourceMap, db::DefDatabase, nameres::CrateDefMap, AssocItemId, DefWithBodyId,
9 LocalModuleId, Lookup, ModuleDefId, 9 LocalModuleId, Lookup, ModuleDefId,
10}; 10};
11use hir_expand::Source; 11use hir_expand::InFile;
12use insta::assert_snapshot; 12use insta::assert_snapshot;
13use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase}; 13use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase};
14use ra_syntax::{ 14use ra_syntax::{
@@ -222,6 +222,56 @@ mod collections {
222} 222}
223 223
224#[test] 224#[test]
225fn infer_ranges() {
226 let (db, pos) = TestDB::with_position(
227 r#"
228//- /main.rs crate:main deps:std
229fn test() {
230 let a = ..;
231 let b = 1..;
232 let c = ..2u32;
233 let d = 1..2usize;
234 let e = ..=10;
235 let f = 'a'..='z';
236
237 let t = (a, b, c, d, e, f);
238 t<|>;
239}
240
241//- /std.rs crate:std
242#[prelude_import] use prelude::*;
243mod prelude {}
244
245pub mod ops {
246 pub struct Range<Idx> {
247 pub start: Idx,
248 pub end: Idx,
249 }
250 pub struct RangeFrom<Idx> {
251 pub start: Idx,
252 }
253 struct RangeFull;
254 pub struct RangeInclusive<Idx> {
255 start: Idx,
256 end: Idx,
257 is_empty: u8,
258 }
259 pub struct RangeTo<Idx> {
260 pub end: Idx,
261 }
262 pub struct RangeToInclusive<Idx> {
263 pub end: Idx,
264 }
265}
266"#,
267 );
268 assert_eq!(
269 "(RangeFull, RangeFrom<i32>, RangeTo<u32>, Range<usize>, RangeToInclusive<i32>, RangeInclusive<char>)",
270 type_at_pos(&db, pos),
271 );
272}
273
274#[test]
225fn infer_while_let() { 275fn infer_while_let() {
226 let (db, pos) = TestDB::with_position( 276 let (db, pos) = TestDB::with_position(
227 r#" 277 r#"
@@ -2104,7 +2154,6 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
2104} 2154}
2105 2155
2106#[test] 2156#[test]
2107#[should_panic] // we currently can't handle this
2108fn recursive_type_alias() { 2157fn recursive_type_alias() {
2109 assert_snapshot!( 2158 assert_snapshot!(
2110 infer(r#" 2159 infer(r#"
@@ -2113,7 +2162,10 @@ type Foo = Foo;
2113type Bar = A<Bar>; 2162type Bar = A<Bar>;
2114fn test(x: Foo) {} 2163fn test(x: Foo) {}
2115"#), 2164"#),
2116 @"" 2165 @r###"
2166 [59; 60) 'x': {unknown}
2167 [67; 69) '{}': ()
2168 "###
2117 ) 2169 )
2118} 2170}
2119 2171
@@ -3642,6 +3694,42 @@ fn main() {
3642} 3694}
3643 3695
3644#[test] 3696#[test]
3697fn not_shadowing_primitive_by_module() {
3698 let t = type_at(
3699 r#"
3700//- /str.rs
3701fn foo() {}
3702
3703//- /main.rs
3704mod str;
3705fn foo() -> &'static str { "" }
3706
3707fn main() {
3708 foo()<|>;
3709}"#,
3710 );
3711 assert_eq!(t, "&str");
3712}
3713
3714#[test]
3715fn not_shadowing_module_by_primitive() {
3716 let t = type_at(
3717 r#"
3718//- /str.rs
3719fn foo() -> u32 {0}
3720
3721//- /main.rs
3722mod str;
3723fn foo() -> &'static str { "" }
3724
3725fn main() {
3726 str::foo()<|>;
3727}"#,
3728 );
3729 assert_eq!(t, "u32");
3730}
3731
3732#[test]
3645fn deref_trait() { 3733fn deref_trait() {
3646 let t = type_at( 3734 let t = type_at(
3647 r#" 3735 r#"
@@ -4626,10 +4714,48 @@ fn test<T, U>() where T::Item: Trait2, T: Trait<U::Item>, U: Trait<()> {
4626} 4714}
4627 4715
4628#[test] 4716#[test]
4629// FIXME this is currently a Salsa panic; it would be nicer if it just returned 4717fn trait_impl_self_ty() {
4630// in Unknown, and we should be able to do that once Salsa allows us to handle 4718 let t = type_at(
4631// the cycle. But at least it doesn't overflow for now. 4719 r#"
4632#[should_panic] 4720//- /main.rs
4721trait Trait<T> {
4722 fn foo(&self);
4723}
4724
4725struct S;
4726
4727impl Trait<Self> for S {}
4728
4729fn test() {
4730 S.foo()<|>;
4731}
4732"#,
4733 );
4734 assert_eq!(t, "()");
4735}
4736
4737#[test]
4738fn trait_impl_self_ty_cycle() {
4739 let t = type_at(
4740 r#"
4741//- /main.rs
4742trait Trait {
4743 fn foo(&self);
4744}
4745
4746struct S<T>;
4747
4748impl Trait for S<Self> {}
4749
4750fn test() {
4751 S.foo()<|>;
4752}
4753"#,
4754 );
4755 assert_eq!(t, "{unknown}");
4756}
4757
4758#[test]
4633fn unselected_projection_in_trait_env_cycle_1() { 4759fn unselected_projection_in_trait_env_cycle_1() {
4634 let t = type_at( 4760 let t = type_at(
4635 r#" 4761 r#"
@@ -4650,10 +4776,6 @@ fn test<T: Trait>() where T: Trait2<T::Item> {
4650} 4776}
4651 4777
4652#[test] 4778#[test]
4653// FIXME this is currently a Salsa panic; it would be nicer if it just returned
4654// in Unknown, and we should be able to do that once Salsa allows us to handle
4655// the cycle. But at least it doesn't overflow for now.
4656#[should_panic]
4657fn unselected_projection_in_trait_env_cycle_2() { 4779fn unselected_projection_in_trait_env_cycle_2() {
4658 let t = type_at( 4780 let t = type_at(
4659 r#" 4781 r#"
@@ -4680,7 +4802,7 @@ fn type_at_pos(db: &TestDB, pos: FilePosition) -> String {
4680 for decl in crate_def_map[module.local_id].scope.declarations() { 4802 for decl in crate_def_map[module.local_id].scope.declarations() {
4681 if let ModuleDefId::FunctionId(func) = decl { 4803 if let ModuleDefId::FunctionId(func) = decl {
4682 let (_body, source_map) = db.body_with_source_map(func.into()); 4804 let (_body, source_map) = db.body_with_source_map(func.into());
4683 if let Some(expr_id) = source_map.node_expr(Source::new(pos.file_id.into(), &expr)) { 4805 if let Some(expr_id) = source_map.node_expr(InFile::new(pos.file_id.into(), &expr)) {
4684 let infer = db.infer(func.into()); 4806 let infer = db.infer(func.into());
4685 let ty = &infer[expr_id]; 4807 let ty = &infer[expr_id];
4686 return ty.display(db).to_string(); 4808 return ty.display(db).to_string();
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 35de37e6b..104346ada 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -20,8 +20,8 @@ use ra_db::salsa::{InternId, InternKey};
20 20
21use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation}; 21use super::{AssocTyValue, Canonical, ChalkContext, Impl, Obligation};
22use crate::{ 22use crate::{
23 db::HirDatabase, display::HirDisplay, ApplicationTy, GenericPredicate, ImplTy, ProjectionTy, 23 db::HirDatabase, display::HirDisplay, ApplicationTy, GenericPredicate, ProjectionTy, Substs,
24 Substs, TraitRef, Ty, TypeCtor, TypeWalk, 24 TraitRef, Ty, TypeCtor, TypeWalk,
25}; 25};
26 26
27/// This represents a trait whose name we could not resolve. 27/// This represents a trait whose name we could not resolve.
@@ -630,10 +630,7 @@ fn impl_block_datum(
630 chalk_id: chalk_ir::ImplId, 630 chalk_id: chalk_ir::ImplId,
631 impl_id: ImplId, 631 impl_id: ImplId,
632) -> Option<Arc<ImplDatum<ChalkIr>>> { 632) -> Option<Arc<ImplDatum<ChalkIr>>> {
633 let trait_ref = match db.impl_ty(impl_id) { 633 let trait_ref = db.impl_trait(impl_id)?;
634 ImplTy::TraitRef(it) => it,
635 ImplTy::Inherent(_) => return None,
636 };
637 let impl_data = db.impl_data(impl_id); 634 let impl_data = db.impl_data(impl_id);
638 635
639 let generic_params = db.generic_params(impl_id.into()); 636 let generic_params = db.generic_params(impl_id.into());
@@ -787,11 +784,7 @@ fn type_alias_associated_ty_value(
787 _ => panic!("assoc ty value should be in impl"), 784 _ => panic!("assoc ty value should be in impl"),
788 }; 785 };
789 786
790 let trait_ref = match db.impl_ty(impl_id) { 787 let trait_ref = db.impl_trait(impl_id).expect("assoc ty value should not exist"); // we don't return any assoc ty values if the impl'd trait can't be resolved
791 ImplTy::TraitRef(it) => it,
792 // we don't return any assoc ty values if the impl'd trait can't be resolved
793 ImplTy::Inherent(_) => panic!("assoc ty value should not exist"),
794 };
795 788
796 let assoc_ty = db 789 let assoc_ty = db
797 .trait_data(trait_ref.trait_) 790 .trait_data(trait_ref.trait_)
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index d559dc4d0..b3c323d38 100644
--- a/crates/ra_ide/src/call_info.rs
+++ b/crates/ra_ide/src/call_info.rs
@@ -18,7 +18,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
18 // Find the calling expression and it's NameRef 18 // Find the calling expression and it's NameRef
19 let calling_node = FnCallNode::with_node(&syntax, position.offset)?; 19 let calling_node = FnCallNode::with_node(&syntax, position.offset)?;
20 let name_ref = calling_node.name_ref()?; 20 let name_ref = calling_node.name_ref()?;
21 let name_ref = hir::Source::new(position.file_id.into(), name_ref.syntax()); 21 let name_ref = hir::InFile::new(position.file_id.into(), name_ref.syntax());
22 22
23 let analyzer = hir::SourceAnalyzer::new(db, name_ref, None); 23 let analyzer = hir::SourceAnalyzer::new(db, name_ref, None);
24 let (mut call_info, has_self) = match &calling_node { 24 let (mut call_info, has_self) = match &calling_node {
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index b8345c91d..ca0a483d4 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -54,13 +54,13 @@ impl<'a> CompletionContext<'a> {
54 let src = hir::ModuleSource::from_position(db, position); 54 let src = hir::ModuleSource::from_position(db, position);
55 let module = hir::Module::from_definition( 55 let module = hir::Module::from_definition(
56 db, 56 db,
57 hir::Source { file_id: position.file_id.into(), value: src }, 57 hir::InFile { file_id: position.file_id.into(), value: src },
58 ); 58 );
59 let token = 59 let token =
60 original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?; 60 original_parse.tree().syntax().token_at_offset(position.offset).left_biased()?;
61 let analyzer = hir::SourceAnalyzer::new( 61 let analyzer = hir::SourceAnalyzer::new(
62 db, 62 db,
63 hir::Source::new(position.file_id.into(), &token.parent()), 63 hir::InFile::new(position.file_id.into(), &token.parent()),
64 Some(position.offset), 64 Some(position.offset),
65 ); 65 );
66 let mut ctx = CompletionContext { 66 let mut ctx = CompletionContext {
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index cc1ccab4b..c50a70d99 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -96,7 +96,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
96 }); 96 });
97 let source_file = db.parse(file_id).tree(); 97 let source_file = db.parse(file_id).tree();
98 let src = 98 let src =
99 hir::Source { file_id: file_id.into(), value: hir::ModuleSource::SourceFile(source_file) }; 99 hir::InFile { file_id: file_id.into(), value: hir::ModuleSource::SourceFile(source_file) };
100 if let Some(m) = hir::Module::from_definition(db, src) { 100 if let Some(m) = hir::Module::from_definition(db, src) {
101 m.diagnostics(db, &mut sink); 101 m.diagnostics(db, &mut sink);
102 }; 102 };
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index 6ac60722b..61dca14ac 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{AssocItem, Either, FieldSource, HasSource, ModuleSource, Source}; 3use hir::{AssocItem, Either, FieldSource, HasSource, InFile, ModuleSource};
4use ra_db::{FileId, SourceDatabase}; 4use ra_db::{FileId, SourceDatabase};
5use ra_syntax::{ 5use ra_syntax::{
6 ast::{self, DocCommentsOwner, NameOwner}, 6 ast::{self, DocCommentsOwner, NameOwner},
@@ -141,7 +141,7 @@ impl NavigationTarget {
141 /// Allows `NavigationTarget` to be created from a `NameOwner` 141 /// Allows `NavigationTarget` to be created from a `NameOwner`
142 pub(crate) fn from_named( 142 pub(crate) fn from_named(
143 db: &RootDatabase, 143 db: &RootDatabase,
144 node: Source<&dyn ast::NameOwner>, 144 node: InFile<&dyn ast::NameOwner>,
145 docs: Option<String>, 145 docs: Option<String>,
146 description: Option<String>, 146 description: Option<String>,
147 ) -> NavigationTarget { 147 ) -> NavigationTarget {
diff --git a/crates/ra_ide/src/expand.rs b/crates/ra_ide/src/expand.rs
index 2f1abf509..216d5cfec 100644
--- a/crates/ra_ide/src/expand.rs
+++ b/crates/ra_ide/src/expand.rs
@@ -1,13 +1,13 @@
1//! Utilities to work with files, produced by macros. 1//! Utilities to work with files, produced by macros.
2use std::iter::successors; 2use std::iter::successors;
3 3
4use hir::Source; 4use hir::InFile;
5use ra_db::FileId; 5use ra_db::FileId;
6use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxToken}; 6use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxToken};
7 7
8use crate::{db::RootDatabase, FileRange}; 8use crate::{db::RootDatabase, FileRange};
9 9
10pub(crate) fn original_range(db: &RootDatabase, node: Source<&SyntaxNode>) -> FileRange { 10pub(crate) fn original_range(db: &RootDatabase, node: InFile<&SyntaxNode>) -> FileRange {
11 let expansion = match node.file_id.expansion_info(db) { 11 let expansion = match node.file_id.expansion_info(db) {
12 None => { 12 None => {
13 return FileRange { 13 return FileRange {
@@ -44,8 +44,8 @@ pub(crate) fn descend_into_macros(
44 db: &RootDatabase, 44 db: &RootDatabase,
45 file_id: FileId, 45 file_id: FileId,
46 token: SyntaxToken, 46 token: SyntaxToken,
47) -> Source<SyntaxToken> { 47) -> InFile<SyntaxToken> {
48 let src = Source::new(file_id.into(), token); 48 let src = InFile::new(file_id.into(), token);
49 49
50 successors(Some(src), |token| { 50 successors(Some(src), |token| {
51 let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; 51 let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?;
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs
index abc602244..862c03304 100644
--- a/crates/ra_ide/src/expand_macro.rs
+++ b/crates/ra_ide/src/expand_macro.rs
@@ -22,7 +22,7 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
22 let name_ref = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)?; 22 let name_ref = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)?;
23 let mac = name_ref.syntax().ancestors().find_map(ast::MacroCall::cast)?; 23 let mac = name_ref.syntax().ancestors().find_map(ast::MacroCall::cast)?;
24 24
25 let source = hir::Source::new(position.file_id.into(), mac.syntax()); 25 let source = hir::InFile::new(position.file_id.into(), mac.syntax());
26 let expanded = expand_macro_recur(db, source, source.with_value(&mac))?; 26 let expanded = expand_macro_recur(db, source, source.with_value(&mac))?;
27 27
28 // FIXME: 28 // FIXME:
@@ -34,8 +34,8 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
34 34
35fn expand_macro_recur( 35fn expand_macro_recur(
36 db: &RootDatabase, 36 db: &RootDatabase,
37 source: hir::Source<&SyntaxNode>, 37 source: hir::InFile<&SyntaxNode>,
38 macro_call: hir::Source<&ast::MacroCall>, 38 macro_call: hir::InFile<&ast::MacroCall>,
39) -> Option<SyntaxNode> { 39) -> Option<SyntaxNode> {
40 let analyzer = hir::SourceAnalyzer::new(db, source, None); 40 let analyzer = hir::SourceAnalyzer::new(db, source, None);
41 let expansion = analyzer.expand(db, macro_call)?; 41 let expansion = analyzer.expand(db, macro_call)?;
@@ -46,7 +46,7 @@ fn expand_macro_recur(
46 let mut replaces = FxHashMap::default(); 46 let mut replaces = FxHashMap::default();
47 47
48 for child in children.into_iter() { 48 for child in children.into_iter() {
49 let node = hir::Source::new(macro_file_id, &child); 49 let node = hir::InFile::new(macro_file_id, &child);
50 if let Some(new_node) = expand_macro_recur(db, source, node) { 50 if let Some(new_node) = expand_macro_recur(db, source, node) {
51 // Replace the whole node if it is root 51 // Replace the whole node if it is root
52 // `replace_descendants` will not replace the parent node 52 // `replace_descendants` will not replace the parent node
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index c10a6c844..76a741207 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::{db::AstDatabase, Source}; 3use hir::{db::AstDatabase, InFile};
4use ra_syntax::{ 4use ra_syntax::{
5 ast::{self, DocCommentsOwner}, 5 ast::{self, DocCommentsOwner},
6 match_ast, AstNode, SyntaxNode, 6 match_ast, AstNode, SyntaxNode,
@@ -58,7 +58,7 @@ impl ReferenceResult {
58 58
59pub(crate) fn reference_definition( 59pub(crate) fn reference_definition(
60 db: &RootDatabase, 60 db: &RootDatabase,
61 name_ref: Source<&ast::NameRef>, 61 name_ref: InFile<&ast::NameRef>,
62) -> ReferenceResult { 62) -> ReferenceResult {
63 use self::ReferenceResult::*; 63 use self::ReferenceResult::*;
64 64
@@ -94,7 +94,7 @@ pub(crate) fn reference_definition(
94 94
95pub(crate) fn name_definition( 95pub(crate) fn name_definition(
96 db: &RootDatabase, 96 db: &RootDatabase,
97 name: Source<&ast::Name>, 97 name: InFile<&ast::Name>,
98) -> Option<Vec<NavigationTarget>> { 98) -> Option<Vec<NavigationTarget>> {
99 let parent = name.value.syntax().parent()?; 99 let parent = name.value.syntax().parent()?;
100 100
@@ -115,7 +115,7 @@ pub(crate) fn name_definition(
115 None 115 None
116} 116}
117 117
118fn named_target(db: &RootDatabase, node: Source<&SyntaxNode>) -> Option<NavigationTarget> { 118fn named_target(db: &RootDatabase, node: InFile<&SyntaxNode>) -> Option<NavigationTarget> {
119 match_ast! { 119 match_ast! {
120 match (node.value) { 120 match (node.value) {
121 ast::StructDef(it) => { 121 ast::StructDef(it) => {
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 260a7b869..d8185c688 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -227,7 +227,7 @@ pub(crate) fn type_of(db: &RootDatabase, frange: FileRange) -> Option<String> {
227 .take_while(|it| it.text_range() == leaf_node.text_range()) 227 .take_while(|it| it.text_range() == leaf_node.text_range())
228 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?; 228 .find(|it| ast::Expr::cast(it.clone()).is_some() || ast::Pat::cast(it.clone()).is_some())?;
229 let analyzer = 229 let analyzer =
230 hir::SourceAnalyzer::new(db, hir::Source::new(frange.file_id.into(), &node), None); 230 hir::SourceAnalyzer::new(db, hir::InFile::new(frange.file_id.into(), &node), None);
231 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e)) 231 let ty = if let Some(ty) = ast::Expr::cast(node.clone()).and_then(|e| analyzer.type_of(db, &e))
232 { 232 {
233 ty 233 ty
diff --git a/crates/ra_ide/src/impls.rs b/crates/ra_ide/src/impls.rs
index aa480e399..9b165ee2a 100644
--- a/crates/ra_ide/src/impls.rs
+++ b/crates/ra_ide/src/impls.rs
@@ -16,7 +16,7 @@ pub(crate) fn goto_implementation(
16 let src = hir::ModuleSource::from_position(db, position); 16 let src = hir::ModuleSource::from_position(db, position);
17 let module = hir::Module::from_definition( 17 let module = hir::Module::from_definition(
18 db, 18 db,
19 hir::Source { file_id: position.file_id.into(), value: src }, 19 hir::InFile { file_id: position.file_id.into(), value: src },
20 )?; 20 )?;
21 21
22 if let Some(nominal_def) = find_node_at_offset::<ast::NominalDef>(&syntax, position.offset) { 22 if let Some(nominal_def) = find_node_at_offset::<ast::NominalDef>(&syntax, position.offset) {
@@ -42,15 +42,15 @@ fn impls_for_def(
42) -> Option<Vec<NavigationTarget>> { 42) -> Option<Vec<NavigationTarget>> {
43 let ty = match node { 43 let ty = match node {
44 ast::NominalDef::StructDef(def) => { 44 ast::NominalDef::StructDef(def) => {
45 let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; 45 let src = hir::InFile { file_id: position.file_id.into(), value: def.clone() };
46 hir::Struct::from_source(db, src)?.ty(db) 46 hir::Struct::from_source(db, src)?.ty(db)
47 } 47 }
48 ast::NominalDef::EnumDef(def) => { 48 ast::NominalDef::EnumDef(def) => {
49 let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; 49 let src = hir::InFile { file_id: position.file_id.into(), value: def.clone() };
50 hir::Enum::from_source(db, src)?.ty(db) 50 hir::Enum::from_source(db, src)?.ty(db)
51 } 51 }
52 ast::NominalDef::UnionDef(def) => { 52 ast::NominalDef::UnionDef(def) => {
53 let src = hir::Source { file_id: position.file_id.into(), value: def.clone() }; 53 let src = hir::InFile { file_id: position.file_id.into(), value: def.clone() };
54 hir::Union::from_source(db, src)?.ty(db) 54 hir::Union::from_source(db, src)?.ty(db)
55 } 55 }
56 }; 56 };
@@ -73,7 +73,7 @@ fn impls_for_trait(
73 node: &ast::TraitDef, 73 node: &ast::TraitDef,
74 module: hir::Module, 74 module: hir::Module,
75) -> Option<Vec<NavigationTarget>> { 75) -> Option<Vec<NavigationTarget>> {
76 let src = hir::Source { file_id: position.file_id.into(), value: node.clone() }; 76 let src = hir::InFile { file_id: position.file_id.into(), value: node.clone() };
77 let tr = hir::Trait::from_source(db, src)?; 77 let tr = hir::Trait::from_source(db, src)?;
78 78
79 let krate = module.krate(); 79 let krate = module.krate();
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 45149bf0c..59eced9d7 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -38,7 +38,7 @@ fn get_inlay_hints(
38 node: &SyntaxNode, 38 node: &SyntaxNode,
39 max_inlay_hint_length: Option<usize>, 39 max_inlay_hint_length: Option<usize>,
40) -> Option<Vec<InlayHint>> { 40) -> Option<Vec<InlayHint>> {
41 let analyzer = SourceAnalyzer::new(db, hir::Source::new(file_id.into(), node), None); 41 let analyzer = SourceAnalyzer::new(db, hir::InFile::new(file_id.into(), node), None);
42 match_ast! { 42 match_ast! {
43 match node { 43 match node {
44 ast::LetStmt(it) => { 44 ast::LetStmt(it) => {
diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs
index 6027e7d54..616d69fce 100644
--- a/crates/ra_ide/src/parent_module.rs
+++ b/crates/ra_ide/src/parent_module.rs
@@ -10,7 +10,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
10 let src = hir::ModuleSource::from_position(db, position); 10 let src = hir::ModuleSource::from_position(db, position);
11 let module = match hir::Module::from_definition( 11 let module = match hir::Module::from_definition(
12 db, 12 db,
13 hir::Source { file_id: position.file_id.into(), value: src }, 13 hir::InFile { file_id: position.file_id.into(), value: src },
14 ) { 14 ) {
15 None => return Vec::new(), 15 None => return Vec::new(),
16 Some(it) => it, 16 Some(it) => it,
@@ -23,7 +23,7 @@ pub(crate) fn parent_module(db: &RootDatabase, position: FilePosition) -> Vec<Na
23pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { 23pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> {
24 let src = hir::ModuleSource::from_file_id(db, file_id); 24 let src = hir::ModuleSource::from_file_id(db, file_id);
25 let module = 25 let module =
26 match hir::Module::from_definition(db, hir::Source { file_id: file_id.into(), value: src }) 26 match hir::Module::from_definition(db, hir::InFile { file_id: file_id.into(), value: src })
27 { 27 {
28 Some(it) => it, 28 Some(it) => it,
29 None => return Vec::new(), 29 None => return Vec::new(),
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index 21a1ea69e..3e7bfd872 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -14,7 +14,7 @@ mod name_definition;
14mod rename; 14mod rename;
15mod search_scope; 15mod search_scope;
16 16
17use hir::Source; 17use hir::InFile;
18use once_cell::unsync::Lazy; 18use once_cell::unsync::Lazy;
19use ra_db::{SourceDatabase, SourceDatabaseExt}; 19use ra_db::{SourceDatabase, SourceDatabaseExt};
20use ra_prof::profile; 20use ra_prof::profile;
@@ -107,12 +107,12 @@ fn find_name<'a>(
107 position: FilePosition, 107 position: FilePosition,
108) -> Option<RangeInfo<(String, NameDefinition)>> { 108) -> Option<RangeInfo<(String, NameDefinition)>> {
109 if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { 109 if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) {
110 let def = classify_name(db, Source::new(position.file_id.into(), &name))?; 110 let def = classify_name(db, InFile::new(position.file_id.into(), &name))?;
111 let range = name.syntax().text_range(); 111 let range = name.syntax().text_range();
112 return Some(RangeInfo::new(range, (name.text().to_string(), def))); 112 return Some(RangeInfo::new(range, (name.text().to_string(), def)));
113 } 113 }
114 let name_ref = find_node_at_offset::<ast::NameRef>(&syntax, position.offset)?; 114 let name_ref = find_node_at_offset::<ast::NameRef>(&syntax, position.offset)?;
115 let def = classify_name_ref(db, Source::new(position.file_id.into(), &name_ref))?; 115 let def = classify_name_ref(db, InFile::new(position.file_id.into(), &name_ref))?;
116 let range = name_ref.syntax().text_range(); 116 let range = name_ref.syntax().text_range();
117 Some(RangeInfo::new(range, (name_ref.text().to_string(), def))) 117 Some(RangeInfo::new(range, (name_ref.text().to_string(), def)))
118} 118}
@@ -144,7 +144,7 @@ fn process_definition(
144 continue; 144 continue;
145 } 145 }
146 } 146 }
147 if let Some(d) = classify_name_ref(db, Source::new(file_id.into(), &name_ref)) { 147 if let Some(d) = classify_name_ref(db, InFile::new(file_id.into(), &name_ref)) {
148 if d == def { 148 if d == def {
149 refs.push(FileRange { file_id, range }); 149 refs.push(FileRange { file_id, range });
150 } 150 }
diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs
index 5cea805ec..b716d32e5 100644
--- a/crates/ra_ide/src/references/classify.rs
+++ b/crates/ra_ide/src/references/classify.rs
@@ -1,6 +1,6 @@
1//! Functions that are used to classify an element from its definition or reference. 1//! Functions that are used to classify an element from its definition or reference.
2 2
3use hir::{FromSource, Module, ModuleSource, PathResolution, Source, SourceAnalyzer}; 3use hir::{FromSource, InFile, Module, ModuleSource, PathResolution, SourceAnalyzer};
4use ra_prof::profile; 4use ra_prof::profile;
5use ra_syntax::{ast, match_ast, AstNode}; 5use ra_syntax::{ast, match_ast, AstNode};
6use test_utils::tested_by; 6use test_utils::tested_by;
@@ -11,7 +11,7 @@ use super::{
11}; 11};
12use crate::db::RootDatabase; 12use crate::db::RootDatabase;
13 13
14pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Option<NameDefinition> { 14pub(crate) fn classify_name(db: &RootDatabase, name: InFile<&ast::Name>) -> Option<NameDefinition> {
15 let _p = profile("classify_name"); 15 let _p = profile("classify_name");
16 let parent = name.value.syntax().parent()?; 16 let parent = name.value.syntax().parent()?;
17 17
@@ -117,7 +117,7 @@ pub(crate) fn classify_name(db: &RootDatabase, name: Source<&ast::Name>) -> Opti
117 117
118pub(crate) fn classify_name_ref( 118pub(crate) fn classify_name_ref(
119 db: &RootDatabase, 119 db: &RootDatabase,
120 name_ref: Source<&ast::NameRef>, 120 name_ref: InFile<&ast::NameRef>,
121) -> Option<NameDefinition> { 121) -> Option<NameDefinition> {
122 let _p = profile("classify_name_ref"); 122 let _p = profile("classify_name_ref");
123 123
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index d58496049..b804d5f6d 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -2,7 +2,7 @@
2 2
3use hir::ModuleSource; 3use hir::ModuleSource;
4use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt}; 4use ra_db::{RelativePath, RelativePathBuf, SourceDatabase, SourceDatabaseExt};
5use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNode}; 5use ra_syntax::{algo::find_node_at_offset, ast, tokenize, AstNode, SyntaxKind, SyntaxNode};
6use ra_text_edit::TextEdit; 6use ra_text_edit::TextEdit;
7 7
8use crate::{ 8use crate::{
@@ -17,6 +17,13 @@ pub(crate) fn rename(
17 position: FilePosition, 17 position: FilePosition,
18 new_name: &str, 18 new_name: &str,
19) -> Option<RangeInfo<SourceChange>> { 19) -> Option<RangeInfo<SourceChange>> {
20 let tokens = tokenize(new_name);
21 if tokens.len() != 1
22 || (tokens[0].kind != SyntaxKind::IDENT && tokens[0].kind != SyntaxKind::UNDERSCORE)
23 {
24 return None;
25 }
26
20 let parse = db.parse(position.file_id); 27 let parse = db.parse(position.file_id);
21 if let Some((ast_name, ast_module)) = 28 if let Some((ast_name, ast_module)) =
22 find_name_and_module_at_offset(parse.tree().syntax(), position) 29 find_name_and_module_at_offset(parse.tree().syntax(), position)
@@ -55,7 +62,7 @@ fn rename_mod(
55) -> Option<SourceChange> { 62) -> Option<SourceChange> {
56 let mut source_file_edits = Vec::new(); 63 let mut source_file_edits = Vec::new();
57 let mut file_system_edits = Vec::new(); 64 let mut file_system_edits = Vec::new();
58 let module_src = hir::Source { file_id: position.file_id.into(), value: ast_module.clone() }; 65 let module_src = hir::InFile { file_id: position.file_id.into(), value: ast_module.clone() };
59 if let Some(module) = hir::Module::from_declaration(db, module_src) { 66 if let Some(module) = hir::Module::from_declaration(db, module_src) {
60 let src = module.definition_source(db); 67 let src = module.definition_source(db);
61 let file_id = src.file_id.original_file(db); 68 let file_id = src.file_id.original_file(db);
@@ -124,6 +131,49 @@ mod tests {
124 }; 131 };
125 132
126 #[test] 133 #[test]
134 fn test_rename_to_underscore() {
135 test_rename(
136 r#"
137 fn main() {
138 let i<|> = 1;
139 }"#,
140 "_",
141 r#"
142 fn main() {
143 let _ = 1;
144 }"#,
145 );
146 }
147
148 #[test]
149 fn test_rename_to_raw_identifier() {
150 test_rename(
151 r#"
152 fn main() {
153 let i<|> = 1;
154 }"#,
155 "r#fn",
156 r#"
157 fn main() {
158 let r#fn = 1;
159 }"#,
160 );
161 }
162
163 #[test]
164 fn test_rename_to_invalid_identifier() {
165 let (analysis, position) = single_file_with_position(
166 "
167 fn main() {
168 let i<|> = 1;
169 }",
170 );
171 let new_name = "invalid!";
172 let source_change = analysis.rename(position, new_name).unwrap();
173 assert!(source_change.is_none());
174 }
175
176 #[test]
127 fn test_rename_for_local() { 177 fn test_rename_for_local() {
128 test_rename( 178 test_rename(
129 r#" 179 r#"
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs
index 8039a5164..e213e1a06 100644
--- a/crates/ra_ide/src/runnables.rs
+++ b/crates/ra_ide/src/runnables.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir::Source; 3use hir::InFile;
4use itertools::Itertools; 4use itertools::Itertools;
5use ra_db::SourceDatabase; 5use ra_db::SourceDatabase;
6use ra_syntax::{ 6use ra_syntax::{
@@ -66,8 +66,8 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti
66 return None; 66 return None;
67 } 67 }
68 let range = module.syntax().text_range(); 68 let range = module.syntax().text_range();
69 let src = hir::ModuleSource::from_child_node(db, Source::new(file_id.into(), &module.syntax())); 69 let src = hir::ModuleSource::from_child_node(db, InFile::new(file_id.into(), &module.syntax()));
70 let module = hir::Module::from_definition(db, Source::new(file_id.into(), src))?; 70 let module = hir::Module::from_definition(db, InFile::new(file_id.into(), src))?;
71 71
72 let path = module.path_to_root(db).into_iter().rev().filter_map(|it| it.name(db)).join("::"); 72 let path = module.path_to_root(db).into_iter().rev().filter_map(|it| it.name(db)).join("::");
73 Some(Runnable { range, kind: RunnableKind::TestMod { path } }) 73 Some(Runnable { range, kind: RunnableKind::TestMod { path } })
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 9a3e4c82f..e6a79541f 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -2,7 +2,7 @@
2 2
3use rustc_hash::{FxHashMap, FxHashSet}; 3use rustc_hash::{FxHashMap, FxHashSet};
4 4
5use hir::{Name, Source}; 5use hir::{InFile, Name};
6use ra_db::SourceDatabase; 6use ra_db::SourceDatabase;
7use ra_prof::profile; 7use ra_prof::profile;
8use ra_syntax::{ast, AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T}; 8use ra_syntax::{ast, AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxKind::*, TextRange, T};
@@ -81,7 +81,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
81 81
82 let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap(); 82 let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap();
83 let name_kind = 83 let name_kind =
84 classify_name_ref(db, Source::new(file_id.into(), &name_ref)).map(|d| d.kind); 84 classify_name_ref(db, InFile::new(file_id.into(), &name_ref)).map(|d| d.kind);
85 85
86 if let Some(Local(local)) = &name_kind { 86 if let Some(Local(local)) = &name_kind {
87 if let Some(name) = local.name(db) { 87 if let Some(name) = local.name(db) {
@@ -95,7 +95,7 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
95 NAME => { 95 NAME => {
96 let name = node.as_node().cloned().and_then(ast::Name::cast).unwrap(); 96 let name = node.as_node().cloned().and_then(ast::Name::cast).unwrap();
97 let name_kind = 97 let name_kind =
98 classify_name(db, Source::new(file_id.into(), &name)).map(|d| d.kind); 98 classify_name(db, InFile::new(file_id.into(), &name)).map(|d| d.kind);
99 99
100 if let Some(Local(local)) = &name_kind { 100 if let Some(Local(local)) = &name_kind {
101 if let Some(name) = local.name(db) { 101 if let Some(name) = local.name(db) {
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index 21aef842c..41672eaff 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -13,7 +13,6 @@ relative-path = "1.0.0"
13serde_json = "1.0.34" 13serde_json = "1.0.34"
14serde = { version = "1.0.83", features = ["derive"] } 14serde = { version = "1.0.83", features = ["derive"] }
15crossbeam-channel = "0.4" 15crossbeam-channel = "0.4"
16flexi_logger = "0.14.0"
17log = "0.4.3" 16log = "0.4.3"
18lsp-types = { version = "0.61.0", features = ["proposed"] } 17lsp-types = { version = "0.61.0", features = ["proposed"] }
19rustc-hash = "1.0" 18rustc-hash = "1.0"
@@ -27,6 +26,7 @@ lsp-server = "0.3.0"
27ra_project_model = { path = "../ra_project_model" } 26ra_project_model = { path = "../ra_project_model" }
28ra_prof = { path = "../ra_prof" } 27ra_prof = { path = "../ra_prof" }
29ra_vfs_glob = { path = "../ra_vfs_glob" } 28ra_vfs_glob = { path = "../ra_vfs_glob" }
29env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] }
30 30
31[dev-dependencies] 31[dev-dependencies]
32tempfile = "3" 32tempfile = "3"
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index e13c8ca14..8076a7fa5 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -1,6 +1,5 @@
1//! `ra_lsp_server` binary 1//! `ra_lsp_server` binary
2 2
3use flexi_logger::{Duplicate, Logger};
4use lsp_server::Connection; 3use lsp_server::Connection;
5use ra_lsp_server::{show_message, Result, ServerConfig}; 4use ra_lsp_server::{show_message, Result, ServerConfig};
6use ra_prof; 5use ra_prof;
@@ -14,11 +13,7 @@ fn main() -> Result<()> {
14fn setup_logging() -> Result<()> { 13fn setup_logging() -> Result<()> {
15 std::env::set_var("RUST_BACKTRACE", "short"); 14 std::env::set_var("RUST_BACKTRACE", "short");
16 15
17 let logger = Logger::with_env_or_str("error").duplicate_to_stderr(Duplicate::All); 16 env_logger::try_init()?;
18 match std::env::var("RA_LOG_DIR") {
19 Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?,
20 _ => logger.start()?,
21 };
22 17
23 ra_prof::set_filter(match std::env::var("RA_PROFILE") { 18 ra_prof::set_filter(match std::env::var("RA_PROFILE") {
24 Ok(spec) => ra_prof::Filter::from_spec(&spec), 19 Ok(spec) => ra_prof::Filter::from_spec(&spec),
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index c81fa7f67..ca47ff5e1 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -480,8 +480,6 @@ pub fn handle_prepare_rename(
480 let _p = profile("handle_prepare_rename"); 480 let _p = profile("handle_prepare_rename");
481 let position = params.try_conv_with(&world)?; 481 let position = params.try_conv_with(&world)?;
482 482
483 // We support renaming references like handle_rename does.
484 // In the future we may want to reject the renaming of things like keywords here too.
485 let optional_change = world.analysis().rename(position, "dummy")?; 483 let optional_change = world.analysis().rename(position, "dummy")?;
486 let range = match optional_change { 484 let range = match optional_change {
487 None => return Ok(None), 485 None => return Ok(None),
diff --git a/crates/ra_lsp_server/tests/heavy_tests/main.rs b/crates/ra_lsp_server/tests/heavy_tests/main.rs
index 2ba82ab05..29224cbe8 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/main.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/main.rs
@@ -15,7 +15,6 @@ use tempfile::TempDir;
15 15
16use crate::support::{project, Project}; 16use crate::support::{project, Project};
17 17
18const LOG: &'static str = "";
19const PROFILE: &'static str = ""; 18const PROFILE: &'static str = "";
20// const PROFILE: &'static str = "*@3>100"; 19// const PROFILE: &'static str = "*@3>100";
21 20
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs
index 86073b57d..d5ea52fa9 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/support.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs
@@ -7,7 +7,6 @@ use std::{
7}; 7};
8 8
9use crossbeam_channel::{after, select, Receiver}; 9use crossbeam_channel::{after, select, Receiver};
10use flexi_logger::Logger;
11use lsp_server::{Connection, Message, Notification, Request}; 10use lsp_server::{Connection, Message, Notification, Request};
12use lsp_types::{ 11use lsp_types::{
13 notification::{DidOpenTextDocument, Exit}, 12 notification::{DidOpenTextDocument, Exit},
@@ -53,7 +52,7 @@ impl<'a> Project<'a> {
53 let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap()); 52 let tmp_dir = self.tmp_dir.unwrap_or_else(|| TempDir::new().unwrap());
54 static INIT: Once = Once::new(); 53 static INIT: Once = Once::new();
55 INIT.call_once(|| { 54 INIT.call_once(|| {
56 let _ = Logger::with_env_or_str(crate::LOG).start().unwrap(); 55 let _ = env_logger::builder().is_test(true).try_init().unwrap();
57 ra_prof::set_filter(if crate::PROFILE.is_empty() { 56 ra_prof::set_filter(if crate::PROFILE.is_empty() {
58 ra_prof::Filter::disabled() 57 ra_prof::Filter::disabled()
59 } else { 58 } else {
diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs
index 20c251ff4..4c00b8f30 100644
--- a/crates/ra_tt/src/lib.rs
+++ b/crates/ra_tt/src/lib.rs
@@ -33,14 +33,14 @@ impl TokenId {
33 } 33 }
34} 34}
35 35
36#[derive(Debug, Clone, PartialEq, Eq)] 36#[derive(Debug, Clone, PartialEq, Eq, Hash)]
37pub enum TokenTree { 37pub enum TokenTree {
38 Leaf(Leaf), 38 Leaf(Leaf),
39 Subtree(Subtree), 39 Subtree(Subtree),
40} 40}
41impl_froms!(TokenTree: Leaf, Subtree); 41impl_froms!(TokenTree: Leaf, Subtree);
42 42
43#[derive(Debug, Clone, PartialEq, Eq)] 43#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub enum Leaf { 44pub enum Leaf {
45 Literal(Literal), 45 Literal(Literal),
46 Punct(Punct), 46 Punct(Punct),
@@ -48,13 +48,13 @@ pub enum Leaf {
48} 48}
49impl_froms!(Leaf: Literal, Punct, Ident); 49impl_froms!(Leaf: Literal, Punct, Ident);
50 50
51#[derive(Debug, Clone, PartialEq, Eq)] 51#[derive(Debug, Clone, PartialEq, Eq, Hash)]
52pub struct Subtree { 52pub struct Subtree {
53 pub delimiter: Delimiter, 53 pub delimiter: Delimiter,
54 pub token_trees: Vec<TokenTree>, 54 pub token_trees: Vec<TokenTree>,
55} 55}
56 56
57#[derive(Clone, Copy, Debug, PartialEq, Eq)] 57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
58pub enum Delimiter { 58pub enum Delimiter {
59 Parenthesis, 59 Parenthesis,
60 Brace, 60 Brace,
@@ -62,24 +62,24 @@ pub enum Delimiter {
62 None, 62 None,
63} 63}
64 64
65#[derive(Debug, Clone, PartialEq, Eq)] 65#[derive(Debug, Clone, PartialEq, Eq, Hash)]
66pub struct Literal { 66pub struct Literal {
67 pub text: SmolStr, 67 pub text: SmolStr,
68} 68}
69 69
70#[derive(Debug, Clone, Copy, PartialEq, Eq)] 70#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
71pub struct Punct { 71pub struct Punct {
72 pub char: char, 72 pub char: char,
73 pub spacing: Spacing, 73 pub spacing: Spacing,
74} 74}
75 75
76#[derive(Debug, Clone, Copy, PartialEq, Eq)] 76#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
77pub enum Spacing { 77pub enum Spacing {
78 Alone, 78 Alone,
79 Joint, 79 Joint,
80} 80}
81 81
82#[derive(Debug, Clone, PartialEq, Eq)] 82#[derive(Debug, Clone, PartialEq, Eq, Hash)]
83pub struct Ident { 83pub struct Ident {
84 pub text: SmolStr, 84 pub text: SmolStr,
85 pub id: TokenId, 85 pub id: TokenId,
diff --git a/docs/dev/README.md b/docs/dev/README.md
index 0f64d7e5f..2f6215d6b 100644
--- a/docs/dev/README.md
+++ b/docs/dev/README.md
@@ -124,9 +124,8 @@ Logging is done by both rust-analyzer and VS Code, so it might be tricky to
124figure out where logs go. 124figure out where logs go.
125 125
126Inside rust-analyzer, we use the standard `log` crate for logging, and 126Inside rust-analyzer, we use the standard `log` crate for logging, and
127`flexi_logger` for logging frotend. By default, log goes to stderr (the same as 127`env_logger` for logging frontend. By default, log goes to stderr, but the
128with `env_logger`), but the stderr itself is processed by VS Code. To mirror 128stderr itself is processed by VS Code.
129logs to a `./log` directory, set `RA_LOG_DIR=1` environmental variable.
130 129
131To see stderr in the running VS Code instance, go to the "Output" tab of the 130To see stderr in the running VS Code instance, go to the "Output" tab of the
132panel and select `rust-analyzer`. This shows `eprintln!` as well. Note that 131panel and select `rust-analyzer`. This shows `eprintln!` as well. Note that
diff --git a/docs/user/README.md b/docs/user/README.md
index 913ecea18..adacead52 100644
--- a/docs/user/README.md
+++ b/docs/user/README.md
@@ -1,14 +1,19 @@
1The main interface to rust-analyzer is the 1The main interface to rust-analyzer is the
2[LSP](https://microsoft.github.io/language-server-protocol/) implementation. To 2[LSP](https://microsoft.github.io/language-server-protocol/) implementation. To
3install lsp server, use `cargo xtask install --server`, which is a shorthand for `cargo 3install lsp server, clone the repository and then run `cargo xtask install
4install --package ra_lsp_server`. The binary is named `ra_lsp_server`, you 4--server` (which is shorthand for `cargo install --path
5should be able to use it with any LSP-compatible editor. We use custom 5./crates/ra_lsp_server`). This will produce a binary named `ra_lsp_server` which
6you should be able to use it with any LSP-compatible editor. We use custom
6extensions to LSP, so special client-side support is required to take full 7extensions to LSP, so special client-side support is required to take full
7advantage of rust-analyzer. This repository contains support code for VS Code 8advantage of rust-analyzer. This repository contains support code for VS Code
8and Emacs. 9and Emacs.
9 10
10Rust Analyzer needs sources of rust standard library to work, so you might need 11```
11to execute 12$ git clone [email protected]:rust-analyzer/rust-analyzer && cd rust-analyzer
13$ cargo xtask install --server
14```
15Rust Analyzer needs sources of rust standard library to work, so
16you might also need to execute
12 17
13``` 18```
14$ rustup component add rust-src 19$ rustup component add rust-src
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index c97bfec97..c52902bb5 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -182,7 +182,8 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> {
182 eprintln!("\nERROR: `npm --version` failed, `npm` is required to build the VS Code plugin") 182 eprintln!("\nERROR: `npm --version` failed, `npm` is required to build the VS Code plugin")
183 } 183 }
184 184
185 Cmd { unix: r"npm ci", windows: r"cmd.exe /c npm ci", work_dir: "./editors/code" }.run()?; 185 Cmd { unix: r"npm install", windows: r"cmd.exe /c npm install", work_dir: "./editors/code" }
186 .run()?;
186 Cmd { 187 Cmd {
187 unix: r"npm run package --scripts-prepend-node-path", 188 unix: r"npm run package --scripts-prepend-node-path",
188 windows: r"cmd.exe /c npm run package", 189 windows: r"cmd.exe /c npm run package",