aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock67
-rw-r--r--crates/ra_hir/Cargo.toml2
-rw-r--r--crates/ra_hir/src/source_binder.rs35
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs14
-rw-r--r--crates/ra_ide_api/Cargo.toml2
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs65
-rw-r--r--crates/ra_syntax/Cargo.toml1
7 files changed, 131 insertions, 55 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]]
4name = "aho-corasick" 4name = "aho-corasick"
5version = "0.7.4" 5version = "0.7.6"
6source = "registry+https://github.com/rust-lang/crates.io-index" 6source = "registry+https://github.com/rust-lang/crates.io-index"
7dependencies = [ 7dependencies = [
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]]
56name = "backtrace" 56name = "backtrace"
57version = "0.3.33" 57version = "0.3.34"
58source = "registry+https://github.com/rust-lang/crates.io-index" 58source = "registry+https://github.com/rust-lang/crates.io-index"
59dependencies = [ 59dependencies = [
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"
422version = "0.12.1" 422version = "0.12.1"
423source = "registry+https://github.com/rust-lang/crates.io-index" 423source = "registry+https://github.com/rust-lang/crates.io-index"
424dependencies = [ 424dependencies = [
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"
431version = "0.1.5" 431version = "0.1.5"
432source = "registry+https://github.com/rust-lang/crates.io-index" 432source = "registry+https://github.com/rust-lang/crates.io-index"
433dependencies = [ 433dependencies = [
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]]
633name = "insta" 633name = "insta"
634version = "0.9.0" 634version = "0.10.0"
635source = "registry+https://github.com/rust-lang/crates.io-index" 635source = "registry+https://github.com/rust-lang/crates.io-index"
636dependencies = [ 636dependencies = [
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"
1213dependencies = [ 1213dependencies = [
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 = [
1285name = "ra_prof" 1285name = "ra_prof"
1286version = "0.1.0" 1286version = "0.1.0"
1287dependencies = [ 1287dependencies = [
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]]
1552name = "regex" 1551name = "regex"
1553version = "1.2.0" 1552version = "1.2.1"
1554source = "registry+https://github.com/rust-lang/crates.io-index" 1553source = "registry+https://github.com/rust-lang/crates.io-index"
1555dependencies = [ 1554dependencies = [
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]]
1564name = "regex-syntax" 1562name = "regex-syntax"
1565version = "0.6.10" 1563version = "0.6.11"
1566source = "registry+https://github.com/rust-lang/crates.io-index" 1564source = "registry+https://github.com/rust-lang/crates.io-index"
1567dependencies = [
1568 "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
1569]
1570 1565
1571[[package]] 1566[[package]]
1572name = "relative-path" 1567name = "relative-path"
@@ -1593,7 +1588,7 @@ dependencies = [
1593 1588
1594[[package]] 1589[[package]]
1595name = "rowan" 1590name = "rowan"
1596version = "0.6.1" 1591version = "0.6.2"
1597source = "registry+https://github.com/rust-lang/crates.io-index" 1592source = "registry+https://github.com/rust-lang/crates.io-index"
1598dependencies = [ 1593dependencies = [
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"
1917source = "registry+https://github.com/rust-lang/crates.io-index" 1912source = "registry+https://github.com/rust-lang/crates.io-index"
1918 1913
1919[[package]] 1914[[package]]
1920name = "ucd-util"
1921version = "0.1.5"
1922source = "registry+https://github.com/rust-lang/crates.io-index"
1923
1924[[package]]
1925name = "unic-char-property" 1915name = "unic-char-property"
1926version = "0.7.0" 1916version = "0.7.0"
1927source = "registry+https://github.com/rust-lang/crates.io-index" 1917source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2024,11 +2014,6 @@ dependencies = [
2024] 2014]
2025 2015
2026[[package]] 2016[[package]]
2027name = "utf8-ranges"
2028version = "1.0.3"
2029source = "registry+https://github.com/rust-lang/crates.io-index"
2030
2031[[package]]
2032name = "uuid" 2017name = "uuid"
2033version = "0.7.4" 2018version = "0.7.4"
2034source = "registry+https://github.com/rust-lang/crates.io-index" 2019source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2117,13 +2102,13 @@ version = "0.5.0"
2117source = "registry+https://github.com/rust-lang/crates.io-index" 2102source = "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"
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" }
27lalrpop-intern = "0.15.1" 27lalrpop-intern = "0.15.1"
28 28
29[dev-dependencies] 29[dev-dependencies]
30insta = "0.9.0" 30insta = "0.10.0"
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index c2c6921cb..e86716d74 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -18,14 +18,18 @@ use ra_syntax::{
18use rustc_hash::{FxHashMap, FxHashSet}; 18use rustc_hash::{FxHashMap, FxHashSet};
19 19
20use crate::{ 20use crate::{
21 expr,
22 expr::{ 21 expr::{
22 self,
23 scope::{ExprScopes, ScopeId}, 23 scope::{ExprScopes, ScopeId},
24 BodySourceMap, 24 BodySourceMap,
25 }, 25 },
26 ids::LocationCtx, 26 ids::LocationCtx,
27 name,
28 path::{PathKind, PathSegment},
29 ty::method_resolution::implements_trait,
27 AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId, 30 AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId,
28 MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty, 31 MacroDef, Module, ModuleDef, Name, Path, PerNs, Resolution, Resolver, Static, Struct, Trait,
32 Ty,
29}; 33};
30 34
31/// Locates the module by `FileId`. Picks topmost module in the file. 35/// Locates the module by `FileId`. Picks topmost module in the file.
@@ -409,6 +413,33 @@ impl SourceAnalyzer {
409 crate::ty::autoderef(db, &self.resolver, canonical).map(|canonical| canonical.value) 413 crate::ty::autoderef(db, &self.resolver, canonical).map(|canonical| canonical.value)
410 } 414 }
411 415
416 /// Checks that particular type `ty` implements `std::future::Future`.
417 /// This function is used in `.await` syntax completion.
418 pub fn impls_future(&self, db: &impl HirDatabase, ty: Ty) -> bool {
419 let std_future_path = Path {
420 kind: PathKind::Abs,
421 segments: vec![
422 PathSegment { name: name::STD, args_and_bindings: None },
423 PathSegment { name: name::FUTURE_MOD, args_and_bindings: None },
424 PathSegment { name: name::FUTURE_TYPE, args_and_bindings: None },
425 ],
426 };
427
428 let std_future_trait =
429 match self.resolver.resolve_path_segments(db, &std_future_path).into_fully_resolved() {
430 PerNs { types: Some(Resolution::Def(ModuleDef::Trait(trait_))), .. } => trait_,
431 _ => return false,
432 };
433
434 let krate = match self.resolver.krate() {
435 Some(krate) => krate,
436 _ => return false,
437 };
438
439 let canonical_ty = crate::ty::Canonical { value: ty, num_vars: 0 };
440 implements_trait(&canonical_ty, db, &self.resolver, krate, std_future_trait)
441 }
442
412 #[cfg(test)] 443 #[cfg(test)]
413 pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> { 444 pub(crate) fn body_source_map(&self) -> Arc<BodySourceMap> {
414 self.body_source_map.clone().unwrap() 445 self.body_source_map.clone().unwrap()
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index d421bf9ef..88d012a74 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -255,6 +255,20 @@ fn iterate_inherent_methods<T>(
255 None 255 None
256} 256}
257 257
258pub(crate) fn implements_trait(
259 ty: &Canonical<Ty>,
260 db: &impl HirDatabase,
261 resolver: &Resolver,
262 krate: Crate,
263 trait_: Trait,
264) -> bool {
265 let env = lower::trait_env(db, resolver);
266 let goal = generic_implements_goal(db, env.clone(), trait_, ty.clone());
267 let solution = db.trait_solve(krate, goal);
268
269 solution.is_some()
270}
271
258impl Ty { 272impl Ty {
259 // This would be nicer if it just returned an iterator, but that runs into 273 // This would be nicer if it just returned an iterator, but that runs into
260 // lifetime problems, because we need to borrow temp `CrateImplBlocks`. 274 // lifetime problems, because we need to borrow temp `CrateImplBlocks`.
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" }
27ra_assists = { path = "../ra_assists" } 27ra_assists = { path = "../ra_assists" }
28 28
29[dev-dependencies] 29[dev-dependencies]
30insta = "0.9.0" 30insta = "0.10.0"
31 31
32[dev-dependencies.proptest] 32[dev-dependencies.proptest]
33version = "0.9.0" 33version = "0.9.0"
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index 536ba36df..d43ff2eec 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -1,19 +1,36 @@
1use hir::{AdtDef, Ty, TypeCtor}; 1use hir::{AdtDef, Ty, TypeCtor};
2 2
3use crate::completion::{CompletionContext, Completions}; 3use crate::completion::completion_item::CompletionKind;
4use crate::{
5 completion::{completion_context::CompletionContext, completion_item::Completions},
6 CompletionItem,
7};
4use rustc_hash::FxHashSet; 8use rustc_hash::FxHashSet;
5 9
6/// Complete dot accesses, i.e. fields or methods (currently only fields). 10/// Complete dot accesses, i.e. fields or methods (and .await syntax).
7pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) { 11pub(super) fn complete_dot(acc: &mut Completions, ctx: &CompletionContext) {
8 let receiver_ty = 12 let dot_receiver = match &ctx.dot_receiver {
9 match ctx.dot_receiver.as_ref().and_then(|it| ctx.analyzer.type_of(ctx.db, it)) { 13 Some(expr) => expr,
10 Some(it) => it, 14 _ => return,
11 None => return, 15 };
12 }; 16
17 let receiver_ty = match ctx.analyzer.type_of(ctx.db, &dot_receiver) {
18 Some(ty) => ty,
19 _ => return,
20 };
21
13 if !ctx.is_call { 22 if !ctx.is_call {
14 complete_fields(acc, ctx, receiver_ty.clone()); 23 complete_fields(acc, ctx, receiver_ty.clone());
15 } 24 }
16 complete_methods(acc, ctx, receiver_ty); 25 complete_methods(acc, ctx, receiver_ty.clone());
26
27 // Suggest .await syntax for types that implement Future trait
28 if ctx.analyzer.impls_future(ctx.db, receiver_ty) {
29 CompletionItem::new(CompletionKind::Keyword, ctx.source_range(), "await")
30 .detail("expr.await")
31 .insert_text("await")
32 .add_to(acc);
33 }
17} 34}
18 35
19fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { 36fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) {
@@ -406,4 +423,36 @@ mod tests {
406 "### 423 "###
407 ); 424 );
408 } 425 }
426
427 #[test]
428 fn test_completion_await_impls_future() {
429 assert_debug_snapshot_matches!(
430 do_completion(
431 r###"
432 //- /main.rs
433 use std::future::*;
434 struct A {}
435 impl Future for A {}
436 fn foo(a: A) {
437 a.<|>
438 }
439
440 //- /std/lib.rs
441 pub mod future {
442 pub trait Future {}
443 }
444 "###, CompletionKind::Keyword),
445 @r###"
446 ⋮[
447 ⋮ CompletionItem {
448 ⋮ label: "await",
449 ⋮ source_range: [74; 74),
450 ⋮ delete: [74; 74),
451 ⋮ insert: "await",
452 ⋮ detail: "expr.await",
453 ⋮ },
454 ⋮]
455 "###
456 )
457 }
409} 458}
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"
8repository = "https://github.com/rust-analyzer/rust-analyzer" 8repository = "https://github.com/rust-analyzer/rust-analyzer"
9 9
10[dependencies] 10[dependencies]
11unicode-xid = "0.1.0"
12itertools = "0.8.0" 11itertools = "0.8.0"
13rowan = "0.6.1" 12rowan = "0.6.1"
14ra_rustc_lexer = { version = "0.1.0-pre.2" } 13ra_rustc_lexer = { version = "0.1.0-pre.2" }