diff options
-rw-r--r-- | Cargo.lock | 67 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | crates/ra_hir/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 67 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 17 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/tests/mods.rs | 14 | ||||
-rw-r--r-- | crates/ra_ide_api/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 62 | ||||
-rw-r--r-- | crates/ra_syntax/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 46 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 12 |
11 files changed, 185 insertions, 107 deletions
diff --git a/Cargo.lock b/Cargo.lock index 5114797f0..7dffcd0bc 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -2,7 +2,7 @@ | |||
2 | # It is not intended for manual editing. | 2 | # It is not intended for manual editing. |
3 | [[package]] | 3 | [[package]] |
4 | name = "aho-corasick" | 4 | name = "aho-corasick" |
5 | version = "0.7.4" | 5 | version = "0.7.6" |
6 | source = "registry+https://github.com/rust-lang/crates.io-index" | 6 | source = "registry+https://github.com/rust-lang/crates.io-index" |
7 | dependencies = [ | 7 | dependencies = [ |
8 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 8 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -54,7 +54,7 @@ dependencies = [ | |||
54 | 54 | ||
55 | [[package]] | 55 | [[package]] |
56 | name = "backtrace" | 56 | name = "backtrace" |
57 | version = "0.3.33" | 57 | version = "0.3.34" |
58 | source = "registry+https://github.com/rust-lang/crates.io-index" | 58 | source = "registry+https://github.com/rust-lang/crates.io-index" |
59 | dependencies = [ | 59 | dependencies = [ |
60 | "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", | 60 | "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -274,7 +274,7 @@ dependencies = [ | |||
274 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 274 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
275 | "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", | 275 | "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", |
276 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 276 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
277 | "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 277 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
278 | "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", | 278 | "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", |
279 | "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 279 | "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
280 | "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", | 280 | "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -422,7 +422,7 @@ name = "error-chain" | |||
422 | version = "0.12.1" | 422 | version = "0.12.1" |
423 | source = "registry+https://github.com/rust-lang/crates.io-index" | 423 | source = "registry+https://github.com/rust-lang/crates.io-index" |
424 | dependencies = [ | 424 | dependencies = [ |
425 | "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", | 425 | "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", |
426 | "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 426 | "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
427 | ] | 427 | ] |
428 | 428 | ||
@@ -431,7 +431,7 @@ name = "failure" | |||
431 | version = "0.1.5" | 431 | version = "0.1.5" |
432 | source = "registry+https://github.com/rust-lang/crates.io-index" | 432 | source = "registry+https://github.com/rust-lang/crates.io-index" |
433 | dependencies = [ | 433 | dependencies = [ |
434 | "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", | 434 | "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", |
435 | "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | 435 | "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", |
436 | ] | 436 | ] |
437 | 437 | ||
@@ -474,7 +474,7 @@ dependencies = [ | |||
474 | "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 474 | "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
475 | "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 475 | "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
476 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 476 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
477 | "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 477 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
478 | "yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", | 478 | "yansi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", |
479 | ] | 479 | ] |
480 | 480 | ||
@@ -608,7 +608,7 @@ dependencies = [ | |||
608 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 608 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
609 | "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", | 609 | "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", |
610 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 610 | "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", |
611 | "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 611 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
612 | ] | 612 | ] |
613 | 613 | ||
614 | [[package]] | 614 | [[package]] |
@@ -631,7 +631,7 @@ dependencies = [ | |||
631 | 631 | ||
632 | [[package]] | 632 | [[package]] |
633 | name = "insta" | 633 | name = "insta" |
634 | version = "0.9.0" | 634 | version = "0.10.0" |
635 | source = "registry+https://github.com/rust-lang/crates.io-index" | 635 | source = "registry+https://github.com/rust-lang/crates.io-index" |
636 | dependencies = [ | 636 | dependencies = [ |
637 | "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", | 637 | "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1098,7 +1098,7 @@ dependencies = [ | |||
1098 | "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1098 | "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1099 | "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1099 | "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1100 | "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1100 | "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1101 | "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", | 1101 | "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", |
1102 | ] | 1102 | ] |
1103 | 1103 | ||
1104 | [[package]] | 1104 | [[package]] |
@@ -1191,7 +1191,7 @@ dependencies = [ | |||
1191 | "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", | 1191 | "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git)", |
1192 | "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)", | 1192 | "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git)", |
1193 | "ena 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1193 | "ena 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1194 | "insta 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1194 | "insta 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1195 | "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1195 | "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1196 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1196 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
1197 | "once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", | 1197 | "once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1213,7 +1213,7 @@ version = "0.1.0" | |||
1213 | dependencies = [ | 1213 | dependencies = [ |
1214 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1214 | "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1215 | "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", | 1215 | "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", |
1216 | "insta 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1216 | "insta 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1217 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1217 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1218 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1218 | "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1219 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", | 1219 | "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1285,7 +1285,7 @@ dependencies = [ | |||
1285 | name = "ra_prof" | 1285 | name = "ra_prof" |
1286 | version = "0.1.0" | 1286 | version = "0.1.0" |
1287 | dependencies = [ | 1287 | dependencies = [ |
1288 | "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", | 1288 | "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", |
1289 | "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1289 | "cpuprofiler 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", |
1290 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1290 | "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1291 | "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", | 1291 | "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1323,10 +1323,9 @@ dependencies = [ | |||
1323 | "ra_parser 0.1.0", | 1323 | "ra_parser 0.1.0", |
1324 | "ra_rustc_lexer 0.1.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", | 1324 | "ra_rustc_lexer 0.1.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1325 | "ra_text_edit 0.1.0", | 1325 | "ra_text_edit 0.1.0", |
1326 | "rowan 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1326 | "rowan 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", |
1327 | "smol_str 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", | 1327 | "smol_str 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", |
1328 | "test_utils 0.1.0", | 1328 | "test_utils 0.1.0", |
1329 | "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1330 | "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", | 1329 | "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", |
1331 | ] | 1330 | ] |
1332 | 1331 | ||
@@ -1550,23 +1549,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
1550 | 1549 | ||
1551 | [[package]] | 1550 | [[package]] |
1552 | name = "regex" | 1551 | name = "regex" |
1553 | version = "1.2.0" | 1552 | version = "1.2.1" |
1554 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1553 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1555 | dependencies = [ | 1554 | dependencies = [ |
1556 | "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", | 1555 | "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1557 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1556 | "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1558 | "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", | 1557 | "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", |
1559 | "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", | 1558 | "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", |
1560 | "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1561 | ] | 1559 | ] |
1562 | 1560 | ||
1563 | [[package]] | 1561 | [[package]] |
1564 | name = "regex-syntax" | 1562 | name = "regex-syntax" |
1565 | version = "0.6.10" | 1563 | version = "0.6.11" |
1566 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1564 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1567 | dependencies = [ | ||
1568 | "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", | ||
1569 | ] | ||
1570 | 1565 | ||
1571 | [[package]] | 1566 | [[package]] |
1572 | name = "relative-path" | 1567 | name = "relative-path" |
@@ -1593,7 +1588,7 @@ dependencies = [ | |||
1593 | 1588 | ||
1594 | [[package]] | 1589 | [[package]] |
1595 | name = "rowan" | 1590 | name = "rowan" |
1596 | version = "0.6.1" | 1591 | version = "0.6.2" |
1597 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1592 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1598 | dependencies = [ | 1593 | dependencies = [ |
1599 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1594 | "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1824,7 +1819,7 @@ dependencies = [ | |||
1824 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1819 | "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1825 | "pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", | 1820 | "pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1826 | "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1821 | "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", |
1827 | "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", | 1822 | "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", |
1828 | "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", | 1823 | "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", |
1829 | "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", | 1824 | "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", |
1830 | "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", | 1825 | "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", |
@@ -1917,11 +1912,6 @@ version = "0.1.2" | |||
1917 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1912 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1918 | 1913 | ||
1919 | [[package]] | 1914 | [[package]] |
1920 | name = "ucd-util" | ||
1921 | version = "0.1.5" | ||
1922 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1923 | |||
1924 | [[package]] | ||
1925 | name = "unic-char-property" | 1915 | name = "unic-char-property" |
1926 | version = "0.7.0" | 1916 | version = "0.7.0" |
1927 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1917 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -2024,11 +2014,6 @@ dependencies = [ | |||
2024 | ] | 2014 | ] |
2025 | 2015 | ||
2026 | [[package]] | 2016 | [[package]] |
2027 | name = "utf8-ranges" | ||
2028 | version = "1.0.3" | ||
2029 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
2030 | |||
2031 | [[package]] | ||
2032 | name = "uuid" | 2017 | name = "uuid" |
2033 | version = "0.7.4" | 2018 | version = "0.7.4" |
2034 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2019 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -2117,13 +2102,13 @@ version = "0.5.0" | |||
2117 | source = "registry+https://github.com/rust-lang/crates.io-index" | 2102 | source = "registry+https://github.com/rust-lang/crates.io-index" |
2118 | 2103 | ||
2119 | [metadata] | 2104 | [metadata] |
2120 | "checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" | 2105 | "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" |
2121 | "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" | 2106 | "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" |
2122 | "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" | 2107 | "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" |
2123 | "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" | 2108 | "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" |
2124 | "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" | 2109 | "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" |
2125 | "checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f" | 2110 | "checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f" |
2126 | "checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" | 2111 | "checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" |
2127 | "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" | 2112 | "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" |
2128 | "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" | 2113 | "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" |
2129 | "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" | 2114 | "checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" |
@@ -2192,7 +2177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2192 | "checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c" | 2177 | "checksum indicatif 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2c60da1c9abea75996b70a931bba6c750730399005b61ccd853cee50ef3d0d0c" |
2193 | "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" | 2178 | "checksum inotify 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40b54539f3910d6f84fbf9a643efd6e3aa6e4f001426c0329576128255994718" |
2194 | "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" | 2179 | "checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" |
2195 | "checksum insta 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a915d6263f1d68fc9b693058702a3e9f47f4434dec45d4e35e2b66e490f8bc51" | 2180 | "checksum insta 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00eef45accbe65bfb859ad16649c6b4bed246768d89493473d9ab6c6a0eb908f" |
2196 | "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" | 2181 | "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" |
2197 | "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" | 2182 | "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" |
2198 | "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" | 2183 | "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" |
@@ -2268,12 +2253,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2268 | "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" | 2253 | "checksum rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe0df8435ac0c397d467b6cad6d25543d06e8a019ef3f6af3c384597515bd2" |
2269 | "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" | 2254 | "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" |
2270 | "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" | 2255 | "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" |
2271 | "checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" | 2256 | "checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" |
2272 | "checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" | 2257 | "checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" |
2273 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" | 2258 | "checksum relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0e7790c7f1cc73d831d28dc5a7deb316a006e7848e6a7f467cdb10a0a9e0fb1c" |
2274 | "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" | 2259 | "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" |
2275 | "checksum ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17f52a24414403f81528b67488cf8edc4eda977d3af1646bb6b106a600ead78f" | 2260 | "checksum ron 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17f52a24414403f81528b67488cf8edc4eda977d3af1646bb6b106a600ead78f" |
2276 | "checksum rowan 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03e34c2e5f01d7fa4ab7e6a49da44f59fb38ffb61e6c9f714deb8e157274c2c7" | 2261 | "checksum rowan 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dc2b79612dedc9004083a61448eb669d336d56690aab29fbd7249e8c8ab41d8c" |
2277 | "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" | 2262 | "checksum rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f4dccf6f4891ebcc0c39f9b6eb1a83b9bf5d747cb439ec6fba4f3b977038af" |
2278 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" | 2263 | "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" |
2279 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" | 2264 | "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" |
@@ -2309,7 +2294,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2309 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" | 2294 | "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" |
2310 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" | 2295 | "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" |
2311 | "checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2" | 2296 | "checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2" |
2312 | "checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" | ||
2313 | "checksum unic-char-property 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce36d3f7ce754afdbccccf8ff0dd0134e50fb44aaae579f96218856e9e5dbd1e" | 2297 | "checksum unic-char-property 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce36d3f7ce754afdbccccf8ff0dd0134e50fb44aaae579f96218856e9e5dbd1e" |
2314 | "checksum unic-char-range 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab85fab42ad1b26cafc03bf891f69cb4d6e15f491030e89a0122197baa8ae8" | 2298 | "checksum unic-char-range 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab85fab42ad1b26cafc03bf891f69cb4d6e15f491030e89a0122197baa8ae8" |
2315 | "checksum unic-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8d4a7ade929ef7d971e16ced21a8cd56a63869aa6032dfb8cb083cf7d077bf" | 2299 | "checksum unic-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8d4a7ade929ef7d971e16ced21a8cd56a63869aa6032dfb8cb083cf7d077bf" |
@@ -2324,7 +2308,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
2324 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" | 2308 | "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" |
2325 | "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" | 2309 | "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" |
2326 | "checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea" | 2310 | "checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea" |
2327 | "checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" | ||
2328 | "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" | 2311 | "checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" |
2329 | "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" | 2312 | "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" |
2330 | "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" | 2313 | "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" |
@@ -7,7 +7,7 @@ language. It is a part of a larger rls-2.0 effort to create excellent IDE | |||
7 | support for Rust. If you want to get involved, check the rls-2.0 working group | 7 | support for Rust. If you want to get involved, check the rls-2.0 working group |
8 | in the compiler-team repository: | 8 | in the compiler-team repository: |
9 | 9 | ||
10 | https://github.com/rust-lang/compiler-team/tree/master/content/docs/working-groups/rls-2.0 | 10 | https://github.com/rust-lang/compiler-team/tree/master/content/working-groups/rls-2.0 |
11 | 11 | ||
12 | Work on the Rust Analyzer is sponsored by | 12 | Work on the Rust Analyzer is sponsored by |
13 | 13 | ||
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml index 285b3c63a..1a2f1b47c 100644 --- a/crates/ra_hir/Cargo.toml +++ b/crates/ra_hir/Cargo.toml | |||
@@ -27,4 +27,4 @@ chalk-ir = { git = "https://github.com/rust-lang/chalk.git" } | |||
27 | lalrpop-intern = "0.15.1" | 27 | lalrpop-intern = "0.15.1" |
28 | 28 | ||
29 | [dev-dependencies] | 29 | [dev-dependencies] |
30 | insta = "0.9.0" | 30 | insta = "0.10.0" |
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 06b732215..7da2dcdff 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -483,7 +483,7 @@ struct ModCollector<'a, D> { | |||
483 | module_id: CrateModuleId, | 483 | module_id: CrateModuleId, |
484 | file_id: HirFileId, | 484 | file_id: HirFileId, |
485 | raw_items: &'a raw::RawItems, | 485 | raw_items: &'a raw::RawItems, |
486 | parent_module: Option<&'a Name>, | 486 | parent_module: Option<ParentModule<'a>>, |
487 | } | 487 | } |
488 | 488 | ||
489 | impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>> | 489 | impl<DB> ModCollector<'_, &'_ mut DefCollector<&'_ DB>> |
@@ -508,15 +508,16 @@ where | |||
508 | fn collect_module(&mut self, module: &raw::ModuleData) { | 508 | fn collect_module(&mut self, module: &raw::ModuleData) { |
509 | match module { | 509 | match module { |
510 | // inline module, just recurse | 510 | // inline module, just recurse |
511 | raw::ModuleData::Definition { name, items, ast_id } => { | 511 | raw::ModuleData::Definition { name, items, ast_id, attr_path } => { |
512 | let module_id = | 512 | let module_id = |
513 | self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); | 513 | self.push_child_module(name.clone(), ast_id.with_file_id(self.file_id), None); |
514 | let parent_module = ParentModule { name, attr_path: attr_path.as_ref() }; | ||
514 | ModCollector { | 515 | ModCollector { |
515 | def_collector: &mut *self.def_collector, | 516 | def_collector: &mut *self.def_collector, |
516 | module_id, | 517 | module_id, |
517 | file_id: self.file_id, | 518 | file_id: self.file_id, |
518 | raw_items: self.raw_items, | 519 | raw_items: self.raw_items, |
519 | parent_module: Some(name), | 520 | parent_module: Some(parent_module), |
520 | } | 521 | } |
521 | .collect(&*items); | 522 | .collect(&*items); |
522 | } | 523 | } |
@@ -530,7 +531,7 @@ where | |||
530 | name, | 531 | name, |
531 | is_root, | 532 | is_root, |
532 | attr_path.as_ref(), | 533 | attr_path.as_ref(), |
533 | self.parent_module, | 534 | self.parent_module.as_ref(), |
534 | ) { | 535 | ) { |
535 | Ok(file_id) => { | 536 | Ok(file_id) => { |
536 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); | 537 | let module_id = self.push_child_module(name.clone(), ast_id, Some(file_id)); |
@@ -647,7 +648,7 @@ fn resolve_submodule( | |||
647 | name: &Name, | 648 | name: &Name, |
648 | is_root: bool, | 649 | is_root: bool, |
649 | attr_path: Option<&SmolStr>, | 650 | attr_path: Option<&SmolStr>, |
650 | parent_module: Option<&Name>, | 651 | parent_module: Option<&ParentModule>, |
651 | ) -> Result<FileId, RelativePathBuf> { | 652 | ) -> Result<FileId, RelativePathBuf> { |
652 | let file_id = file_id.original_file(db); | 653 | let file_id = file_id.original_file(db); |
653 | let source_root_id = db.file_source_root(file_id); | 654 | let source_root_id = db.file_source_root(file_id); |
@@ -657,20 +658,49 @@ fn resolve_submodule( | |||
657 | let mod_name = path.file_stem().unwrap_or("unknown"); | 658 | let mod_name = path.file_stem().unwrap_or("unknown"); |
658 | 659 | ||
659 | let resolve_mode = match (attr_path.filter(|p| !p.is_empty()), parent_module) { | 660 | let resolve_mode = match (attr_path.filter(|p| !p.is_empty()), parent_module) { |
660 | (Some(file_path), Some(parent_name)) => { | 661 | (Some(file_path), Some(parent_module)) => { |
661 | let file_path = normalize_attribute_path(file_path); | 662 | let file_path = normalize_attribute_path(file_path); |
662 | let path = dir_path.join(format!("{}/{}", parent_name, file_path)).normalize(); | 663 | match parent_module.attribute_path() { |
663 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::WithAttributePath(path)) | 664 | Some(parent_module_attr_path) => { |
665 | let path = dir_path | ||
666 | .join(format!( | ||
667 | "{}/{}", | ||
668 | normalize_attribute_path(parent_module_attr_path), | ||
669 | file_path | ||
670 | )) | ||
671 | .normalize(); | ||
672 | ResolutionMode::InlineModuleWithAttributePath( | ||
673 | InsideInlineModuleMode::WithAttributePath(path), | ||
674 | ) | ||
675 | } | ||
676 | None => { | ||
677 | let path = | ||
678 | dir_path.join(format!("{}/{}", parent_module.name, file_path)).normalize(); | ||
679 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::WithAttributePath( | ||
680 | path, | ||
681 | )) | ||
682 | } | ||
683 | } | ||
664 | } | 684 | } |
685 | (None, Some(parent_module)) => match parent_module.attribute_path() { | ||
686 | Some(parent_module_attr_path) => { | ||
687 | let path = dir_path.join(format!( | ||
688 | "{}/{}.rs", | ||
689 | normalize_attribute_path(parent_module_attr_path), | ||
690 | name | ||
691 | )); | ||
692 | ResolutionMode::InlineModuleWithAttributePath(InsideInlineModuleMode::File(path)) | ||
693 | } | ||
694 | None => { | ||
695 | let path = dir_path.join(format!("{}/{}.rs", parent_module.name, name)); | ||
696 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::File(path)) | ||
697 | } | ||
698 | }, | ||
665 | (Some(file_path), None) => { | 699 | (Some(file_path), None) => { |
666 | let file_path = normalize_attribute_path(file_path); | 700 | let file_path = normalize_attribute_path(file_path); |
667 | let path = dir_path.join(file_path.as_ref()).normalize(); | 701 | let path = dir_path.join(file_path.as_ref()).normalize(); |
668 | ResolutionMode::OutOfLine(OutOfLineMode::WithAttributePath(path)) | 702 | ResolutionMode::OutOfLine(OutOfLineMode::WithAttributePath(path)) |
669 | } | 703 | } |
670 | (None, Some(parent_name)) => { | ||
671 | let path = dir_path.join(format!("{}/{}.rs", parent_name, name)); | ||
672 | ResolutionMode::InsideInlineModule(InsideInlineModuleMode::File(path)) | ||
673 | } | ||
674 | _ => { | 704 | _ => { |
675 | let is_dir_owner = is_root || mod_name == "mod"; | 705 | let is_dir_owner = is_root || mod_name == "mod"; |
676 | if is_dir_owner { | 706 | if is_dir_owner { |
@@ -743,6 +773,7 @@ impl InsideInlineModuleMode { | |||
743 | enum ResolutionMode { | 773 | enum ResolutionMode { |
744 | OutOfLine(OutOfLineMode), | 774 | OutOfLine(OutOfLineMode), |
745 | InsideInlineModule(InsideInlineModuleMode), | 775 | InsideInlineModule(InsideInlineModuleMode), |
776 | InlineModuleWithAttributePath(InsideInlineModuleMode), | ||
746 | } | 777 | } |
747 | 778 | ||
748 | impl ResolutionMode { | 779 | impl ResolutionMode { |
@@ -752,6 +783,7 @@ impl ResolutionMode { | |||
752 | match self { | 783 | match self { |
753 | OutOfLine(mode) => mode.resolve(source_root), | 784 | OutOfLine(mode) => mode.resolve(source_root), |
754 | InsideInlineModule(mode) => mode.resolve(source_root), | 785 | InsideInlineModule(mode) => mode.resolve(source_root), |
786 | InlineModuleWithAttributePath(mode) => mode.resolve(source_root), | ||
755 | } | 787 | } |
756 | } | 788 | } |
757 | } | 789 | } |
@@ -773,6 +805,17 @@ fn resolve_find_result( | |||
773 | } | 805 | } |
774 | } | 806 | } |
775 | 807 | ||
808 | struct ParentModule<'a> { | ||
809 | name: &'a Name, | ||
810 | attr_path: Option<&'a SmolStr>, | ||
811 | } | ||
812 | |||
813 | impl<'a> ParentModule<'a> { | ||
814 | pub fn attribute_path(&self) -> Option<&SmolStr> { | ||
815 | self.attr_path.filter(|p| !p.is_empty()) | ||
816 | } | ||
817 | } | ||
818 | |||
776 | #[cfg(test)] | 819 | #[cfg(test)] |
777 | mod tests { | 820 | mod tests { |
778 | use ra_db::SourceDatabase; | 821 | use ra_db::SourceDatabase; |
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 8517f3c43..584e15e29 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -130,8 +130,17 @@ impl_arena_id!(Module); | |||
130 | 130 | ||
131 | #[derive(Debug, PartialEq, Eq)] | 131 | #[derive(Debug, PartialEq, Eq)] |
132 | pub(super) enum ModuleData { | 132 | pub(super) enum ModuleData { |
133 | Declaration { name: Name, ast_id: FileAstId<ast::Module>, attr_path: Option<SmolStr> }, | 133 | Declaration { |
134 | Definition { name: Name, ast_id: FileAstId<ast::Module>, items: Vec<RawItem> }, | 134 | name: Name, |
135 | ast_id: FileAstId<ast::Module>, | ||
136 | attr_path: Option<SmolStr>, | ||
137 | }, | ||
138 | Definition { | ||
139 | name: Name, | ||
140 | ast_id: FileAstId<ast::Module>, | ||
141 | items: Vec<RawItem>, | ||
142 | attr_path: Option<SmolStr>, | ||
143 | }, | ||
135 | } | 144 | } |
136 | 145 | ||
137 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 146 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -256,9 +265,9 @@ impl RawItemsCollector { | |||
256 | None => return, | 265 | None => return, |
257 | }; | 266 | }; |
258 | 267 | ||
259 | let attr_path = extract_mod_path_attribute(&module); | ||
260 | let ast_id = self.source_ast_id_map.ast_id(&module); | 268 | let ast_id = self.source_ast_id_map.ast_id(&module); |
261 | if module.has_semi() { | 269 | if module.has_semi() { |
270 | let attr_path = extract_mod_path_attribute(&module); | ||
262 | let item = | 271 | let item = |
263 | self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, attr_path }); | 272 | self.raw_items.modules.alloc(ModuleData::Declaration { name, ast_id, attr_path }); |
264 | self.push_item(current_module, RawItem::Module(item)); | 273 | self.push_item(current_module, RawItem::Module(item)); |
@@ -266,10 +275,12 @@ impl RawItemsCollector { | |||
266 | } | 275 | } |
267 | 276 | ||
268 | if let Some(item_list) = module.item_list() { | 277 | if let Some(item_list) = module.item_list() { |
278 | let attr_path = extract_mod_path_attribute(&module); | ||
269 | let item = self.raw_items.modules.alloc(ModuleData::Definition { | 279 | let item = self.raw_items.modules.alloc(ModuleData::Definition { |
270 | name, | 280 | name, |
271 | ast_id, | 281 | ast_id, |
272 | items: Vec::new(), | 282 | items: Vec::new(), |
283 | attr_path, | ||
273 | }); | 284 | }); |
274 | self.process_module(Some(item), item_list); | 285 | self.process_module(Some(item), item_list); |
275 | self.push_item(current_module, RawItem::Module(item)); | 286 | self.push_item(current_module, RawItem::Module(item)); |
diff --git a/crates/ra_hir/src/nameres/tests/mods.rs b/crates/ra_hir/src/nameres/tests/mods.rs index 382728149..6dd18df1a 100644 --- a/crates/ra_hir/src/nameres/tests/mods.rs +++ b/crates/ra_hir/src/nameres/tests/mods.rs | |||
@@ -336,9 +336,7 @@ fn module_resolution_explicit_path_mod_rs_with_win_separator() { | |||
336 | "###); | 336 | "###); |
337 | } | 337 | } |
338 | 338 | ||
339 | // FIXME: issue #1529. not support out-of-line modules inside inline. | ||
340 | #[test] | 339 | #[test] |
341 | #[ignore] | ||
342 | fn module_resolution_decl_inside_inline_module_with_path_attribute() { | 340 | fn module_resolution_decl_inside_inline_module_with_path_attribute() { |
343 | let map = def_map_with_crate_graph( | 341 | let map = def_map_with_crate_graph( |
344 | r###" | 342 | r###" |
@@ -397,9 +395,7 @@ fn module_resolution_decl_inside_inline_module() { | |||
397 | "###); | 395 | "###); |
398 | } | 396 | } |
399 | 397 | ||
400 | // FIXME: issue #1529. not support out-of-line modules inside inline. | ||
401 | #[test] | 398 | #[test] |
402 | #[ignore] | ||
403 | fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { | 399 | fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { |
404 | let map = def_map_with_crate_graph( | 400 | let map = def_map_with_crate_graph( |
405 | r###" | 401 | r###" |
@@ -429,9 +425,7 @@ fn module_resolution_decl_inside_inline_module_2_with_path_attribute() { | |||
429 | "###); | 425 | "###); |
430 | } | 426 | } |
431 | 427 | ||
432 | // FIXME: issue #1529. not support out-of-line modules inside inline. | ||
433 | #[test] | 428 | #[test] |
434 | #[ignore] | ||
435 | fn module_resolution_decl_inside_inline_module_3() { | 429 | fn module_resolution_decl_inside_inline_module_3() { |
436 | let map = def_map_with_crate_graph( | 430 | let map = def_map_with_crate_graph( |
437 | r###" | 431 | r###" |
@@ -462,9 +456,7 @@ fn module_resolution_decl_inside_inline_module_3() { | |||
462 | "###); | 456 | "###); |
463 | } | 457 | } |
464 | 458 | ||
465 | // FIXME: issue #1529. not support out-of-line modules inside inline. | ||
466 | #[test] | 459 | #[test] |
467 | #[ignore] | ||
468 | fn module_resolution_decl_inside_inline_module_empty_path() { | 460 | fn module_resolution_decl_inside_inline_module_empty_path() { |
469 | let map = def_map_with_crate_graph( | 461 | let map = def_map_with_crate_graph( |
470 | r###" | 462 | r###" |
@@ -475,7 +467,7 @@ fn module_resolution_decl_inside_inline_module_empty_path() { | |||
475 | mod bar; | 467 | mod bar; |
476 | } | 468 | } |
477 | 469 | ||
478 | //- /users.rs | 470 | //- /foo/users.rs |
479 | pub struct Baz; | 471 | pub struct Baz; |
480 | "###, | 472 | "###, |
481 | crate_graph! { | 473 | crate_graph! { |
@@ -520,9 +512,7 @@ fn module_resolution_decl_empty_path() { | |||
520 | "###); | 512 | "###); |
521 | } | 513 | } |
522 | 514 | ||
523 | // FIXME: issue #1529. not support out-of-line modules inside inline. | ||
524 | #[test] | 515 | #[test] |
525 | #[ignore] | ||
526 | fn module_resolution_decl_inside_inline_module_relative_path() { | 516 | fn module_resolution_decl_inside_inline_module_relative_path() { |
527 | let map = def_map_with_crate_graph( | 517 | let map = def_map_with_crate_graph( |
528 | r###" | 518 | r###" |
@@ -660,9 +650,7 @@ fn module_resolution_decl_inside_inline_module_in_non_crate_root() { | |||
660 | "###); | 650 | "###); |
661 | } | 651 | } |
662 | 652 | ||
663 | // FIXME: issue #1529. not support out-of-line modules inside inline. | ||
664 | #[test] | 653 | #[test] |
665 | #[ignore] | ||
666 | fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { | 654 | fn module_resolution_decl_inside_inline_module_in_non_crate_root_2() { |
667 | let map = def_map_with_crate_graph( | 655 | let map = def_map_with_crate_graph( |
668 | r###" | 656 | r###" |
diff --git a/crates/ra_ide_api/Cargo.toml b/crates/ra_ide_api/Cargo.toml index dd11ec0f6..a7dc0b63a 100644 --- a/crates/ra_ide_api/Cargo.toml +++ b/crates/ra_ide_api/Cargo.toml | |||
@@ -27,7 +27,7 @@ test_utils = { path = "../test_utils" } | |||
27 | ra_assists = { path = "../ra_assists" } | 27 | ra_assists = { path = "../ra_assists" } |
28 | 28 | ||
29 | [dev-dependencies] | 29 | [dev-dependencies] |
30 | insta = "0.9.0" | 30 | insta = "0.10.0" |
31 | 31 | ||
32 | [dev-dependencies.proptest] | 32 | [dev-dependencies.proptest] |
33 | version = "0.9.0" | 33 | version = "0.9.0" |
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index 6603ff34d..9d6d0133f 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_parser::{Token, TokenSource}; | 1 | use ra_parser::{Token, TokenSource}; |
2 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; | 2 | use ra_syntax::{classify_literal, SmolStr, SyntaxKind, SyntaxKind::*, T}; |
3 | use std::cell::{Cell, RefCell}; | 3 | use std::cell::{Cell, Ref, RefCell}; |
4 | use tt::buffer::{Cursor, TokenBuffer}; | 4 | use tt::buffer::{Cursor, TokenBuffer}; |
5 | 5 | ||
6 | #[derive(Debug, Clone, Eq, PartialEq)] | 6 | #[derive(Debug, Clone, Eq, PartialEq)] |
@@ -20,8 +20,8 @@ impl<'a> SubtreeTokenSource<'a> { | |||
20 | // Helper function used in test | 20 | // Helper function used in test |
21 | #[cfg(test)] | 21 | #[cfg(test)] |
22 | pub fn text(&self) -> SmolStr { | 22 | pub fn text(&self) -> SmolStr { |
23 | match self.get(self.curr.1) { | 23 | match *self.get(self.curr.1) { |
24 | Some(tt) => tt.text, | 24 | Some(ref tt) => tt.text.clone(), |
25 | _ => SmolStr::new(""), | 25 | _ => SmolStr::new(""), |
26 | } | 26 | } |
27 | } | 27 | } |
@@ -41,44 +41,46 @@ impl<'a> SubtreeTokenSource<'a> { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | fn mk_token(&self, pos: usize) -> Token { | 43 | fn mk_token(&self, pos: usize) -> Token { |
44 | match self.get(pos) { | 44 | match *self.get(pos) { |
45 | Some(tt) => Token { kind: tt.kind, is_jointed_to_next: tt.is_joint_to_next }, | 45 | Some(ref tt) => Token { kind: tt.kind, is_jointed_to_next: tt.is_joint_to_next }, |
46 | None => Token { kind: EOF, is_jointed_to_next: false }, | 46 | None => Token { kind: EOF, is_jointed_to_next: false }, |
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | fn get(&self, pos: usize) -> Option<TtToken> { | 50 | fn get(&self, pos: usize) -> Ref<Option<TtToken>> { |
51 | let mut cached = self.cached.borrow_mut(); | 51 | if pos < self.cached.borrow().len() { |
52 | if pos < cached.len() { | 52 | return Ref::map(self.cached.borrow(), |c| &c[pos]); |
53 | return cached[pos].clone(); | ||
54 | } | 53 | } |
55 | 54 | ||
56 | while pos >= cached.len() { | 55 | { |
57 | let cursor = self.cached_cursor.get(); | 56 | let mut cached = self.cached.borrow_mut(); |
58 | if cursor.eof() { | 57 | while pos >= cached.len() { |
59 | cached.push(None); | 58 | let cursor = self.cached_cursor.get(); |
60 | continue; | 59 | if cursor.eof() { |
61 | } | 60 | cached.push(None); |
62 | 61 | continue; | |
63 | match cursor.token_tree() { | ||
64 | Some(tt::TokenTree::Leaf(leaf)) => { | ||
65 | cached.push(Some(convert_leaf(&leaf))); | ||
66 | self.cached_cursor.set(cursor.bump()); | ||
67 | } | ||
68 | Some(tt::TokenTree::Subtree(subtree)) => { | ||
69 | self.cached_cursor.set(cursor.subtree().unwrap()); | ||
70 | cached.push(Some(convert_delim(subtree.delimiter, false))); | ||
71 | } | 62 | } |
72 | None => { | 63 | |
73 | if let Some(subtree) = cursor.end() { | 64 | match cursor.token_tree() { |
74 | cached.push(Some(convert_delim(subtree.delimiter, true))); | 65 | Some(tt::TokenTree::Leaf(leaf)) => { |
66 | cached.push(Some(convert_leaf(&leaf))); | ||
75 | self.cached_cursor.set(cursor.bump()); | 67 | self.cached_cursor.set(cursor.bump()); |
76 | } | 68 | } |
69 | Some(tt::TokenTree::Subtree(subtree)) => { | ||
70 | self.cached_cursor.set(cursor.subtree().unwrap()); | ||
71 | cached.push(Some(convert_delim(subtree.delimiter, false))); | ||
72 | } | ||
73 | None => { | ||
74 | if let Some(subtree) = cursor.end() { | ||
75 | cached.push(Some(convert_delim(subtree.delimiter, true))); | ||
76 | self.cached_cursor.set(cursor.bump()); | ||
77 | } | ||
78 | } | ||
77 | } | 79 | } |
78 | } | 80 | } |
79 | } | 81 | } |
80 | 82 | ||
81 | cached[pos].clone() | 83 | Ref::map(self.cached.borrow(), |c| &c[pos]) |
82 | } | 84 | } |
83 | } | 85 | } |
84 | 86 | ||
@@ -103,8 +105,8 @@ impl<'a> TokenSource for SubtreeTokenSource<'a> { | |||
103 | 105 | ||
104 | /// Is the current token a specified keyword? | 106 | /// Is the current token a specified keyword? |
105 | fn is_keyword(&self, kw: &str) -> bool { | 107 | fn is_keyword(&self, kw: &str) -> bool { |
106 | match self.get(self.curr.1) { | 108 | match *self.get(self.curr.1) { |
107 | Some(t) => t.text == *kw, | 109 | Some(ref t) => t.text == *kw, |
108 | _ => false, | 110 | _ => false, |
109 | } | 111 | } |
110 | } | 112 | } |
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index bc1c88070..5f8585878 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -8,7 +8,6 @@ description = "Comment and whitespace preserving parser for the Rust langauge" | |||
8 | repository = "https://github.com/rust-analyzer/rust-analyzer" | 8 | repository = "https://github.com/rust-analyzer/rust-analyzer" |
9 | 9 | ||
10 | [dependencies] | 10 | [dependencies] |
11 | unicode-xid = "0.1.0" | ||
12 | itertools = "0.8.0" | 11 | itertools = "0.8.0" |
13 | rowan = "0.6.1" | 12 | rowan = "0.6.1" |
14 | ra_rustc_lexer = { version = "0.1.0-pre.2" } | 13 | ra_rustc_lexer = { version = "0.1.0-pre.2" } |
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index c5746d98d..6f0489617 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -139,6 +139,52 @@ fn test_doc_comment_preserves_newlines() { | |||
139 | } | 139 | } |
140 | 140 | ||
141 | #[test] | 141 | #[test] |
142 | fn test_doc_comment_single_line_block_strips_suffix() { | ||
143 | let file = SourceFile::parse( | ||
144 | r#" | ||
145 | /** this is mod foo*/ | ||
146 | mod foo {} | ||
147 | "#, | ||
148 | ) | ||
149 | .ok() | ||
150 | .unwrap(); | ||
151 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
152 | assert_eq!("this is mod foo", module.doc_comment_text().unwrap()); | ||
153 | } | ||
154 | |||
155 | #[test] | ||
156 | fn test_doc_comment_single_line_block_strips_suffix_whitespace() { | ||
157 | let file = SourceFile::parse( | ||
158 | r#" | ||
159 | /** this is mod foo */ | ||
160 | mod foo {} | ||
161 | "#, | ||
162 | ) | ||
163 | .ok() | ||
164 | .unwrap(); | ||
165 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
166 | assert_eq!("this is mod foo", module.doc_comment_text().unwrap()); | ||
167 | } | ||
168 | |||
169 | #[test] | ||
170 | fn test_doc_comment_multi_line_block_strips_suffix() { | ||
171 | let file = SourceFile::parse( | ||
172 | r#" | ||
173 | /** | ||
174 | this | ||
175 | is | ||
176 | mod foo | ||
177 | */ | ||
178 | mod foo {} | ||
179 | "#, | ||
180 | ) | ||
181 | .ok() | ||
182 | .unwrap(); | ||
183 | let module = file.syntax().descendants().find_map(Module::cast).unwrap(); | ||
184 | assert_eq!(" this\n is\n mod foo", module.doc_comment_text().unwrap()); | ||
185 | } | ||
186 | |||
187 | #[test] | ||
142 | fn test_where_predicates() { | 188 | fn test_where_predicates() { |
143 | fn assert_bound(text: &str, bound: Option<TypeBound>) { | 189 | fn assert_bound(text: &str, bound: Option<TypeBound>) { |
144 | assert_eq!(text, bound.unwrap().syntax().text().to_string()); | 190 | assert_eq!(text, bound.unwrap().syntax().text().to_string()); |
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 6ed1b5213..1b9a2b20c 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -115,8 +115,8 @@ pub trait DocCommentsOwner: AstNode { | |||
115 | } | 115 | } |
116 | 116 | ||
117 | /// Returns the textual content of a doc comment block as a single string. | 117 | /// Returns the textual content of a doc comment block as a single string. |
118 | /// That is, strips leading `///` (+ optional 1 character of whitespace) | 118 | /// That is, strips leading `///` (+ optional 1 character of whitespace), |
119 | /// and joins lines. | 119 | /// trailing `*/`, trailing whitespace and then joins the lines. |
120 | fn doc_comment_text(&self) -> Option<String> { | 120 | fn doc_comment_text(&self) -> Option<String> { |
121 | let mut has_comments = false; | 121 | let mut has_comments = false; |
122 | let docs = self | 122 | let docs = self |
@@ -136,7 +136,13 @@ pub trait DocCommentsOwner: AstNode { | |||
136 | prefix_len | 136 | prefix_len |
137 | }; | 137 | }; |
138 | 138 | ||
139 | line[pos..].to_owned() | 139 | let end = if comment.kind().shape.is_block() && line.ends_with("*/") { |
140 | line.len() - 2 | ||
141 | } else { | ||
142 | line.len() | ||
143 | }; | ||
144 | |||
145 | line[pos..end].trim_end().to_owned() | ||
140 | }) | 146 | }) |
141 | .join("\n"); | 147 | .join("\n"); |
142 | 148 | ||