aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml2
-rw-r--r--Cargo.lock57
-rw-r--r--Cargo.toml3
-rw-r--r--crates/ra_db/src/input.rs6
-rw-r--r--crates/ra_db/src/lib.rs26
-rw-r--r--crates/ra_hir/src/debug.rs20
-rw-r--r--crates/ra_hir/src/ids.rs10
-rw-r--r--crates/ra_hir/src/nameres/collector.rs2
-rw-r--r--crates/ra_hir/src/nameres/mod_resolution.rs60
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs11
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs6
-rw-r--r--crates/ra_ide_api/src/references.rs2
12 files changed, 110 insertions, 95 deletions
diff --git a/.travis.yml b/.travis.yml
index d4cf71ab5..65a08cbcd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,7 +14,7 @@ matrix:
14 script: 14 script:
15 - rustup component add rustfmt 15 - rustup component add rustfmt
16 - rustup component add rust-src 16 - rustup component add rust-src
17 - printf "\n\n[profile.dev]\ndebug = false\n" >> Cargo.toml 17 - sed -i "s/debug = 1/debug = false/g" Cargo.toml
18 - cargo test --no-run # let's measure compile time separately 18 - cargo test --no-run # let's measure compile time separately
19 - cargo test 19 - cargo test
20 env: 20 env:
diff --git a/Cargo.lock b/Cargo.lock
index fc2f5d87c..965d5aaa0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -13,7 +13,7 @@ name = "arrayvec"
13version = "0.4.11" 13version = "0.4.11"
14source = "registry+https://github.com/rust-lang/crates.io-index" 14source = "registry+https://github.com/rust-lang/crates.io-index"
15dependencies = [ 15dependencies = [
16 "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", 16 "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
17] 17]
18 18
19[[package]] 19[[package]]
@@ -106,7 +106,7 @@ dependencies = [
106 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 106 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
107 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 107 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
108 "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 108 "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
109 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 109 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
110] 110]
111 111
112[[package]] 112[[package]]
@@ -496,18 +496,17 @@ dependencies = [
496 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 496 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
497 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 497 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
498 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 498 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
499 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 499 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
500 "serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)", 500 "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
501 "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", 501 "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
502] 502]
503 503
504[[package]] 504[[package]]
505name = "iovec" 505name = "iovec"
506version = "0.1.2" 506version = "0.1.4"
507source = "registry+https://github.com/rust-lang/crates.io-index" 507source = "registry+https://github.com/rust-lang/crates.io-index"
508dependencies = [ 508dependencies = [
509 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 509 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
510 "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
511] 510]
512 511
513[[package]] 512[[package]]
@@ -620,7 +619,7 @@ dependencies = [
620 "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", 619 "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
621 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 620 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
622 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 621 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
623 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 622 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
624] 623]
625 624
626[[package]] 625[[package]]
@@ -630,7 +629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
630dependencies = [ 629dependencies = [
631 "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 630 "bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
632 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 631 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
633 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 632 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
634 "serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 633 "serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
635 "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 634 "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
636] 635]
@@ -660,7 +659,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
660dependencies = [ 659dependencies = [
661 "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 660 "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
662 "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 661 "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
663 "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 662 "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
664 "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", 663 "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
665 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", 664 "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
666 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 665 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -704,7 +703,7 @@ dependencies = [
704 703
705[[package]] 704[[package]]
706name = "nodrop" 705name = "nodrop"
707version = "0.1.13" 706version = "0.1.14"
708source = "registry+https://github.com/rust-lang/crates.io-index" 707source = "registry+https://github.com/rust-lang/crates.io-index"
709 708
710[[package]] 709[[package]]
@@ -798,7 +797,7 @@ version = "0.1.6"
798source = "registry+https://github.com/rust-lang/crates.io-index" 797source = "registry+https://github.com/rust-lang/crates.io-index"
799dependencies = [ 798dependencies = [
800 "paste-impl 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 799 "paste-impl 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
801 "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", 800 "proc-macro-hack 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
802] 801]
803 802
804[[package]] 803[[package]]
@@ -806,7 +805,7 @@ name = "paste-impl"
806version = "0.1.6" 805version = "0.1.6"
807source = "registry+https://github.com/rust-lang/crates.io-index" 806source = "registry+https://github.com/rust-lang/crates.io-index"
808dependencies = [ 807dependencies = [
809 "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", 808 "proc-macro-hack 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
810 "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 809 "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
811 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 810 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
812 "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 811 "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -838,7 +837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
838 837
839[[package]] 838[[package]]
840name = "proc-macro-hack" 839name = "proc-macro-hack"
841version = "0.5.9" 840version = "0.5.10"
842source = "registry+https://github.com/rust-lang/crates.io-index" 841source = "registry+https://github.com/rust-lang/crates.io-index"
843dependencies = [ 842dependencies = [
844 "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", 843 "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -956,7 +955,7 @@ dependencies = [
956 "ra_syntax 0.1.0", 955 "ra_syntax 0.1.0",
957 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 956 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
958 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 957 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
959 "salsa 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", 958 "salsa 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
960] 959]
961 960
962[[package]] 961[[package]]
@@ -1044,7 +1043,7 @@ dependencies = [
1044 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 1043 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
1045 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1044 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1046 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 1045 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
1047 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 1046 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
1048 "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1047 "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1049 "test_utils 0.1.0", 1048 "test_utils 0.1.0",
1050 "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 1049 "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1093,7 +1092,7 @@ dependencies = [
1093 "ra_db 0.1.0", 1092 "ra_db 0.1.0",
1094 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1093 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1095 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", 1094 "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)",
1096 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 1095 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
1097] 1096]
1098 1097
1099[[package]] 1098[[package]]
@@ -1428,7 +1427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1428 1427
1429[[package]] 1428[[package]]
1430name = "salsa" 1429name = "salsa"
1431version = "0.13.1" 1430version = "0.13.2"
1432source = "registry+https://github.com/rust-lang/crates.io-index" 1431source = "registry+https://github.com/rust-lang/crates.io-index"
1433dependencies = [ 1432dependencies = [
1434 "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 1433 "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1438,13 +1437,13 @@ dependencies = [
1438 "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 1437 "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
1439 "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", 1438 "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
1440 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1439 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1441 "salsa-macros 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", 1440 "salsa-macros 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
1442 "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", 1441 "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
1443] 1442]
1444 1443
1445[[package]] 1444[[package]]
1446name = "salsa-macros" 1445name = "salsa-macros"
1447version = "0.13.1" 1446version = "0.13.2"
1448source = "registry+https://github.com/rust-lang/crates.io-index" 1447source = "registry+https://github.com/rust-lang/crates.io-index"
1449dependencies = [ 1448dependencies = [
1450 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1449 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1500,7 +1499,7 @@ dependencies = [
1500 1499
1501[[package]] 1500[[package]]
1502name = "serde_json" 1501name = "serde_json"
1503version = "1.0.40" 1502version = "1.0.41"
1504source = "registry+https://github.com/rust-lang/crates.io-index" 1503source = "registry+https://github.com/rust-lang/crates.io-index"
1505dependencies = [ 1504dependencies = [
1506 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 1505 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1520,7 +1519,7 @@ dependencies = [
1520 1519
1521[[package]] 1520[[package]]
1522name = "serde_yaml" 1521name = "serde_yaml"
1523version = "0.8.9" 1522version = "0.8.11"
1524source = "registry+https://github.com/rust-lang/crates.io-index" 1523source = "registry+https://github.com/rust-lang/crates.io-index"
1525dependencies = [ 1524dependencies = [
1526 "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 1525 "dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1599,7 +1598,7 @@ name = "test_utils"
1599version = "0.1.0" 1598version = "0.1.0"
1600dependencies = [ 1599dependencies = [
1601 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 1600 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
1602 "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", 1601 "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
1603 "text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1602 "text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
1604] 1603]
1605 1604
@@ -1840,7 +1839,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1840"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" 1839"checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718"
1841"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" 1840"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
1842"checksum insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23f83ab4ee86f38b292f0420c27fd412690a4baa9ea0ad4e3fa624bf34379b76" 1841"checksum insta 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23f83ab4ee86f38b292f0420c27fd412690a4baa9ea0ad4e3fa624bf34379b76"
1843"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" 1842"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
1844"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" 1843"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358"
1845"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" 1844"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
1846"checksum jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7" 1845"checksum jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7"
@@ -1865,7 +1864,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1865"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" 1864"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40"
1866"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" 1865"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
1867"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" 1866"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88"
1868"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" 1867"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
1869"checksum notify 4.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1191efa2b8fe041decb55c238a125b7a1aeb6fad7a525133a02be5ec949ff3cb" 1868"checksum notify 4.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1191efa2b8fe041decb55c238a125b7a1aeb6fad7a525133a02be5ec949ff3cb"
1870"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" 1869"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
1871"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" 1870"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32"
@@ -1881,7 +1880,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1881"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" 1880"checksum petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f"
1882"checksum pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22e32b0f3771287ebb436130477eabf0f11f934ed036099ad548bc885e708667" 1881"checksum pico-args 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22e32b0f3771287ebb436130477eabf0f11f934ed036099ad548bc885e708667"
1883"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" 1882"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b"
1884"checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" 1883"checksum proc-macro-hack 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "114cdf1f426eb7f550f01af5f53a33c0946156f6814aec939b3bd77e844f9a9d"
1885"checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" 1884"checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0"
1886"checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f" 1885"checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f"
1887"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" 1886"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
@@ -1917,17 +1916,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1917"checksum rustc_lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c86aae0c77166108c01305ee1a36a1e77289d7dc6ca0a3cd91ff4992de2d16a5" 1916"checksum rustc_lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c86aae0c77166108c01305ee1a36a1e77289d7dc6ca0a3cd91ff4992de2d16a5"
1918"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1917"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
1919"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" 1918"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
1920"checksum salsa 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "df34c3a66ef408c3219c11dee2c928d52e679390d3ee6e0b87e96cc758d85377" 1919"checksum salsa 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec0865bdd9d8e614686a0cbb76979c735810131d287eb1683e91e4e64a58c387"
1921"checksum salsa-macros 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c15f36e5c85b3f40b84283321f97ef2ceafa6f9996cffad06793a9e096ab695" 1920"checksum salsa-macros 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cac182212d3a1db75ddc42399ff1461b258a694b8318ee7e0baf6c976e39efee"
1922"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" 1921"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
1923"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" 1922"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"
1924"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1923"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
1925"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1924"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
1926"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" 1925"checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd"
1927"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" 1926"checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e"
1928"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" 1927"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2"
1929"checksum serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573" 1928"checksum serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573"
1930"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582" 1929"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
1931"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" 1930"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
1932"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" 1931"checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7"
1933"checksum smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34836c9a295c62c2ce3514471117c5cb269891e8421b2aafdd910050576c4d8b" 1932"checksum smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34836c9a295c62c2ce3514471117c5cb269891e8421b2aafdd910050576c4d8b"
diff --git a/Cargo.toml b/Cargo.toml
index 317c63795..c7e1f1215 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,9 @@
1[workspace] 1[workspace]
2members = [ "crates/*", "website/website-gen" ] 2members = [ "crates/*", "website/website-gen" ]
3 3
4[profile.dev]
5debug = 1 # only line info
6
4[profile.release] 7[profile.release]
5incremental = true 8incremental = true
6debug = 1 # only line info 9debug = 1 # only line info
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index 23148096c..cae51b02c 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -48,9 +48,6 @@ impl SourceRoot {
48 pub fn new_library() -> SourceRoot { 48 pub fn new_library() -> SourceRoot {
49 SourceRoot { is_library: true, ..SourceRoot::new() } 49 SourceRoot { is_library: true, ..SourceRoot::new() }
50 } 50 }
51 pub fn file_by_relative_path(&self, path: &RelativePath) -> Option<FileId> {
52 self.files.get(path).copied()
53 }
54 pub fn insert_file(&mut self, path: RelativePathBuf, file_id: FileId) { 51 pub fn insert_file(&mut self, path: RelativePathBuf, file_id: FileId) {
55 self.files.insert(path, file_id); 52 self.files.insert(path, file_id);
56 } 53 }
@@ -60,6 +57,9 @@ impl SourceRoot {
60 pub fn walk(&self) -> impl Iterator<Item = FileId> + '_ { 57 pub fn walk(&self) -> impl Iterator<Item = FileId> + '_ {
61 self.files.values().copied() 58 self.files.values().copied()
62 } 59 }
60 pub(crate) fn file_by_relative_path(&self, path: &RelativePath) -> Option<FileId> {
61 self.files.get(path).copied()
62 }
63} 63}
64 64
65/// `CrateGraph` is a bit of information which turns a set of text files into a 65/// `CrateGraph` is a bit of information which turns a set of text files into a
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index 603daed37..4d3a9c036 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -6,7 +6,7 @@ use std::{panic, sync::Arc};
6 6
7use ra_prof::profile; 7use ra_prof::profile;
8use ra_syntax::{ast, Parse, SourceFile, TextRange, TextUnit}; 8use ra_syntax::{ast, Parse, SourceFile, TextRange, TextUnit};
9use relative_path::RelativePathBuf; 9use relative_path::{RelativePath, RelativePathBuf};
10 10
11pub use crate::{ 11pub use crate::{
12 cancellation::Canceled, 12 cancellation::Canceled,
@@ -71,6 +71,11 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug {
71 /// Text of the file. 71 /// Text of the file.
72 #[salsa::input] 72 #[salsa::input]
73 fn file_text(&self, file_id: FileId) -> Arc<String>; 73 fn file_text(&self, file_id: FileId) -> Arc<String>;
74
75 #[salsa::transparent]
76 fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath)
77 -> Option<FileId>;
78
74 // Parses the file into the syntax tree. 79 // Parses the file into the syntax tree.
75 #[salsa::invoke(parse_query)] 80 #[salsa::invoke(parse_query)]
76 fn parse(&self, file_id: FileId) -> Parse<ast::SourceFile>; 81 fn parse(&self, file_id: FileId) -> Parse<ast::SourceFile>;
@@ -89,6 +94,25 @@ pub trait SourceDatabase: CheckCanceled + std::fmt::Debug {
89 fn crate_graph(&self) -> Arc<CrateGraph>; 94 fn crate_graph(&self) -> Arc<CrateGraph>;
90} 95}
91 96
97fn resolve_relative_path(
98 db: &impl SourceDatabase,
99 anchor: FileId,
100 relative_path: &RelativePath,
101) -> Option<FileId> {
102 let path = {
103 let mut path = db.file_relative_path(anchor);
104 // Workaround for relative path API: turn `lib.rs` into ``.
105 if !path.pop() {
106 path = RelativePathBuf::default();
107 }
108 path.push(relative_path);
109 path.normalize()
110 };
111 let source_root = db.file_source_root(anchor);
112 let source_root = db.source_root(source_root);
113 source_root.file_by_relative_path(&path)
114}
115
92fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> { 116fn source_root_crates(db: &impl SourceDatabase, id: SourceRootId) -> Arc<Vec<CrateId>> {
93 let root = db.source_root(id); 117 let root = db.source_root(id);
94 let graph = db.crate_graph(); 118 let graph = db.crate_graph();
diff --git a/crates/ra_hir/src/debug.rs b/crates/ra_hir/src/debug.rs
index 87f3180c3..48b69000b 100644
--- a/crates/ra_hir/src/debug.rs
+++ b/crates/ra_hir/src/debug.rs
@@ -22,7 +22,7 @@ use std::fmt;
22 22
23use ra_db::{CrateId, FileId}; 23use ra_db::{CrateId, FileId};
24 24
25use crate::{db::HirDatabase, Crate, Module, Name}; 25use crate::{db::HirDatabase, Crate, HirFileId, Module, Name};
26 26
27impl Crate { 27impl Crate {
28 pub fn debug(self, db: &impl HirDebugDatabase) -> impl fmt::Debug + '_ { 28 pub fn debug(self, db: &impl HirDebugDatabase) -> impl fmt::Debug + '_ {
@@ -36,6 +36,12 @@ impl Module {
36 } 36 }
37} 37}
38 38
39impl HirFileId {
40 pub fn debug(self, db: &impl HirDebugDatabase) -> impl fmt::Debug + '_ {
41 debug_fn(move |fmt| db.debug_hir_file_id(self, fmt))
42 }
43}
44
39pub trait HirDebugHelper: HirDatabase { 45pub trait HirDebugHelper: HirDatabase {
40 fn crate_name(&self, _krate: CrateId) -> Option<String> { 46 fn crate_name(&self, _krate: CrateId) -> Option<String> {
41 None 47 None
@@ -48,6 +54,7 @@ pub trait HirDebugHelper: HirDatabase {
48pub trait HirDebugDatabase { 54pub trait HirDebugDatabase {
49 fn debug_crate(&self, krate: Crate, fmt: &mut fmt::Formatter<'_>) -> fmt::Result; 55 fn debug_crate(&self, krate: Crate, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
50 fn debug_module(&self, module: Module, fmt: &mut fmt::Formatter<'_>) -> fmt::Result; 56 fn debug_module(&self, module: Module, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
57 fn debug_hir_file_id(&self, file_id: HirFileId, fmt: &mut fmt::Formatter<'_>) -> fmt::Result;
51} 58}
52 59
53impl<DB: HirDebugHelper> HirDebugDatabase for DB { 60impl<DB: HirDebugHelper> HirDebugDatabase for DB {
@@ -62,12 +69,19 @@ impl<DB: HirDebugHelper> HirDebugDatabase for DB {
62 69
63 fn debug_module(&self, module: Module, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { 70 fn debug_module(&self, module: Module, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
64 let file_id = module.definition_source(self).file_id.original_file(self); 71 let file_id = module.definition_source(self).file_id.original_file(self);
65 let path = self.file_path(file_id); 72 let path = self.file_path(file_id).unwrap_or_else(|| "N/A".to_string());
66 fmt.debug_struct("Module") 73 fmt.debug_struct("Module")
67 .field("name", &module.name(self).unwrap_or_else(Name::missing)) 74 .field("name", &module.name(self).unwrap_or_else(Name::missing))
68 .field("path", &path.unwrap_or_else(|| "N/A".to_string())) 75 .field("path", &path)
69 .finish() 76 .finish()
70 } 77 }
78
79 fn debug_hir_file_id(&self, file_id: HirFileId, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
80 let original = file_id.original_file(self);
81 let path = self.file_path(original).unwrap_or_else(|| "N/A".to_string());
82 let is_macro = file_id != original.into();
83 fmt.debug_struct("HirFileId").field("path", &path).field("macro", &is_macro).finish()
84 }
71} 85}
72 86
73fn debug_fn(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Debug { 87fn debug_fn(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Debug {
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index a3b65cc79..85b022744 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -50,16 +50,6 @@ impl HirFileId {
50 } 50 }
51 } 51 }
52 52
53 /// XXX: this is a temporary function, which should go away when we implement the
54 /// nameresolution+macro expansion combo. Prefer using `original_file` if
55 /// possible.
56 pub fn as_original_file(self) -> FileId {
57 match self.0 {
58 HirFileIdRepr::File(file_id) => file_id,
59 HirFileIdRepr::Macro(_r) => panic!("macro generated file: {:?}", self),
60 }
61 }
62
63 /// Get the crate which the macro lives in, if it is a macro file. 53 /// Get the crate which the macro lives in, if it is a macro file.
64 pub(crate) fn macro_crate(self, db: &impl AstDatabase) -> Option<Crate> { 54 pub(crate) fn macro_crate(self, db: &impl AstDatabase) -> Option<Crate> {
65 match self.0 { 55 match self.0 {
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index aa5885f04..b5fe16bfa 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -584,7 +584,7 @@ where
584 // out of line module, resolve, parse and recurse 584 // out of line module, resolve, parse and recurse
585 raw::ModuleData::Declaration { name, ast_id } => { 585 raw::ModuleData::Declaration { name, ast_id } => {
586 let ast_id = ast_id.with_file_id(self.file_id); 586 let ast_id = ast_id.with_file_id(self.file_id);
587 match self.mod_dir.resolve_submodule( 587 match self.mod_dir.resolve_declaration(
588 self.def_collector.db, 588 self.def_collector.db,
589 self.file_id, 589 self.file_id,
590 name, 590 name,
diff --git a/crates/ra_hir/src/nameres/mod_resolution.rs b/crates/ra_hir/src/nameres/mod_resolution.rs
index f50f9abe6..e8b808514 100644
--- a/crates/ra_hir/src/nameres/mod_resolution.rs
+++ b/crates/ra_hir/src/nameres/mod_resolution.rs
@@ -1,9 +1,7 @@
1//! This module resolves `mod foo;` declaration to file. 1//! This module resolves `mod foo;` declaration to file.
2use std::borrow::Cow;
3
4use ra_db::FileId; 2use ra_db::FileId;
5use ra_syntax::SmolStr; 3use ra_syntax::SmolStr;
6use relative_path::{RelativePath, RelativePathBuf}; 4use relative_path::RelativePathBuf;
7 5
8use crate::{db::DefDatabase, HirFileId, Name}; 6use crate::{db::DefDatabase, HirFileId, Name};
9 7
@@ -28,23 +26,22 @@ impl ModDir {
28 attr_path: Option<&SmolStr>, 26 attr_path: Option<&SmolStr>,
29 ) -> ModDir { 27 ) -> ModDir {
30 let mut path = self.path.clone(); 28 let mut path = self.path.clone();
31 match attr_path { 29 match attr_to_path(attr_path) {
32 None => path.push(&name.to_string()), 30 None => path.push(&name.to_string()),
33 Some(attr_path) => { 31 Some(attr_path) => {
34 if self.root_non_dir_owner { 32 if self.root_non_dir_owner {
35 path = path 33 // Workaround for relative path API: turn `lib.rs` into ``.
36 .parent() 34 if !path.pop() {
37 .map(|it| it.to_relative_path_buf()) 35 path = RelativePathBuf::default();
38 .unwrap_or_else(RelativePathBuf::new); 36 }
39 } 37 }
40 let attr_path = &*normalize_attribute_path(attr_path); 38 path.push(attr_path);
41 path.push(RelativePath::new(attr_path));
42 } 39 }
43 } 40 }
44 ModDir { path, root_non_dir_owner: false } 41 ModDir { path, root_non_dir_owner: false }
45 } 42 }
46 43
47 pub(super) fn resolve_submodule( 44 pub(super) fn resolve_declaration(
48 &self, 45 &self,
49 db: &impl DefDatabase, 46 db: &impl DefDatabase,
50 file_id: HirFileId, 47 file_id: HirFileId,
@@ -53,32 +50,25 @@ impl ModDir {
53 ) -> Result<(FileId, ModDir), RelativePathBuf> { 50 ) -> Result<(FileId, ModDir), RelativePathBuf> {
54 let empty_path = RelativePathBuf::default(); 51 let empty_path = RelativePathBuf::default();
55 let file_id = file_id.original_file(db); 52 let file_id = file_id.original_file(db);
56 let base_dir = {
57 let path = db.file_relative_path(file_id);
58 path.parent().unwrap_or(&empty_path).join(&self.path)
59 };
60 53
61 let mut candidate_files = Vec::new(); 54 let mut candidate_files = Vec::new();
62 match attr_path { 55 match attr_to_path(attr_path) {
63 Some(attr) => { 56 Some(attr_path) => {
64 let base = if self.root_non_dir_owner { 57 let base = if self.root_non_dir_owner {
65 base_dir.parent().unwrap_or(&empty_path) 58 self.path.parent().unwrap_or(&empty_path)
66 } else { 59 } else {
67 &base_dir 60 &self.path
68 }; 61 };
69 candidate_files.push(base.join(&*normalize_attribute_path(attr))) 62 candidate_files.push(base.join(attr_path))
70 } 63 }
71 None => { 64 None => {
72 candidate_files.push(base_dir.join(&format!("{}.rs", name))); 65 candidate_files.push(self.path.join(&format!("{}.rs", name)));
73 candidate_files.push(base_dir.join(&format!("{}/mod.rs", name))); 66 candidate_files.push(self.path.join(&format!("{}/mod.rs", name)));
74 } 67 }
75 }; 68 };
76 69
77 let source_root_id = db.file_source_root(file_id);
78 let source_root = db.source_root(source_root_id);
79 for candidate in candidate_files.iter() { 70 for candidate in candidate_files.iter() {
80 let candidate = candidate.normalize(); 71 if let Some(file_id) = db.resolve_relative_path(file_id, candidate) {
81 if let Some(file_id) = source_root.file_by_relative_path(&candidate) {
82 let mut root_non_dir_owner = false; 72 let mut root_non_dir_owner = false;
83 let mut mod_path = RelativePathBuf::new(); 73 let mut mod_path = RelativePathBuf::new();
84 if !(candidate.ends_with("mod.rs") || attr_path.is_some()) { 74 if !(candidate.ends_with("mod.rs") || attr_path.is_some()) {
@@ -88,22 +78,10 @@ impl ModDir {
88 return Ok((file_id, ModDir { path: mod_path, root_non_dir_owner })); 78 return Ok((file_id, ModDir { path: mod_path, root_non_dir_owner }));
89 } 79 }
90 } 80 }
91 let suggestion = candidate_files.first().unwrap(); 81 Err(candidate_files.remove(0))
92 Err(base_dir.join(suggestion))
93 } 82 }
94} 83}
95 84
96fn normalize_attribute_path(file_path: &str) -> Cow<str> { 85fn attr_to_path(attr: Option<&SmolStr>) -> Option<RelativePathBuf> {
97 let current_dir = "./"; 86 attr.and_then(|it| RelativePathBuf::from_path(&it.replace("\\", "/")).ok())
98 let windows_path_separator = r#"\"#;
99 let current_dir_normalize = if file_path.starts_with(current_dir) {
100 &file_path[current_dir.len()..]
101 } else {
102 file_path
103 };
104 if current_dir_normalize.contains(windows_path_separator) {
105 Cow::Owned(current_dir_normalize.replace(windows_path_separator, "/"))
106 } else {
107 Cow::Borrowed(current_dir_normalize)
108 }
109} 87}
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 0435188c8..65f061443 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -12,6 +12,7 @@ use ra_syntax::{
12 Location, SyntaxNode, TextRange, T, 12 Location, SyntaxNode, TextRange, T,
13}; 13};
14use ra_text_edit::{TextEdit, TextEditBuilder}; 14use ra_text_edit::{TextEdit, TextEditBuilder};
15use relative_path::RelativePath;
15 16
16use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit}; 17use crate::{db::RootDatabase, Diagnostic, FileId, FileSystemEdit, SourceChange, SourceFileEdit};
17 18
@@ -47,8 +48,14 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
47 }) 48 })
48 }) 49 })
49 .on::<hir::diagnostics::UnresolvedModule, _>(|d| { 50 .on::<hir::diagnostics::UnresolvedModule, _>(|d| {
50 let source_root = db.file_source_root(d.source().file_id.original_file(db)); 51 let original_file = d.source().file_id.original_file(db);
51 let create_file = FileSystemEdit::CreateFile { source_root, path: d.candidate.clone() }; 52 let source_root = db.file_source_root(original_file);
53 let path = db
54 .file_relative_path(original_file)
55 .parent()
56 .unwrap_or_else(|| RelativePath::new(""))
57 .join(&d.candidate);
58 let create_file = FileSystemEdit::CreateFile { source_root, path };
52 let fix = SourceChange::file_system_edit("create module", create_file); 59 let fix = SourceChange::file_system_edit("create module", create_file);
53 res.borrow_mut().push(Diagnostic { 60 res.borrow_mut().push(Diagnostic {
54 range: d.highlight_range(), 61 range: d.highlight_range(),
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index d0b1a8a2a..5cb67fb95 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -119,7 +119,7 @@ impl NavigationTarget {
119 119
120 pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { 120 pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
121 let src = module.definition_source(db); 121 let src = module.definition_source(db);
122 let file_id = src.file_id.as_original_file(); 122 let file_id = src.file_id.original_file(db);
123 let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); 123 let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
124 match src.ast { 124 match src.ast {
125 ModuleSource::SourceFile(node) => { 125 ModuleSource::SourceFile(node) => {
@@ -139,7 +139,7 @@ impl NavigationTarget {
139 pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { 139 pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
140 let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); 140 let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
141 if let Some(src) = module.declaration_source(db) { 141 if let Some(src) = module.declaration_source(db) {
142 let file_id = src.file_id.as_original_file(); 142 let file_id = src.file_id.original_file(db);
143 return NavigationTarget::from_syntax( 143 return NavigationTarget::from_syntax(
144 file_id, 144 file_id,
145 name, 145 name,
@@ -213,7 +213,7 @@ impl NavigationTarget {
213 ) -> NavigationTarget { 213 ) -> NavigationTarget {
214 let src = impl_block.source(db); 214 let src = impl_block.source(db);
215 NavigationTarget::from_syntax( 215 NavigationTarget::from_syntax(
216 src.file_id.as_original_file(), 216 src.file_id.original_file(db),
217 "impl".into(), 217 "impl".into(),
218 None, 218 None,
219 src.ast.syntax(), 219 src.ast.syntax(),
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 84c2eb793..c95c47bf1 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -140,7 +140,7 @@ fn rename_mod(
140 let module_src = hir::Source { file_id: position.file_id.into(), ast: ast_module.clone() }; 140 let module_src = hir::Source { file_id: position.file_id.into(), ast: ast_module.clone() };
141 if let Some(module) = hir::Module::from_declaration(db, module_src) { 141 if let Some(module) = hir::Module::from_declaration(db, module_src) {
142 let src = module.definition_source(db); 142 let src = module.definition_source(db);
143 let file_id = src.file_id.as_original_file(); 143 let file_id = src.file_id.original_file(db);
144 match src.ast { 144 match src.ast {
145 ModuleSource::SourceFile(..) => { 145 ModuleSource::SourceFile(..) => {
146 let mod_path: RelativePathBuf = db.file_relative_path(file_id); 146 let mod_path: RelativePathBuf = db.file_relative_path(file_id);