aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yaml6
-rw-r--r--Cargo.lock200
-rw-r--r--README.md5
-rw-r--r--bors.toml2
-rw-r--r--crates/ra_assists/src/assist_ctx.rs2
-rw-r--r--crates/ra_assists/src/assists/auto_import.rs210
-rw-r--r--crates/ra_assists/src/assists/inline_local_variable.rs15
-rw-r--r--crates/ra_assists/src/doc_tests.rs4
-rw-r--r--crates/ra_assists/src/doc_tests/generated.rs19
-rw-r--r--crates/ra_assists/src/lib.rs177
-rw-r--r--crates/ra_cargo_watch/Cargo.toml5
-rw-r--r--crates/ra_cargo_watch/src/conv.rs2
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_clippy_pass_by_ref.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_clippy_pass_by_ref.snap)0
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_handles_macro_location.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_handles_macro_location.snap)0
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_macro_compiler_error.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_macro_compiler_error.snap)0
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_incompatible_type_for_trait.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_incompatible_type_for_trait.snap)0
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_mismatched_type.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_mismatched_type.snap)0
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_unused_variable.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_unused_variable.snap)0
-rw-r--r--crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_wrong_number_of_parameters.snap (renamed from crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_wrong_number_of_parameters.snap)0
-rw-r--r--crates/ra_cargo_watch/src/lib.rs50
-rw-r--r--crates/ra_cli/Cargo.toml2
-rw-r--r--crates/ra_hir/src/db.rs22
-rw-r--r--crates/ra_hir/src/lib.rs1
-rw-r--r--crates/ra_hir_def/Cargo.toml2
-rw-r--r--crates/ra_hir_def/src/find_path.rs99
-rw-r--r--crates/ra_hir_def/src/marks.rs1
-rw-r--r--crates/ra_hir_def/src/nameres.rs40
-rw-r--r--crates/ra_hir_def/src/nameres/tests.rs43
-rw-r--r--crates/ra_hir_expand/src/name.rs2
-rw-r--r--crates/ra_hir_ty/Cargo.toml8
-rw-r--r--crates/ra_hir_ty/src/lib.rs2
-rw-r--r--crates/ra_hir_ty/src/tests/coercion.rs96
-rw-r--r--crates/ra_hir_ty/src/tests/regression.rs8
-rw-r--r--crates/ra_hir_ty/src/tests/simple.rs70
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs4
-rw-r--r--crates/ra_hir_ty/src/traits.rs19
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs108
-rw-r--r--crates/ra_ide/Cargo.toml2
-rw-r--r--crates/ra_ide/src/assists.rs7
-rw-r--r--crates/ra_ide/src/change.rs61
-rw-r--r--crates/ra_ide/src/expand.rs8
-rw-r--r--crates/ra_ide/src/imports_locator.rs76
-rw-r--r--crates/ra_ide/src/lib.rs4
-rw-r--r--crates/ra_ide/src/references.rs138
-rw-r--r--crates/ra_ide/src/runnables.rs16
-rw-r--r--crates/ra_ide/src/snapshots/highlighting.html10
-rw-r--r--crates/ra_ide/src/snapshots/rainbow_highlighting.html12
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs289
-rw-r--r--crates/ra_lsp_server/Cargo.toml7
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs133
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs5
-rw-r--r--crates/ra_lsp_server/src/world.rs4
-rw-r--r--crates/ra_prof/src/lib.rs15
-rw-r--r--crates/test_utils/src/lib.rs97
-rw-r--r--crates/test_utils/src/marks.rs2
-rw-r--r--docs/dev/README.md88
-rw-r--r--docs/dev/architecture.md79
-rw-r--r--docs/dev/debugging.md2
-rw-r--r--docs/user/README.md2
-rw-r--r--docs/user/assists.md18
-rw-r--r--editors/code/package-lock.json102
-rw-r--r--editors/code/package.json14
-rw-r--r--editors/code/src/client.ts8
63 files changed, 1669 insertions, 754 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 395ce1ef4..77c92512a 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -1,4 +1,4 @@
1name: CI-Release 1name: release
2on: 2on:
3 push: 3 push:
4 branches: 4 branches:
@@ -132,7 +132,9 @@ jobs:
132 132
133 - name: Create Release 133 - name: Create Release
134 id: create_release 134 id: create_release
135 uses: actions/create-release@v1 135 # uses: actions/create-release@v1
136 # https://github.com/actions/create-release/pull/32
137 uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
136 env: 138 env:
137 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 139 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138 with: 140 with:
diff --git a/Cargo.lock b/Cargo.lock
index 67822cb8a..01e86ab0e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
88 88
89[[package]] 89[[package]]
90name = "bstr" 90name = "bstr"
91version = "0.2.9" 91version = "0.2.10"
92source = "registry+https://github.com/rust-lang/crates.io-index" 92source = "registry+https://github.com/rust-lang/crates.io-index"
93dependencies = [ 93dependencies = [
94 "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 94 "memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -115,7 +115,7 @@ dependencies = [
115 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 115 "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
116 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 116 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
117 "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 117 "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
118 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 118 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
119] 119]
120 120
121[[package]] 121[[package]]
@@ -131,37 +131,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
131[[package]] 131[[package]]
132name = "chalk-derive" 132name = "chalk-derive"
133version = "0.1.0" 133version = "0.1.0"
134source = "git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5#ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" 134source = "git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75#af48f302a1f571b3ca418f7c5aa639a144a34f75"
135dependencies = [ 135dependencies = [
136 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 136 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
137 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 137 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
138 "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", 138 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
139] 139]
140 140
141[[package]] 141[[package]]
142name = "chalk-engine" 142name = "chalk-engine"
143version = "0.9.0" 143version = "0.9.0"
144source = "git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5#ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" 144source = "git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75#af48f302a1f571b3ca418f7c5aa639a144a34f75"
145dependencies = [ 145dependencies = [
146 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 146 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
147 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 147 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
148] 148]
149 149
150[[package]] 150[[package]]
151name = "chalk-ir" 151name = "chalk-ir"
152version = "0.1.0" 152version = "0.1.0"
153source = "git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5#ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" 153source = "git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75#af48f302a1f571b3ca418f7c5aa639a144a34f75"
154dependencies = [ 154dependencies = [
155 "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 155 "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
156 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 156 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
157 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 157 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
158 "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", 158 "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
159] 159]
160 160
161[[package]] 161[[package]]
162name = "chalk-macros" 162name = "chalk-macros"
163version = "0.1.1" 163version = "0.1.1"
164source = "git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5#ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" 164source = "git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75#af48f302a1f571b3ca418f7c5aa639a144a34f75"
165dependencies = [ 165dependencies = [
166 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 166 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
167] 167]
@@ -169,24 +169,24 @@ dependencies = [
169[[package]] 169[[package]]
170name = "chalk-rust-ir" 170name = "chalk-rust-ir"
171version = "0.1.0" 171version = "0.1.0"
172source = "git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5#ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" 172source = "git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75#af48f302a1f571b3ca418f7c5aa639a144a34f75"
173dependencies = [ 173dependencies = [
174 "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 174 "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
175 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 175 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
176 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 176 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
177 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 177 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
178] 178]
179 179
180[[package]] 180[[package]]
181name = "chalk-solve" 181name = "chalk-solve"
182version = "0.1.0" 182version = "0.1.0"
183source = "git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5#ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" 183source = "git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75#af48f302a1f571b3ca418f7c5aa639a144a34f75"
184dependencies = [ 184dependencies = [
185 "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 185 "chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
186 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 186 "chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
187 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 187 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
188 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 188 "chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
189 "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 189 "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
190 "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", 190 "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
191 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", 191 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
192 "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", 192 "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -214,7 +214,7 @@ dependencies = [
214 214
215[[package]] 215[[package]]
216name = "console" 216name = "console"
217version = "0.9.1" 217version = "0.9.2"
218source = "registry+https://github.com/rust-lang/crates.io-index" 218source = "registry+https://github.com/rust-lang/crates.io-index"
219dependencies = [ 219dependencies = [
220 "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 220 "clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -326,7 +326,6 @@ name = "env_logger"
326version = "0.7.1" 326version = "0.7.1"
327source = "registry+https://github.com/rust-lang/crates.io-index" 327source = "registry+https://github.com/rust-lang/crates.io-index"
328dependencies = [ 328dependencies = [
329 "humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
330 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 329 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
331] 330]
332 331
@@ -421,7 +420,7 @@ version = "0.4.4"
421source = "registry+https://github.com/rust-lang/crates.io-index" 420source = "registry+https://github.com/rust-lang/crates.io-index"
422dependencies = [ 421dependencies = [
423 "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", 422 "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
424 "bstr 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", 423 "bstr 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
425 "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", 424 "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
426 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 425 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
427 "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 426 "regex 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -444,21 +443,13 @@ dependencies = [
444] 443]
445 444
446[[package]] 445[[package]]
447name = "humantime"
448version = "1.3.0"
449source = "registry+https://github.com/rust-lang/crates.io-index"
450dependencies = [
451 "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
452]
453
454[[package]]
455name = "idna" 446name = "idna"
456version = "0.2.0" 447version = "0.2.0"
457source = "registry+https://github.com/rust-lang/crates.io-index" 448source = "registry+https://github.com/rust-lang/crates.io-index"
458dependencies = [ 449dependencies = [
459 "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 450 "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
460 "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", 451 "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
461 "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", 452 "unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
462] 453]
463 454
464[[package]] 455[[package]]
@@ -489,16 +480,15 @@ dependencies = [
489 480
490[[package]] 481[[package]]
491name = "insta" 482name = "insta"
492version = "0.12.0" 483version = "0.13.1"
493source = "registry+https://github.com/rust-lang/crates.io-index" 484source = "registry+https://github.com/rust-lang/crates.io-index"
494dependencies = [ 485dependencies = [
495 "console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 486 "console 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
496 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 487 "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)", 488 "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
498 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 489 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
499 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 490 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
500 "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", 491 "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
501 "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
502] 492]
503 493
504[[package]] 494[[package]]
@@ -519,7 +509,7 @@ dependencies = [
519 509
520[[package]] 510[[package]]
521name = "itoa" 511name = "itoa"
522version = "0.4.4" 512version = "0.4.5"
523source = "registry+https://github.com/rust-lang/crates.io-index" 513source = "registry+https://github.com/rust-lang/crates.io-index"
524 514
525[[package]] 515[[package]]
@@ -619,18 +609,18 @@ dependencies = [
619 "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 609 "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
620 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 610 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
621 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 611 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
622 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 612 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
623] 613]
624 614
625[[package]] 615[[package]]
626name = "lsp-types" 616name = "lsp-types"
627version = "0.69.0" 617version = "0.70.0"
628source = "registry+https://github.com/rust-lang/crates.io-index" 618source = "registry+https://github.com/rust-lang/crates.io-index"
629dependencies = [ 619dependencies = [
630 "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", 620 "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
631 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 621 "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
632 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 622 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
633 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 623 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
634 "serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 624 "serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
635 "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 625 "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
636] 626]
@@ -739,7 +729,7 @@ dependencies = [
739 729
740[[package]] 730[[package]]
741name = "once_cell" 731name = "once_cell"
742version = "1.3.0" 732version = "1.3.1"
743source = "registry+https://github.com/rust-lang/crates.io-index" 733source = "registry+https://github.com/rust-lang/crates.io-index"
744 734
745[[package]] 735[[package]]
@@ -784,9 +774,9 @@ version = "0.1.6"
784source = "registry+https://github.com/rust-lang/crates.io-index" 774source = "registry+https://github.com/rust-lang/crates.io-index"
785dependencies = [ 775dependencies = [
786 "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", 776 "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)",
787 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 777 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
788 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 778 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
789 "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", 779 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
790] 780]
791 781
792[[package]] 782[[package]]
@@ -818,14 +808,14 @@ name = "proc-macro-hack"
818version = "0.5.11" 808version = "0.5.11"
819source = "registry+https://github.com/rust-lang/crates.io-index" 809source = "registry+https://github.com/rust-lang/crates.io-index"
820dependencies = [ 810dependencies = [
821 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 811 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
822 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 812 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
823 "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", 813 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
824] 814]
825 815
826[[package]] 816[[package]]
827name = "proc-macro2" 817name = "proc-macro2"
828version = "1.0.7" 818version = "1.0.8"
829source = "registry+https://github.com/rust-lang/crates.io-index" 819source = "registry+https://github.com/rust-lang/crates.io-index"
830dependencies = [ 820dependencies = [
831 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 821 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -833,7 +823,7 @@ dependencies = [
833 823
834[[package]] 824[[package]]
835name = "proptest" 825name = "proptest"
836version = "0.9.4" 826version = "0.9.5"
837source = "registry+https://github.com/rust-lang/crates.io-index" 827source = "registry+https://github.com/rust-lang/crates.io-index"
838dependencies = [ 828dependencies = [
839 "bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 829 "bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -858,7 +848,7 @@ name = "quote"
858version = "1.0.2" 848version = "1.0.2"
859source = "registry+https://github.com/rust-lang/crates.io-index" 849source = "registry+https://github.com/rust-lang/crates.io-index"
860dependencies = [ 850dependencies = [
861 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 851 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
862] 852]
863 853
864[[package]] 854[[package]]
@@ -902,12 +892,12 @@ version = "0.1.0"
902dependencies = [ 892dependencies = [
903 "cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", 893 "cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
904 "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 894 "crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
905 "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 895 "insta 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
906 "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 896 "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
907 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 897 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
908 "lsp-types 0.69.0 (registry+https://github.com/rust-lang/crates.io-index)", 898 "lsp-types 0.70.0 (registry+https://github.com/rust-lang/crates.io-index)",
909 "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 899 "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
910 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 900 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
911] 901]
912 902
913[[package]] 903[[package]]
@@ -979,9 +969,9 @@ dependencies = [
979 "anymap 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", 969 "anymap 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
980 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 970 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
981 "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", 971 "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
982 "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 972 "insta 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
983 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 973 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
984 "once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 974 "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
985 "ra_arena 0.1.0", 975 "ra_arena 0.1.0",
986 "ra_cfg 0.1.0", 976 "ra_cfg 0.1.0",
987 "ra_db 0.1.0", 977 "ra_db 0.1.0",
@@ -1014,11 +1004,11 @@ name = "ra_hir_ty"
1014version = "0.1.0" 1004version = "0.1.0"
1015dependencies = [ 1005dependencies = [
1016 "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 1006 "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
1017 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 1007 "chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
1018 "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 1008 "chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
1019 "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)", 1009 "chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)",
1020 "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", 1010 "ena 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
1021 "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 1011 "insta 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
1022 "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)", 1012 "lalrpop-intern 0.15.1 (registry+https://github.com/rust-lang/crates.io-index)",
1023 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 1013 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
1024 "ra_arena 0.1.0", 1014 "ra_arena 0.1.0",
@@ -1039,12 +1029,12 @@ dependencies = [
1039 "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 1029 "format-buf 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
1040 "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 1030 "fst 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
1041 "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1031 "indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1042 "insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", 1032 "insta 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
1043 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", 1033 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
1044 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 1034 "join_to_string 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
1045 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 1035 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
1046 "once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 1036 "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1047 "proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", 1037 "proptest 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
1048 "ra_assists 0.1.0", 1038 "ra_assists 0.1.0",
1049 "ra_cfg 0.1.0", 1039 "ra_cfg 0.1.0",
1050 "ra_db 0.1.0", 1040 "ra_db 0.1.0",
@@ -1071,7 +1061,7 @@ dependencies = [
1071 "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1061 "jod-thread 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1072 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", 1062 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
1073 "lsp-server 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1063 "lsp-server 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1074 "lsp-types 0.69.0 (registry+https://github.com/rust-lang/crates.io-index)", 1064 "lsp-types 0.70.0 (registry+https://github.com/rust-lang/crates.io-index)",
1075 "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", 1065 "parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
1076 "ra_cargo_watch 0.1.0", 1066 "ra_cargo_watch 0.1.0",
1077 "ra_ide 0.1.0", 1067 "ra_ide 0.1.0",
@@ -1084,10 +1074,11 @@ dependencies = [
1084 "relative-path 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 1074 "relative-path 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
1085 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1075 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1086 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 1076 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
1087 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 1077 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
1088 "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1078 "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
1089 "test_utils 0.1.0", 1079 "test_utils 0.1.0",
1090 "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", 1080 "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
1081 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
1091] 1082]
1092 1083
1093[[package]] 1084[[package]]
@@ -1118,7 +1109,7 @@ dependencies = [
1118 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", 1109 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
1119 "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", 1110 "jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
1120 "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", 1111 "jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
1121 "once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 1112 "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1122] 1113]
1123 1114
1124[[package]] 1115[[package]]
@@ -1132,7 +1123,7 @@ dependencies = [
1132 "ra_db 0.1.0", 1123 "ra_db 0.1.0",
1133 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 1124 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
1134 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 1125 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
1135 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 1126 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
1136] 1127]
1137 1128
1138[[package]] 1129[[package]]
@@ -1141,7 +1132,7 @@ version = "0.1.0"
1141dependencies = [ 1132dependencies = [
1142 "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", 1133 "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
1143 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", 1134 "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
1144 "once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 1135 "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1145 "ra_parser 0.1.0", 1136 "ra_parser 0.1.0",
1146 "ra_text_edit 0.1.0", 1137 "ra_text_edit 0.1.0",
1147 "rowan 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", 1138 "rowan 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1157,7 +1148,7 @@ dependencies = [
1157name = "ra_text_edit" 1148name = "ra_text_edit"
1158version = "0.1.0" 1149version = "0.1.0"
1159dependencies = [ 1150dependencies = [
1160 "proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)", 1151 "proptest 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
1161 "test_utils 0.1.0", 1152 "test_utils 0.1.0",
1162 "text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1153 "text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
1163] 1154]
@@ -1464,9 +1455,9 @@ version = "0.14.1"
1464source = "registry+https://github.com/rust-lang/crates.io-index" 1455source = "registry+https://github.com/rust-lang/crates.io-index"
1465dependencies = [ 1456dependencies = [
1466 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1457 "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1467 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 1458 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
1468 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1459 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1469 "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", 1460 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
1470] 1461]
1471 1462
1472[[package]] 1463[[package]]
@@ -1509,17 +1500,17 @@ name = "serde_derive"
1509version = "1.0.104" 1500version = "1.0.104"
1510source = "registry+https://github.com/rust-lang/crates.io-index" 1501source = "registry+https://github.com/rust-lang/crates.io-index"
1511dependencies = [ 1502dependencies = [
1512 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 1503 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
1513 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1504 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1514 "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", 1505 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
1515] 1506]
1516 1507
1517[[package]] 1508[[package]]
1518name = "serde_json" 1509name = "serde_json"
1519version = "1.0.44" 1510version = "1.0.45"
1520source = "registry+https://github.com/rust-lang/crates.io-index" 1511source = "registry+https://github.com/rust-lang/crates.io-index"
1521dependencies = [ 1512dependencies = [
1522 "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", 1513 "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
1523 "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1514 "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1524 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", 1515 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
1525] 1516]
@@ -1529,9 +1520,9 @@ name = "serde_repr"
1529version = "0.1.5" 1520version = "0.1.5"
1530source = "registry+https://github.com/rust-lang/crates.io-index" 1521source = "registry+https://github.com/rust-lang/crates.io-index"
1531dependencies = [ 1522dependencies = [
1532 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 1523 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
1533 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1524 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1534 "syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", 1525 "syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)",
1535] 1526]
1536 1527
1537[[package]] 1528[[package]]
@@ -1570,10 +1561,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1570 1561
1571[[package]] 1562[[package]]
1572name = "syn" 1563name = "syn"
1573version = "1.0.13" 1564version = "1.0.14"
1574source = "registry+https://github.com/rust-lang/crates.io-index" 1565source = "registry+https://github.com/rust-lang/crates.io-index"
1575dependencies = [ 1566dependencies = [
1576 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 1567 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
1577 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1568 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1578 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 1569 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
1579] 1570]
@@ -1604,7 +1595,7 @@ name = "test_utils"
1604version = "0.1.0" 1595version = "0.1.0"
1605dependencies = [ 1596dependencies = [
1606 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", 1597 "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
1607 "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", 1598 "serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)",
1608 "text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", 1599 "text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
1609] 1600]
1610 1601
@@ -1652,7 +1643,7 @@ dependencies = [
1652 1643
1653[[package]] 1644[[package]]
1654name = "unicode-normalization" 1645name = "unicode-normalization"
1655version = "0.1.11" 1646version = "0.1.12"
1656source = "registry+https://github.com/rust-lang/crates.io-index" 1647source = "registry+https://github.com/rust-lang/crates.io-index"
1657dependencies = [ 1648dependencies = [
1658 "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 1649 "smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1680,15 +1671,6 @@ dependencies = [
1680] 1671]
1681 1672
1682[[package]] 1673[[package]]
1683name = "uuid"
1684version = "0.8.1"
1685source = "registry+https://github.com/rust-lang/crates.io-index"
1686dependencies = [
1687 "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
1688 "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
1689]
1690
1691[[package]]
1692name = "version_check" 1674name = "version_check"
1693version = "0.9.1" 1675version = "0.9.1"
1694source = "registry+https://github.com/rust-lang/crates.io-index" 1676source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1760,7 +1742,7 @@ version = "0.1.0"
1760dependencies = [ 1742dependencies = [
1761 "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", 1743 "anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
1762 "pico-args 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1744 "pico-args 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1763 "proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", 1745 "proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
1764 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", 1746 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
1765 "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 1747 "walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
1766] 1748]
@@ -1787,21 +1769,21 @@ dependencies = [
1787"checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80" 1769"checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
1788"checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb" 1770"checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb"
1789"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 1771"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
1790"checksum bstr 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3ede750122d9d1f87919570cb2cccee38c84fbc8c5599b25c289af40625b7030" 1772"checksum bstr 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "fe8a65814ca90dfc9705af76bb6ba3c6e2534489a72270e797e603783bb4990b"
1791"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" 1773"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
1792"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" 1774"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
1793"checksum cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" 1775"checksum cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202"
1794"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" 1776"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
1795"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 1777"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
1796"checksum chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)" = "<none>" 1778"checksum chalk-derive 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)" = "<none>"
1797"checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)" = "<none>" 1779"checksum chalk-engine 0.9.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)" = "<none>"
1798"checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)" = "<none>" 1780"checksum chalk-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)" = "<none>"
1799"checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)" = "<none>" 1781"checksum chalk-macros 0.1.1 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)" = "<none>"
1800"checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)" = "<none>" 1782"checksum chalk-rust-ir 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)" = "<none>"
1801"checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5)" = "<none>" 1783"checksum chalk-solve 0.1.0 (git+https://github.com/rust-lang/chalk.git?rev=af48f302a1f571b3ca418f7c5aa639a144a34f75)" = "<none>"
1802"checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" 1784"checksum clicolors-control 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e"
1803"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 1785"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
1804"checksum console 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f5d540c2d34ac9dd0deb5f3b5f54c36c79efa78f6b3ad19106a554d07a7b5d9f" 1786"checksum console 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "45e0f3986890b3acbc782009e2629dfe2baa430ac091519ce3be26164a2ae6c0"
1805"checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" 1787"checksum crossbeam 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e"
1806"checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" 1788"checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c"
1807"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" 1789"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca"
@@ -1830,15 +1812,14 @@ dependencies = [
1830"checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" 1812"checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2"
1831"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" 1813"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
1832"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772" 1814"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772"
1833"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
1834"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" 1815"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
1835"checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc" 1816"checksum indexmap 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b54058f0a6ff80b6803da8faf8997cde53872b38f4023728f6830b06cd3c0dc"
1836"checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" 1817"checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8"
1837"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" 1818"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0"
1838"checksum insta 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d499dc062e841590a67230d853bce62d0abeb91304927871670b7c55c461349" 1819"checksum insta 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8df742abee84dbf27d20869c9adf77b0d8f7ea3eead13c2c9e3998d136a97058"
1839"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 1820"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
1840"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" 1821"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
1841"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" 1822"checksum itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
1842"checksum jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7" 1823"checksum jemalloc-ctl 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c502a5ff9dd2924f1ed32ba96e3b65735d837b4bfd978d3161b1702e66aca4b7"
1843"checksum jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45" 1824"checksum jemalloc-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45"
1844"checksum jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69" 1825"checksum jemallocator 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69"
@@ -1853,7 +1834,7 @@ dependencies = [
1853"checksum lock_api 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" 1834"checksum lock_api 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b"
1854"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 1835"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
1855"checksum lsp-server 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5383e043329615624bbf45e1ba27bd75c176762b2592855c659bc28ac580a06b" 1836"checksum lsp-server 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5383e043329615624bbf45e1ba27bd75c176762b2592855c659bc28ac580a06b"
1856"checksum lsp-types 0.69.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd78b254376c0734bb75c200616e256adbf2c3685497fcc1124db9daf5958630" 1837"checksum lsp-types 0.70.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef197b24cb3f12fc3984667a505691fec9d683204ddff56f12b2d1940e09a988"
1857"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 1838"checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
1858"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" 1839"checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223"
1859"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" 1840"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
@@ -1864,7 +1845,7 @@ dependencies = [
1864"checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" 1845"checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd"
1865"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" 1846"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
1866"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" 1847"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
1867"checksum once_cell 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5941ec2d5ee5916c709580d71553b81a633df245bcc73c04dcbd62152ceefc4" 1848"checksum once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b"
1868"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" 1849"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
1869"checksum parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" 1850"checksum parking_lot 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc"
1870"checksum parking_lot_core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" 1851"checksum parking_lot_core 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1"
@@ -1875,8 +1856,8 @@ dependencies = [
1875"checksum pico-args 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ad1f1b834a05d42dae330066e9699a173b28185b3bdc3dbf14ca239585de8cc" 1856"checksum pico-args 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ad1f1b834a05d42dae330066e9699a173b28185b3bdc3dbf14ca239585de8cc"
1876"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" 1857"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
1877"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" 1858"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5"
1878"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc" 1859"checksum proc-macro2 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3acb317c6ff86a4e579dfa00fc5e6cca91ecbb4e7eb2df0468805b674eb88548"
1879"checksum proptest 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cf147e022eacf0c8a054ab864914a7602618adba841d800a9a9868a5237a529f" 1860"checksum proptest 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bf6147d103a7c9d7598f4105cf049b15c99e2ecd93179bf024f0fd349be5ada4"
1880"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 1861"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
1881"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" 1862"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
1882"checksum ra_vfs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc898f237e4b4498959ae0100c688793a23e77624d44ef710ba70094217f98e0" 1863"checksum ra_vfs 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc898f237e4b4498959ae0100c688793a23e77624d44ef710ba70094217f98e0"
@@ -1917,14 +1898,14 @@ dependencies = [
1917"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1898"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
1918"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" 1899"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
1919"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" 1900"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
1920"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" 1901"checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b"
1921"checksum serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573" 1902"checksum serde_repr 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cd02c7587ec314570041b2754829f84d873ced14a96d1fd1823531e11db40573"
1922"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" 1903"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
1923"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" 1904"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
1924"checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4" 1905"checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4"
1925"checksum smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34836c9a295c62c2ce3514471117c5cb269891e8421b2aafdd910050576c4d8b" 1906"checksum smol_str 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34836c9a295c62c2ce3514471117c5cb269891e8421b2aafdd910050576c4d8b"
1926"checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" 1907"checksum superslice 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
1927"checksum syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4ff033220a41d1a57d8125eab57bf5263783dfdcc18688b1dacc6ce9651ef8" 1908"checksum syn 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "af6f3550d8dff9ef7dc34d384ac6f107e5d31c8f57d9f28e0081503f547ac8f5"
1928"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" 1909"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
1929"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" 1910"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625"
1930"checksum text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e08bbcb7a3adbda0eb23431206b653bdad3d8dea311e72d36bf2215e27a42579" 1911"checksum text_unit 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e08bbcb7a3adbda0eb23431206b653bdad3d8dea311e72d36bf2215e27a42579"
@@ -1933,11 +1914,10 @@ dependencies = [
1933"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" 1914"checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865"
1934"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" 1915"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
1935"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" 1916"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
1936"checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" 1917"checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4"
1937"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" 1918"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
1938"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 1919"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
1939"checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" 1920"checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb"
1940"checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11"
1941"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" 1921"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
1942"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" 1922"checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d"
1943"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 1923"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
diff --git a/README.md b/README.md
index 4a76ea6e3..2f6ed1e05 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,9 @@
4 4
5Rust Analyzer is an **experimental** modular compiler frontend for the Rust 5Rust Analyzer is an **experimental** modular compiler frontend for the Rust
6language. It is a part of a larger rls-2.0 effort to create excellent IDE 6language. It is a part of a larger rls-2.0 effort to create excellent IDE
7support for Rust. If you want to get involved, check the rls-2.0 working group 7support for Rust. If you want to get involved, check the rls-2.0 working group:
8in the compiler-team repository:
9 8
10https://github.com/rust-lang/compiler-team/tree/master/content/working-groups/rls-2.0 9https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0
11 10
12Work on the Rust Analyzer is sponsored by 11Work on the Rust Analyzer is sponsored by
13 12
diff --git a/bors.toml b/bors.toml
index bf5553df4..0bc71860f 100644
--- a/bors.toml
+++ b/bors.toml
@@ -1,6 +1,6 @@
1status = [ 1status = [
2 "Rust (ubuntu-latest)", 2 "Rust (ubuntu-latest)",
3 # "Rust (windows-latest)", 3 "Rust (windows-latest)",
4 "Rust (macos-latest)", 4 "Rust (macos-latest)",
5 "TypeScript" 5 "TypeScript"
6] 6]
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs
index 43f0d664b..2ab65ab99 100644
--- a/crates/ra_assists/src/assist_ctx.rs
+++ b/crates/ra_assists/src/assist_ctx.rs
@@ -101,7 +101,6 @@ impl<'a, DB: HirDatabase> AssistCtx<'a, DB> {
101 Some(assist) 101 Some(assist)
102 } 102 }
103 103
104 #[allow(dead_code)] // will be used for auto import assist with multiple actions
105 pub(crate) fn add_assist_group( 104 pub(crate) fn add_assist_group(
106 self, 105 self,
107 id: AssistId, 106 id: AssistId,
@@ -168,7 +167,6 @@ pub(crate) struct ActionBuilder {
168} 167}
169 168
170impl ActionBuilder { 169impl ActionBuilder {
171 #[allow(dead_code)]
172 /// Adds a custom label to the action, if it needs to be different from the assist label 170 /// Adds a custom label to the action, if it needs to be different from the assist label
173 pub(crate) fn label(&mut self, label: impl Into<String>) { 171 pub(crate) fn label(&mut self, label: impl Into<String>) {
174 self.label = Some(label.into()) 172 self.label = Some(label.into())
diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs
new file mode 100644
index 000000000..69126a1c9
--- /dev/null
+++ b/crates/ra_assists/src/assists/auto_import.rs
@@ -0,0 +1,210 @@
1use hir::db::HirDatabase;
2use ra_syntax::{
3 ast::{self, AstNode},
4 SmolStr,
5 SyntaxKind::USE_ITEM,
6 SyntaxNode,
7};
8
9use crate::{
10 assist_ctx::{ActionBuilder, Assist, AssistCtx},
11 auto_import_text_edit, AssistId, ImportsLocator,
12};
13
14// Assist: auto_import
15//
16// If the name is unresolved, provides all possible imports for it.
17//
18// ```
19// fn main() {
20// let map = HashMap<|>::new();
21// }
22// ```
23// ->
24// ```
25// use std::collections::HashMap;
26//
27// fn main() {
28// let map = HashMap<|>::new();
29// }
30// ```
31pub(crate) fn auto_import<F: ImportsLocator>(
32 ctx: AssistCtx<impl HirDatabase>,
33 imports_locator: &mut F,
34) -> Option<Assist> {
35 let path_to_import: ast::Path = ctx.find_node_at_offset()?;
36 let path_to_import_syntax = path_to_import.syntax();
37 if path_to_import_syntax.ancestors().find(|ancestor| ancestor.kind() == USE_ITEM).is_some() {
38 return None;
39 }
40
41 let module = path_to_import_syntax.ancestors().find_map(ast::Module::cast);
42 let position = match module.and_then(|it| it.item_list()) {
43 Some(item_list) => item_list.syntax().clone(),
44 None => {
45 let current_file = path_to_import_syntax.ancestors().find_map(ast::SourceFile::cast)?;
46 current_file.syntax().clone()
47 }
48 };
49 let source_analyzer = ctx.source_analyzer(&position, None);
50 let module_with_name_to_import = source_analyzer.module()?;
51 if source_analyzer.resolve_path(ctx.db, &path_to_import).is_some() {
52 return None;
53 }
54
55 let proposed_imports = imports_locator
56 .find_imports(&path_to_import_syntax.to_string())
57 .into_iter()
58 .filter_map(|module_def| module_with_name_to_import.find_use_path(ctx.db, module_def))
59 .filter(|use_path| !use_path.segments.is_empty())
60 .take(20)
61 .map(|import| import.to_string())
62 .collect::<std::collections::BTreeSet<_>>();
63 if proposed_imports.is_empty() {
64 return None;
65 }
66
67 ctx.add_assist_group(AssistId("auto_import"), "auto import", || {
68 proposed_imports
69 .into_iter()
70 .map(|import| import_to_action(import, &position, &path_to_import_syntax))
71 .collect()
72 })
73}
74
75fn import_to_action(import: String, position: &SyntaxNode, anchor: &SyntaxNode) -> ActionBuilder {
76 let mut action_builder = ActionBuilder::default();
77 action_builder.label(format!("Import `{}`", &import));
78 auto_import_text_edit(
79 position,
80 anchor,
81 &[SmolStr::new(import)],
82 action_builder.text_edit_builder(),
83 );
84 action_builder
85}
86
87#[cfg(test)]
88mod tests {
89 use super::*;
90 use crate::helpers::{
91 check_assist_with_imports_locator, check_assist_with_imports_locator_not_applicable,
92 TestImportsLocator,
93 };
94
95 #[test]
96 fn applicable_when_found_an_import() {
97 check_assist_with_imports_locator(
98 auto_import,
99 TestImportsLocator::new,
100 r"
101 <|>PubStruct
102
103 pub mod PubMod {
104 pub struct PubStruct;
105 }
106 ",
107 r"
108 <|>use PubMod::PubStruct;
109
110 PubStruct
111
112 pub mod PubMod {
113 pub struct PubStruct;
114 }
115 ",
116 );
117 }
118
119 #[test]
120 fn applicable_when_found_multiple_imports() {
121 check_assist_with_imports_locator(
122 auto_import,
123 TestImportsLocator::new,
124 r"
125 PubSt<|>ruct
126
127 pub mod PubMod1 {
128 pub struct PubStruct;
129 }
130 pub mod PubMod2 {
131 pub struct PubStruct;
132 }
133 pub mod PubMod3 {
134 pub struct PubStruct;
135 }
136 ",
137 r"
138 use PubMod1::PubStruct;
139
140 PubSt<|>ruct
141
142 pub mod PubMod1 {
143 pub struct PubStruct;
144 }
145 pub mod PubMod2 {
146 pub struct PubStruct;
147 }
148 pub mod PubMod3 {
149 pub struct PubStruct;
150 }
151 ",
152 );
153 }
154
155 #[test]
156 fn not_applicable_for_already_imported_types() {
157 check_assist_with_imports_locator_not_applicable(
158 auto_import,
159 TestImportsLocator::new,
160 r"
161 use PubMod::PubStruct;
162
163 PubStruct<|>
164
165 pub mod PubMod {
166 pub struct PubStruct;
167 }
168 ",
169 );
170 }
171
172 #[test]
173 fn not_applicable_for_types_with_private_paths() {
174 check_assist_with_imports_locator_not_applicable(
175 auto_import,
176 TestImportsLocator::new,
177 r"
178 PrivateStruct<|>
179
180 pub mod PubMod {
181 struct PrivateStruct;
182 }
183 ",
184 );
185 }
186
187 #[test]
188 fn not_applicable_when_no_imports_found() {
189 check_assist_with_imports_locator_not_applicable(
190 auto_import,
191 TestImportsLocator::new,
192 "
193 PubStruct<|>",
194 );
195 }
196
197 #[test]
198 fn not_applicable_in_import_statements() {
199 check_assist_with_imports_locator_not_applicable(
200 auto_import,
201 TestImportsLocator::new,
202 r"
203 use PubStruct<|>;
204
205 pub mod PubMod {
206 pub struct PubStruct;
207 }",
208 );
209 }
210}
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs
index d0c5c3b8c..83527d904 100644
--- a/crates/ra_assists/src/assists/inline_local_variable.rs
+++ b/crates/ra_assists/src/assists/inline_local_variable.rs
@@ -47,6 +47,9 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<
47 }; 47 };
48 let analyzer = ctx.source_analyzer(bind_pat.syntax(), None); 48 let analyzer = ctx.source_analyzer(bind_pat.syntax(), None);
49 let refs = analyzer.find_all_refs(&bind_pat); 49 let refs = analyzer.find_all_refs(&bind_pat);
50 if refs.is_empty() {
51 return None;
52 };
50 53
51 let mut wrap_in_parens = vec![true; refs.len()]; 54 let mut wrap_in_parens = vec![true; refs.len()];
52 55
@@ -645,4 +648,16 @@ fn foo() {
645}", 648}",
646 ); 649 );
647 } 650 }
651
652 #[test]
653 fn test_not_applicable_if_variable_unused() {
654 check_assist_not_applicable(
655 inline_local_variable,
656 "
657fn foo() {
658 let <|>a = 0;
659}
660 ",
661 )
662 }
648} 663}
diff --git a/crates/ra_assists/src/doc_tests.rs b/crates/ra_assists/src/doc_tests.rs
index 5dc1ee233..65d51428b 100644
--- a/crates/ra_assists/src/doc_tests.rs
+++ b/crates/ra_assists/src/doc_tests.rs
@@ -11,6 +11,10 @@ use test_utils::{assert_eq_text, extract_range_or_offset};
11use crate::test_db::TestDB; 11use crate::test_db::TestDB;
12 12
13fn check(assist_id: &str, before: &str, after: &str) { 13fn check(assist_id: &str, before: &str, after: &str) {
14 // FIXME we cannot get the imports search functionality here yet, but still need to generate a test and a doc for an assist
15 if assist_id == "auto_import" {
16 return;
17 }
14 let (selection, before) = extract_range_or_offset(before); 18 let (selection, before) = extract_range_or_offset(before);
15 let (db, file_id) = TestDB::with_single_file(&before); 19 let (db, file_id) = TestDB::with_single_file(&before);
16 let frange = FileRange { file_id, range: selection.into() }; 20 let frange = FileRange { file_id, range: selection.into() };
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
index 7d84dc8fb..ec4587ce7 100644
--- a/crates/ra_assists/src/doc_tests/generated.rs
+++ b/crates/ra_assists/src/doc_tests/generated.rs
@@ -215,6 +215,25 @@ fn main() {
215} 215}
216 216
217#[test] 217#[test]
218fn doctest_auto_import() {
219 check(
220 "auto_import",
221 r#####"
222fn main() {
223 let map = HashMap<|>::new();
224}
225"#####,
226 r#####"
227use std::collections::HashMap;
228
229fn main() {
230 let map = HashMap<|>::new();
231}
232"#####,
233 )
234}
235
236#[test]
218fn doctest_change_visibility() { 237fn doctest_change_visibility() {
219 check( 238 check(
220 "change_visibility", 239 "change_visibility",
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 3337805a5..625ebc4a2 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -14,7 +14,7 @@ mod test_db;
14pub mod ast_transform; 14pub mod ast_transform;
15 15
16use either::Either; 16use either::Either;
17use hir::db::HirDatabase; 17use hir::{db::HirDatabase, ModuleDef};
18use ra_db::FileRange; 18use ra_db::FileRange;
19use ra_syntax::{TextRange, TextUnit}; 19use ra_syntax::{TextRange, TextUnit};
20use ra_text_edit::TextEdit; 20use ra_text_edit::TextEdit;
@@ -77,6 +77,51 @@ where
77 }) 77 })
78} 78}
79 79
80/// A functionality for locating imports for the given name.
81///
82/// Currently has to be a trait with the real implementation provided by the ra_ide_api crate,
83/// due to the search functionality located there.
84/// Later, this trait should be removed completely and the search functionality moved to a separate crate,
85/// accessible from the ra_assists crate.
86pub trait ImportsLocator {
87 /// Finds all imports for the given name and the module that contains this name.
88 fn find_imports(&mut self, name_to_import: &str) -> Vec<ModuleDef>;
89}
90
91/// Return all the assists applicable at the given position
92/// and additional assists that need the imports locator functionality to work.
93///
94/// Assists are returned in the "resolved" state, that is with edit fully
95/// computed.
96pub fn assists_with_imports_locator<H, F>(
97 db: &H,
98 range: FileRange,
99 mut imports_locator: F,
100) -> Vec<ResolvedAssist>
101where
102 H: HirDatabase + 'static,
103 F: ImportsLocator,
104{
105 AssistCtx::with_ctx(db, range, true, |ctx| {
106 let mut assists = assists::all()
107 .iter()
108 .map(|f| f(ctx.clone()))
109 .chain(
110 assists::all_with_imports_locator()
111 .iter()
112 .map(|f| f(ctx.clone(), &mut imports_locator)),
113 )
114 .filter_map(std::convert::identity)
115 .map(|a| match a {
116 Assist::Resolved { assist } => assist,
117 Assist::Unresolved { .. } => unreachable!(),
118 })
119 .collect();
120 sort_assists(&mut assists);
121 assists
122 })
123}
124
80/// Return all the assists applicable at the given position. 125/// Return all the assists applicable at the given position.
81/// 126///
82/// Assists are returned in the "resolved" state, that is with edit fully 127/// Assists are returned in the "resolved" state, that is with edit fully
@@ -85,8 +130,6 @@ pub fn assists<H>(db: &H, range: FileRange) -> Vec<ResolvedAssist>
85where 130where
86 H: HirDatabase + 'static, 131 H: HirDatabase + 'static,
87{ 132{
88 use std::cmp::Ordering;
89
90 AssistCtx::with_ctx(db, range, true, |ctx| { 133 AssistCtx::with_ctx(db, range, true, |ctx| {
91 let mut a = assists::all() 134 let mut a = assists::all()
92 .iter() 135 .iter()
@@ -95,19 +138,24 @@ where
95 Assist::Resolved { assist } => assist, 138 Assist::Resolved { assist } => assist,
96 Assist::Unresolved { .. } => unreachable!(), 139 Assist::Unresolved { .. } => unreachable!(),
97 }) 140 })
98 .collect::<Vec<_>>(); 141 .collect();
99 a.sort_by(|a, b| match (a.get_first_action().target, b.get_first_action().target) { 142 sort_assists(&mut a);
100 (Some(a), Some(b)) => a.len().cmp(&b.len()),
101 (Some(_), None) => Ordering::Less,
102 (None, Some(_)) => Ordering::Greater,
103 (None, None) => Ordering::Equal,
104 });
105 a 143 a
106 }) 144 })
107} 145}
108 146
147fn sort_assists(assists: &mut Vec<ResolvedAssist>) {
148 use std::cmp::Ordering;
149 assists.sort_by(|a, b| match (a.get_first_action().target, b.get_first_action().target) {
150 (Some(a), Some(b)) => a.len().cmp(&b.len()),
151 (Some(_), None) => Ordering::Less,
152 (None, Some(_)) => Ordering::Greater,
153 (None, None) => Ordering::Equal,
154 });
155}
156
109mod assists { 157mod assists {
110 use crate::{Assist, AssistCtx}; 158 use crate::{Assist, AssistCtx, ImportsLocator};
111 use hir::db::HirDatabase; 159 use hir::db::HirDatabase;
112 160
113 mod add_derive; 161 mod add_derive;
@@ -116,6 +164,7 @@ mod assists {
116 mod add_custom_impl; 164 mod add_custom_impl;
117 mod add_new; 165 mod add_new;
118 mod apply_demorgan; 166 mod apply_demorgan;
167 mod auto_import;
119 mod invert_if; 168 mod invert_if;
120 mod flip_comma; 169 mod flip_comma;
121 mod flip_binexpr; 170 mod flip_binexpr;
@@ -168,15 +217,69 @@ mod assists {
168 early_return::convert_to_guarded_return, 217 early_return::convert_to_guarded_return,
169 ] 218 ]
170 } 219 }
220
221 pub(crate) fn all_with_imports_locator<'a, DB: HirDatabase, F: ImportsLocator>(
222 ) -> &'a [fn(AssistCtx<DB>, &mut F) -> Option<Assist>] {
223 &[auto_import::auto_import]
224 }
171} 225}
172 226
173#[cfg(test)] 227#[cfg(test)]
174mod helpers { 228mod helpers {
175 use ra_db::{fixture::WithFixture, FileRange}; 229 use hir::db::DefDatabase;
230 use ra_db::{fixture::WithFixture, FileId, FileRange};
176 use ra_syntax::TextRange; 231 use ra_syntax::TextRange;
177 use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range}; 232 use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range};
178 233
179 use crate::{test_db::TestDB, Assist, AssistCtx}; 234 use crate::{test_db::TestDB, Assist, AssistCtx, ImportsLocator};
235 use std::sync::Arc;
236
237 // FIXME remove the `ModuleDefId` reexport from `ra_hir` when this gets removed.
238 pub(crate) struct TestImportsLocator {
239 db: Arc<TestDB>,
240 test_file_id: FileId,
241 }
242
243 impl TestImportsLocator {
244 pub(crate) fn new(db: Arc<TestDB>, test_file_id: FileId) -> Self {
245 TestImportsLocator { db, test_file_id }
246 }
247 }
248
249 impl ImportsLocator for TestImportsLocator {
250 fn find_imports(&mut self, name_to_import: &str) -> Vec<hir::ModuleDef> {
251 let crate_def_map = self.db.crate_def_map(self.db.test_crate());
252 let mut findings = Vec::new();
253
254 let mut module_ids_to_process =
255 crate_def_map.modules_for_file(self.test_file_id).collect::<Vec<_>>();
256
257 while !module_ids_to_process.is_empty() {
258 let mut more_ids_to_process = Vec::new();
259 for local_module_id in module_ids_to_process.drain(..) {
260 for (name, namespace_data) in
261 crate_def_map[local_module_id].scope.entries_without_primitives()
262 {
263 let found_a_match = &name.to_string() == name_to_import;
264 vec![namespace_data.types, namespace_data.values]
265 .into_iter()
266 .filter_map(std::convert::identity)
267 .for_each(|(module_def_id, _)| {
268 if found_a_match {
269 findings.push(module_def_id.into());
270 }
271 if let hir::ModuleDefId::ModuleId(module_id) = module_def_id {
272 more_ids_to_process.push(module_id.local_id);
273 }
274 });
275 }
276 }
277 module_ids_to_process = more_ids_to_process;
278 }
279
280 findings
281 }
282 }
180 283
181 pub(crate) fn check_assist( 284 pub(crate) fn check_assist(
182 assist: fn(AssistCtx<TestDB>) -> Option<Assist>, 285 assist: fn(AssistCtx<TestDB>) -> Option<Assist>,
@@ -206,6 +309,38 @@ mod helpers {
206 assert_eq_text!(after, &actual); 309 assert_eq_text!(after, &actual);
207 } 310 }
208 311
312 pub(crate) fn check_assist_with_imports_locator<F: ImportsLocator>(
313 assist: fn(AssistCtx<TestDB>, &mut F) -> Option<Assist>,
314 imports_locator_provider: fn(db: Arc<TestDB>, file_id: FileId) -> F,
315 before: &str,
316 after: &str,
317 ) {
318 let (before_cursor_pos, before) = extract_offset(before);
319 let (db, file_id) = TestDB::with_single_file(&before);
320 let db = Arc::new(db);
321 let mut imports_locator = imports_locator_provider(Arc::clone(&db), file_id);
322 let frange =
323 FileRange { file_id, range: TextRange::offset_len(before_cursor_pos, 0.into()) };
324 let assist =
325 AssistCtx::with_ctx(db.as_ref(), frange, true, |ctx| assist(ctx, &mut imports_locator))
326 .expect("code action is not applicable");
327 let action = match assist {
328 Assist::Unresolved { .. } => unreachable!(),
329 Assist::Resolved { assist } => assist.get_first_action(),
330 };
331
332 let actual = action.edit.apply(&before);
333 let actual_cursor_pos = match action.cursor_position {
334 None => action
335 .edit
336 .apply_to_offset(before_cursor_pos)
337 .expect("cursor position is affected by the edit"),
338 Some(off) => off,
339 };
340 let actual = add_cursor(&actual, actual_cursor_pos);
341 assert_eq_text!(after, &actual);
342 }
343
209 pub(crate) fn check_assist_range( 344 pub(crate) fn check_assist_range(
210 assist: fn(AssistCtx<TestDB>) -> Option<Assist>, 345 assist: fn(AssistCtx<TestDB>) -> Option<Assist>,
211 before: &str, 346 before: &str,
@@ -279,6 +414,22 @@ mod helpers {
279 assert!(assist.is_none()); 414 assert!(assist.is_none());
280 } 415 }
281 416
417 pub(crate) fn check_assist_with_imports_locator_not_applicable<F: ImportsLocator>(
418 assist: fn(AssistCtx<TestDB>, &mut F) -> Option<Assist>,
419 imports_locator_provider: fn(db: Arc<TestDB>, file_id: FileId) -> F,
420 before: &str,
421 ) {
422 let (before_cursor_pos, before) = extract_offset(before);
423 let (db, file_id) = TestDB::with_single_file(&before);
424 let db = Arc::new(db);
425 let mut imports_locator = imports_locator_provider(Arc::clone(&db), file_id);
426 let frange =
427 FileRange { file_id, range: TextRange::offset_len(before_cursor_pos, 0.into()) };
428 let assist =
429 AssistCtx::with_ctx(db.as_ref(), frange, true, |ctx| assist(ctx, &mut imports_locator));
430 assert!(assist.is_none());
431 }
432
282 pub(crate) fn check_assist_range_not_applicable( 433 pub(crate) fn check_assist_range_not_applicable(
283 assist: fn(AssistCtx<TestDB>) -> Option<Assist>, 434 assist: fn(AssistCtx<TestDB>) -> Option<Assist>,
284 before: &str, 435 before: &str,
diff --git a/crates/ra_cargo_watch/Cargo.toml b/crates/ra_cargo_watch/Cargo.toml
index 9ead48abf..dd814fc9d 100644
--- a/crates/ra_cargo_watch/Cargo.toml
+++ b/crates/ra_cargo_watch/Cargo.toml
@@ -6,12 +6,13 @@ authors = ["rust-analyzer developers"]
6 6
7[dependencies] 7[dependencies]
8crossbeam-channel = "0.4" 8crossbeam-channel = "0.4"
9lsp-types = { version = "0.69.0", features = ["proposed"] } 9lsp-types = { version = "0.70.0", features = ["proposed"] }
10log = "0.4.3" 10log = "0.4.3"
11cargo_metadata = "0.9.1" 11cargo_metadata = "0.9.1"
12jod-thread = "0.1.0" 12jod-thread = "0.1.0"
13parking_lot = "0.10.0" 13parking_lot = "0.10.0"
14serde_json = "1.0.45"
14 15
15[dev-dependencies] 16[dev-dependencies]
16insta = "0.12.0" 17insta = "0.13.0"
17serde_json = "1.0" \ No newline at end of file 18serde_json = "1.0" \ No newline at end of file
diff --git a/crates/ra_cargo_watch/src/conv.rs b/crates/ra_cargo_watch/src/conv.rs
index ac0f1d28a..8fba400ae 100644
--- a/crates/ra_cargo_watch/src/conv.rs
+++ b/crates/ra_cargo_watch/src/conv.rs
@@ -117,7 +117,7 @@ fn is_deprecated(rd: &RustDiagnostic) -> bool {
117 } 117 }
118} 118}
119 119
120#[derive(Debug)] 120#[derive(Clone, Debug)]
121pub struct SuggestedFix { 121pub struct SuggestedFix {
122 pub title: String, 122 pub title: String,
123 pub location: Location, 123 pub location: Location,
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_clippy_pass_by_ref.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_clippy_pass_by_ref.snap
index cb0920914..cb0920914 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_clippy_pass_by_ref.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_clippy_pass_by_ref.snap
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_handles_macro_location.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_handles_macro_location.snap
index 19510ecc1..19510ecc1 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_handles_macro_location.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_handles_macro_location.snap
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_macro_compiler_error.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_macro_compiler_error.snap
index 92f7eec05..92f7eec05 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_macro_compiler_error.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_macro_compiler_error.snap
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_incompatible_type_for_trait.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_incompatible_type_for_trait.snap
index cf683e4b6..cf683e4b6 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_incompatible_type_for_trait.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_incompatible_type_for_trait.snap
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_mismatched_type.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_mismatched_type.snap
index 8c1483c74..8c1483c74 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_mismatched_type.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_mismatched_type.snap
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_unused_variable.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_unused_variable.snap
index eb5a2247b..eb5a2247b 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_unused_variable.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_unused_variable.snap
diff --git a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_wrong_number_of_parameters.snap b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_wrong_number_of_parameters.snap
index 2f4518931..2f4518931 100644
--- a/crates/ra_cargo_watch/src/conv/snapshots/test__snap_rustc_wrong_number_of_parameters.snap
+++ b/crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_rustc_wrong_number_of_parameters.snap
diff --git a/crates/ra_cargo_watch/src/lib.rs b/crates/ra_cargo_watch/src/lib.rs
index 7f4c9280c..ea7ddc86b 100644
--- a/crates/ra_cargo_watch/src/lib.rs
+++ b/crates/ra_cargo_watch/src/lib.rs
@@ -7,9 +7,9 @@ use lsp_types::{
7 Diagnostic, Url, WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressEnd, 7 Diagnostic, Url, WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressEnd,
8 WorkDoneProgressReport, 8 WorkDoneProgressReport,
9}; 9};
10use parking_lot::RwLock;
11use std::{ 10use std::{
12 collections::HashMap, 11 collections::HashMap,
12 io::{BufRead, BufReader},
13 path::PathBuf, 13 path::PathBuf,
14 process::{Command, Stdio}, 14 process::{Command, Stdio},
15 sync::Arc, 15 sync::Arc,
@@ -38,7 +38,7 @@ pub struct CheckOptions {
38#[derive(Debug)] 38#[derive(Debug)]
39pub struct CheckWatcher { 39pub struct CheckWatcher {
40 pub task_recv: Receiver<CheckTask>, 40 pub task_recv: Receiver<CheckTask>,
41 pub state: Arc<RwLock<CheckState>>, 41 pub state: Arc<CheckState>,
42 cmd_send: Option<Sender<CheckCommand>>, 42 cmd_send: Option<Sender<CheckCommand>>,
43 handle: Option<JoinHandle<()>>, 43 handle: Option<JoinHandle<()>>,
44} 44}
@@ -46,7 +46,7 @@ pub struct CheckWatcher {
46impl CheckWatcher { 46impl CheckWatcher {
47 pub fn new(options: &CheckOptions, workspace_root: PathBuf) -> CheckWatcher { 47 pub fn new(options: &CheckOptions, workspace_root: PathBuf) -> CheckWatcher {
48 let options = options.clone(); 48 let options = options.clone();
49 let state = Arc::new(RwLock::new(CheckState::new())); 49 let state = Arc::new(CheckState::new());
50 50
51 let (task_send, task_recv) = unbounded::<CheckTask>(); 51 let (task_send, task_recv) = unbounded::<CheckTask>();
52 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); 52 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
@@ -59,7 +59,7 @@ impl CheckWatcher {
59 59
60 /// Returns a CheckWatcher that doesn't actually do anything 60 /// Returns a CheckWatcher that doesn't actually do anything
61 pub fn dummy() -> CheckWatcher { 61 pub fn dummy() -> CheckWatcher {
62 let state = Arc::new(RwLock::new(CheckState::new())); 62 let state = Arc::new(CheckState::new());
63 CheckWatcher { task_recv: never(), cmd_send: None, handle: None, state } 63 CheckWatcher { task_recv: never(), cmd_send: None, handle: None, state }
64 } 64 }
65 65
@@ -87,7 +87,7 @@ impl std::ops::Drop for CheckWatcher {
87 } 87 }
88} 88}
89 89
90#[derive(Debug)] 90#[derive(Clone, Debug)]
91pub struct CheckState { 91pub struct CheckState {
92 diagnostic_collection: HashMap<Url, Vec<Diagnostic>>, 92 diagnostic_collection: HashMap<Url, Vec<Diagnostic>>,
93 suggested_fix_collection: HashMap<Url, Vec<SuggestedFix>>, 93 suggested_fix_collection: HashMap<Url, Vec<SuggestedFix>>,
@@ -216,8 +216,10 @@ impl CheckWatcherThread {
216 self.last_update_req.take(); 216 self.last_update_req.take();
217 task_send.send(CheckTask::ClearDiagnostics).unwrap(); 217 task_send.send(CheckTask::ClearDiagnostics).unwrap();
218 218
219 // By replacing the watcher, we drop the previous one which 219 // Replace with a dummy watcher first so we drop the original and wait for completion
220 // causes it to shut down automatically. 220 std::mem::replace(&mut self.watcher, WatchThread::dummy());
221
222 // Then create the actual new watcher
221 self.watcher = WatchThread::new(&self.options, &self.workspace_root); 223 self.watcher = WatchThread::new(&self.options, &self.workspace_root);
222 } 224 }
223 } 225 }
@@ -348,15 +350,45 @@ impl WatchThread {
348 // which will break out of the loop, and continue the shutdown 350 // which will break out of the loop, and continue the shutdown
349 let _ = message_send.send(CheckEvent::Begin); 351 let _ = message_send.send(CheckEvent::Begin);
350 352
351 for message in cargo_metadata::parse_messages(command.stdout.take().unwrap()) { 353 // We manually read a line at a time, instead of using serde's
354 // stream deserializers, because the deserializer cannot recover
355 // from an error, resulting in it getting stuck, because we try to
356 // be resillient against failures.
357 //
358 // Because cargo only outputs one JSON object per line, we can
359 // simply skip a line if it doesn't parse, which just ignores any
360 // erroneus output.
361 let stdout = BufReader::new(command.stdout.take().unwrap());
362 for line in stdout.lines() {
363 let line = match line {
364 Ok(line) => line,
365 Err(err) => {
366 log::error!("Couldn't read line from cargo: {}", err);
367 continue;
368 }
369 };
370
371 let message = serde_json::from_str::<cargo_metadata::Message>(&line);
352 let message = match message { 372 let message = match message {
353 Ok(message) => message, 373 Ok(message) => message,
354 Err(err) => { 374 Err(err) => {
355 log::error!("Invalid json from cargo check, ignoring: {}", err); 375 log::error!(
376 "Invalid json from cargo check, ignoring ({}): {:?} ",
377 err,
378 line
379 );
356 continue; 380 continue;
357 } 381 }
358 }; 382 };
359 383
384 // Skip certain kinds of messages to only spend time on what's useful
385 match &message {
386 Message::CompilerArtifact(artifact) if artifact.fresh => continue,
387 Message::BuildScriptExecuted(_) => continue,
388 Message::Unknown => continue,
389 _ => {}
390 }
391
360 match message_send.send(CheckEvent::Msg(message)) { 392 match message_send.send(CheckEvent::Msg(message)) {
361 Ok(()) => {} 393 Ok(()) => {}
362 Err(_err) => { 394 Err(_err) => {
diff --git a/crates/ra_cli/Cargo.toml b/crates/ra_cli/Cargo.toml
index 12af075f7..bcd408421 100644
--- a/crates/ra_cli/Cargo.toml
+++ b/crates/ra_cli/Cargo.toml
@@ -7,7 +7,7 @@ publish = false
7 7
8[dependencies] 8[dependencies]
9pico-args = "0.3.0" 9pico-args = "0.3.0"
10env_logger = { version = "0.7.1", default-features = false, features = ["humantime"] } 10env_logger = { version = "0.7.1", default-features = false }
11 11
12ra_syntax = { path = "../ra_syntax" } 12ra_syntax = { path = "../ra_syntax" }
13ra_ide = { path = "../ra_ide" } 13ra_ide = { path = "../ra_ide" }
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index e6079b88d..a77bf6de6 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -1,20 +1,24 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3pub use hir_def::db::{ 3pub use hir_def::db::{
4 BodyQuery, BodyWithSourceMapQuery, ComputeCrateDefMapQuery, ConstDataQuery, 4 AttrsQuery, BodyQuery, BodyWithSourceMapQuery, ComputeCrateDefMapQuery, ConstDataQuery,
5 CrateLangItemsQuery, DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery, 5 CrateLangItemsQuery, DefDatabase, DefDatabaseStorage, DocumentationQuery, EnumDataQuery,
6 ExprScopesQuery, FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternDatabase, 6 ExprScopesQuery, FunctionDataQuery, GenericParamsQuery, ImplDataQuery, InternConstQuery,
7 InternDatabaseStorage, LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, StaticDataQuery, 7 InternDatabase, InternDatabaseStorage, InternEnumQuery, InternFunctionQuery, InternImplQuery,
8 StructDataQuery, TraitDataQuery, TypeAliasDataQuery, 8 InternStaticQuery, InternStructQuery, InternTraitQuery, InternTypeAliasQuery, InternUnionQuery,
9 LangItemQuery, ModuleLangItemsQuery, RawItemsQuery, StaticDataQuery, StructDataQuery,
10 TraitDataQuery, TypeAliasDataQuery, UnionDataQuery,
9}; 11};
10pub use hir_expand::db::{ 12pub use hir_expand::db::{
11 AstDatabase, AstDatabaseStorage, AstIdMapQuery, MacroArgQuery, MacroDefQuery, MacroExpandQuery, 13 AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternMacroQuery, MacroArgQuery, MacroDefQuery,
12 ParseMacroQuery, 14 MacroExpandQuery, ParseMacroQuery,
13}; 15};
14pub use hir_ty::db::{ 16pub use hir_ty::db::{
15 AssociatedTyDataQuery, CallableItemSignatureQuery, DoInferQuery, FieldTypesQuery, 17 AssociatedTyDataQuery, AssociatedTyValueQuery, CallableItemSignatureQuery, DoInferQuery,
16 GenericDefaultsQuery, GenericPredicatesQuery, HirDatabase, HirDatabaseStorage, ImplDatumQuery, 18 FieldTypesQuery, GenericDefaultsQuery, GenericPredicatesForParamQuery, GenericPredicatesQuery,
17 ImplsForTraitQuery, ImplsInCrateQuery, StructDatumQuery, TraitDatumQuery, TraitSolveQuery, 19 HirDatabase, HirDatabaseStorage, ImplDatumQuery, ImplSelfTyQuery, ImplTraitQuery,
20 ImplsForTraitQuery, ImplsInCrateQuery, InternAssocTyValueQuery, InternChalkImplQuery,
21 InternTypeCtorQuery, StructDatumQuery, TraitDatumQuery, TraitSolveQuery, TraitSolverQuery,
18 TyQuery, ValueTyQuery, 22 TyQuery, ValueTyQuery,
19}; 23};
20 24
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index e1c7b7a20..9e2673d13 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -56,6 +56,7 @@ pub use hir_def::{
56 nameres::ModuleSource, 56 nameres::ModuleSource,
57 path::{ModPath, Path, PathKind}, 57 path::{ModPath, Path, PathKind},
58 type_ref::Mutability, 58 type_ref::Mutability,
59 ModuleDefId, // FIXME this is exposed and should be used for implementing the `TestImportsLocator` in `ra_assists` only, should be removed later along with the trait and the implementation.
59}; 60};
60pub use hir_expand::{ 61pub use hir_expand::{
61 name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, Origin, 62 name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, Origin,
diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml
index 2c368f690..1efa00fe0 100644
--- a/crates/ra_hir_def/Cargo.toml
+++ b/crates/ra_hir_def/Cargo.toml
@@ -26,4 +26,4 @@ ra_cfg = { path = "../ra_cfg" }
26tt = { path = "../ra_tt", package = "ra_tt" } 26tt = { path = "../ra_tt", package = "ra_tt" }
27 27
28[dev-dependencies] 28[dev-dependencies]
29insta = "0.12.0" 29insta = "0.13.0"
diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs
index 8cc2fb160..43b9b124a 100644
--- a/crates/ra_hir_def/src/find_path.rs
+++ b/crates/ra_hir_def/src/find_path.rs
@@ -7,10 +7,39 @@ use crate::{
7 visibility::Visibility, 7 visibility::Visibility,
8 CrateId, ModuleDefId, ModuleId, 8 CrateId, ModuleDefId, ModuleId,
9}; 9};
10use hir_expand::name::Name; 10use hir_expand::name::{known, Name};
11use test_utils::tested_by;
11 12
12const MAX_PATH_LEN: usize = 15; 13const MAX_PATH_LEN: usize = 15;
13 14
15impl ModPath {
16 fn starts_with_std(&self) -> bool {
17 self.segments.first().filter(|&first_segment| first_segment == &known::std).is_some()
18 }
19
20 // When std library is present, paths starting with `std::`
21 // should be preferred over paths starting with `core::` and `alloc::`
22 fn should_start_with_std(&self) -> bool {
23 self.segments
24 .first()
25 .filter(|&first_segment| {
26 first_segment == &known::alloc || first_segment == &known::core
27 })
28 .is_some()
29 }
30
31 fn len(&self) -> usize {
32 self.segments.len()
33 + match self.kind {
34 PathKind::Plain => 0,
35 PathKind::Super(i) => i as usize,
36 PathKind::Crate => 1,
37 PathKind::Abs => 0,
38 PathKind::DollarCrate(_) => 1,
39 }
40 }
41}
42
14// FIXME: handle local items 43// FIXME: handle local items
15 44
16/// Find a path that can be used to refer to a certain item. This can depend on 45/// Find a path that can be used to refer to a certain item. This can depend on
@@ -112,23 +141,27 @@ fn find_path_inner(
112 Some(path) => path, 141 Some(path) => path,
113 }; 142 };
114 path.segments.push(name); 143 path.segments.push(name);
115 if path_len(&path) < best_path_len { 144
116 best_path_len = path_len(&path); 145 let new_path =
117 best_path = Some(path); 146 if let Some(best_path) = best_path { select_best_path(best_path, path) } else { path };
118 } 147 best_path_len = new_path.len();
148 best_path = Some(new_path);
119 } 149 }
120 best_path 150 best_path
121} 151}
122 152
123fn path_len(path: &ModPath) -> usize { 153fn select_best_path(old_path: ModPath, new_path: ModPath) -> ModPath {
124 path.segments.len() 154 if old_path.starts_with_std() && new_path.should_start_with_std() {
125 + match path.kind { 155 tested_by!(prefer_std_paths);
126 PathKind::Plain => 0, 156 old_path
127 PathKind::Super(i) => i as usize, 157 } else if new_path.starts_with_std() && old_path.should_start_with_std() {
128 PathKind::Crate => 1, 158 tested_by!(prefer_std_paths);
129 PathKind::Abs => 0, 159 new_path
130 PathKind::DollarCrate(_) => 1, 160 } else if new_path.len() < old_path.len() {
131 } 161 new_path
162 } else {
163 old_path
164 }
132} 165}
133 166
134fn find_importable_locations( 167fn find_importable_locations(
@@ -201,6 +234,7 @@ mod tests {
201 use hir_expand::hygiene::Hygiene; 234 use hir_expand::hygiene::Hygiene;
202 use ra_db::fixture::WithFixture; 235 use ra_db::fixture::WithFixture;
203 use ra_syntax::ast::AstNode; 236 use ra_syntax::ast::AstNode;
237 use test_utils::covers;
204 238
205 /// `code` needs to contain a cursor marker; checks that `find_path` for the 239 /// `code` needs to contain a cursor marker; checks that `find_path` for the
206 /// item the `path` refers to returns that same path when called from the 240 /// item the `path` refers to returns that same path when called from the
@@ -452,4 +486,41 @@ mod tests {
452 "#; 486 "#;
453 check_found_path(code, "crate::foo::S"); 487 check_found_path(code, "crate::foo::S");
454 } 488 }
489
490 #[test]
491 fn prefer_std_paths_over_alloc() {
492 covers!(prefer_std_paths);
493 let code = r#"
494 //- /main.rs crate:main deps:alloc,std
495 <|>
496
497 //- /std.rs crate:std deps:alloc
498 pub mod sync {
499 pub use alloc::sync::Arc;
500 }
501
502 //- /zzz.rs crate:alloc
503 pub mod sync {
504 pub struct Arc;
505 }
506 "#;
507 check_found_path(code, "std::sync::Arc");
508 }
509
510 #[test]
511 fn prefer_shorter_paths_if_not_alloc() {
512 let code = r#"
513 //- /main.rs crate:main deps:megaalloc,std
514 <|>
515
516 //- /std.rs crate:std deps:megaalloc
517 pub mod sync {
518 pub use megaalloc::sync::Arc;
519 }
520
521 //- /zzz.rs crate:megaalloc
522 pub struct Arc;
523 "#;
524 check_found_path(code, "megaalloc::Arc");
525 }
455} 526}
diff --git a/crates/ra_hir_def/src/marks.rs b/crates/ra_hir_def/src/marks.rs
index 457ba4abe..daa49d5f1 100644
--- a/crates/ra_hir_def/src/marks.rs
+++ b/crates/ra_hir_def/src/marks.rs
@@ -13,4 +13,5 @@ test_utils::marks!(
13 macro_dollar_crate_self 13 macro_dollar_crate_self
14 macro_dollar_crate_other 14 macro_dollar_crate_other
15 infer_resolve_while_let 15 infer_resolve_while_let
16 prefer_std_paths
16); 17);
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 27c12e46c..852304dd0 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -229,6 +229,46 @@ impl CrateDefMap {
229 self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path, shadow); 229 self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path, shadow);
230 (res.resolved_def, res.segment_index) 230 (res.resolved_def, res.segment_index)
231 } 231 }
232
233 // FIXME: this can use some more human-readable format (ideally, an IR
234 // even), as this should be a great debugging aid.
235 pub fn dump(&self) -> String {
236 let mut buf = String::new();
237 go(&mut buf, self, "\ncrate", self.root);
238 return buf.trim().to_string();
239
240 fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) {
241 *buf += path;
242 *buf += "\n";
243
244 let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect();
245 entries.sort_by_key(|(name, _)| name.clone());
246
247 for (name, def) in entries {
248 *buf += &format!("{}:", name);
249
250 if def.types.is_some() {
251 *buf += " t";
252 }
253 if def.values.is_some() {
254 *buf += " v";
255 }
256 if def.macros.is_some() {
257 *buf += " m";
258 }
259 if def.is_none() {
260 *buf += " _";
261 }
262
263 *buf += "\n";
264 }
265
266 for (name, child) in map.modules[module].children.iter() {
267 let path = path.to_string() + &format!("::{}", name);
268 go(buf, map, &path, *child);
269 }
270 }
271 }
232} 272}
233 273
234impl ModuleData { 274impl ModuleData {
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs
index 78bcdc850..82f0f835c 100644
--- a/crates/ra_hir_def/src/nameres/tests.rs
+++ b/crates/ra_hir_def/src/nameres/tests.rs
@@ -10,11 +10,10 @@ use insta::assert_snapshot;
10use ra_db::{fixture::WithFixture, SourceDatabase}; 10use ra_db::{fixture::WithFixture, SourceDatabase};
11use test_utils::covers; 11use test_utils::covers;
12 12
13use crate::{db::DefDatabase, nameres::*, test_db::TestDB, LocalModuleId}; 13use crate::{db::DefDatabase, nameres::*, test_db::TestDB};
14 14
15fn def_map(fixture: &str) -> String { 15fn def_map(fixture: &str) -> String {
16 let dm = compute_crate_def_map(fixture); 16 compute_crate_def_map(fixture).dump()
17 render_crate_def_map(&dm)
18} 17}
19 18
20fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> { 19fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
@@ -23,44 +22,6 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> {
23 db.crate_def_map(krate) 22 db.crate_def_map(krate)
24} 23}
25 24
26fn render_crate_def_map(map: &CrateDefMap) -> String {
27 let mut buf = String::new();
28 go(&mut buf, map, "\ncrate", map.root);
29 return buf.trim().to_string();
30
31 fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) {
32 *buf += path;
33 *buf += "\n";
34
35 let mut entries: Vec<_> = map.modules[module].scope.resolutions().collect();
36 entries.sort_by_key(|(name, _)| name.clone());
37
38 for (name, def) in entries {
39 *buf += &format!("{}:", name);
40
41 if def.types.is_some() {
42 *buf += " t";
43 }
44 if def.values.is_some() {
45 *buf += " v";
46 }
47 if def.macros.is_some() {
48 *buf += " m";
49 }
50 if def.is_none() {
51 *buf += " _";
52 }
53
54 *buf += "\n";
55 }
56
57 for (name, child) in map.modules[module].children.iter() {
58 let path = path.to_string() + &format!("::{}", name);
59 go(buf, map, &path, *child);
60 }
61 }
62}
63
64#[test] 25#[test]
65fn crate_def_map_smoke_test() { 26fn crate_def_map_smoke_test() {
66 let map = def_map( 27 let map = def_map(
diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs
index b3fa1efba..b2e10f445 100644
--- a/crates/ra_hir_expand/src/name.rs
+++ b/crates/ra_hir_expand/src/name.rs
@@ -141,6 +141,8 @@ pub mod known {
141 macro_rules, 141 macro_rules,
142 // Components of known path (value or mod name) 142 // Components of known path (value or mod name)
143 std, 143 std,
144 core,
145 alloc,
144 iter, 146 iter,
145 ops, 147 ops,
146 future, 148 future,
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml
index 60793db44..f5484bf70 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/ra_hir_ty/Cargo.toml
@@ -21,11 +21,11 @@ ra_prof = { path = "../ra_prof" }
21ra_syntax = { path = "../ra_syntax" } 21ra_syntax = { path = "../ra_syntax" }
22test_utils = { path = "../test_utils" } 22test_utils = { path = "../test_utils" }
23 23
24chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" } 24chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "af48f302a1f571b3ca418f7c5aa639a144a34f75" }
25chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" } 25chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "af48f302a1f571b3ca418f7c5aa639a144a34f75" }
26chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "ff65b5ac9860f3c36bd892c865ab23d5ff0bbae5" } 26chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "af48f302a1f571b3ca418f7c5aa639a144a34f75" }
27 27
28lalrpop-intern = "0.15.1" 28lalrpop-intern = "0.15.1"
29 29
30[dev-dependencies] 30[dev-dependencies]
31insta = "0.12.0" 31insta = "0.13.0"
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 908e4862d..08d501ccd 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -847,7 +847,7 @@ impl HirDisplay for ApplicationTy {
847 } 847 }
848 TypeCtor::Array => { 848 TypeCtor::Array => {
849 let t = self.parameters.as_single(); 849 let t = self.parameters.as_single();
850 write!(f, "[{};_]", t.display(f.db))?; 850 write!(f, "[{}; _]", t.display(f.db))?;
851 } 851 }
852 TypeCtor::RawPtr(m) => { 852 TypeCtor::RawPtr(m) => {
853 let t = self.parameters.as_single(); 853 let t = self.parameters.as_single();
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs
index 7e99a42ed..76a1b46c0 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/ra_hir_ty/src/tests/coercion.rs
@@ -71,42 +71,42 @@ fn test2() {
71 [82; 93) '{ loop {} }': T 71 [82; 93) '{ loop {} }': T
72 [84; 91) 'loop {}': ! 72 [84; 91) 'loop {}': !
73 [89; 91) '{}': () 73 [89; 91) '{}': ()
74 [122; 133) '{ loop {} }': *mut [T;_] 74 [122; 133) '{ loop {} }': *mut [T; _]
75 [124; 131) 'loop {}': ! 75 [124; 131) 'loop {}': !
76 [129; 131) '{}': () 76 [129; 131) '{}': ()
77 [160; 173) '{ gen() }': *mut [U] 77 [160; 173) '{ gen() }': *mut [U]
78 [166; 169) 'gen': fn gen<U>() -> *mut [T;_] 78 [166; 169) 'gen': fn gen<U>() -> *mut [T; _]
79 [166; 171) 'gen()': *mut [U;_] 79 [166; 171) 'gen()': *mut [U; _]
80 [186; 420) '{ ...rr); }': () 80 [186; 420) '{ ...rr); }': ()
81 [196; 199) 'arr': &[u8;_] 81 [196; 199) 'arr': &[u8; _]
82 [212; 216) '&[1]': &[u8;_] 82 [212; 216) '&[1]': &[u8; _]
83 [213; 216) '[1]': [u8;_] 83 [213; 216) '[1]': [u8; _]
84 [214; 215) '1': u8 84 [214; 215) '1': u8
85 [227; 228) 'a': &[u8] 85 [227; 228) 'a': &[u8]
86 [237; 240) 'arr': &[u8;_] 86 [237; 240) 'arr': &[u8; _]
87 [250; 251) 'b': u8 87 [250; 251) 'b': u8
88 [254; 255) 'f': fn f<u8>(&[T]) -> T 88 [254; 255) 'f': fn f<u8>(&[T]) -> T
89 [254; 260) 'f(arr)': u8 89 [254; 260) 'f(arr)': u8
90 [256; 259) 'arr': &[u8;_] 90 [256; 259) 'arr': &[u8; _]
91 [270; 271) 'c': &[u8] 91 [270; 271) 'c': &[u8]
92 [280; 287) '{ arr }': &[u8] 92 [280; 287) '{ arr }': &[u8]
93 [282; 285) 'arr': &[u8;_] 93 [282; 285) 'arr': &[u8; _]
94 [297; 298) 'd': u8 94 [297; 298) 'd': u8
95 [301; 302) 'g': fn g<u8>(S<&[T]>) -> T 95 [301; 302) 'g': fn g<u8>(S<&[T]>) -> T
96 [301; 316) 'g(S { a: arr })': u8 96 [301; 316) 'g(S { a: arr })': u8
97 [303; 315) 'S { a: arr }': S<&[u8]> 97 [303; 315) 'S { a: arr }': S<&[u8]>
98 [310; 313) 'arr': &[u8;_] 98 [310; 313) 'arr': &[u8; _]
99 [326; 327) 'e': [&[u8];_] 99 [326; 327) 'e': [&[u8]; _]
100 [341; 346) '[arr]': [&[u8];_] 100 [341; 346) '[arr]': [&[u8]; _]
101 [342; 345) 'arr': &[u8;_] 101 [342; 345) 'arr': &[u8; _]
102 [356; 357) 'f': [&[u8];_] 102 [356; 357) 'f': [&[u8]; _]
103 [371; 379) '[arr; 2]': [&[u8];_] 103 [371; 379) '[arr; 2]': [&[u8]; _]
104 [372; 375) 'arr': &[u8;_] 104 [372; 375) 'arr': &[u8; _]
105 [377; 378) '2': usize 105 [377; 378) '2': usize
106 [389; 390) 'g': (&[u8], &[u8]) 106 [389; 390) 'g': (&[u8], &[u8])
107 [407; 417) '(arr, arr)': (&[u8], &[u8]) 107 [407; 417) '(arr, arr)': (&[u8], &[u8])
108 [408; 411) 'arr': &[u8;_] 108 [408; 411) 'arr': &[u8; _]
109 [413; 416) 'arr': &[u8;_] 109 [413; 416) 'arr': &[u8; _]
110 "### 110 "###
111 ); 111 );
112} 112}
@@ -122,8 +122,8 @@ fn test() {
122 @r###" 122 @r###"
123 [11; 40) '{ ...[1]; }': () 123 [11; 40) '{ ...[1]; }': ()
124 [21; 22) 'x': &[i32] 124 [21; 22) 'x': &[i32]
125 [33; 37) '&[1]': &[i32;_] 125 [33; 37) '&[1]': &[i32; _]
126 [34; 37) '[1]': [i32;_] 126 [34; 37) '[1]': [i32; _]
127 [35; 36) '1': i32 127 [35; 36) '1': i32
128 "###); 128 "###);
129} 129}
@@ -159,22 +159,22 @@ fn test(a: A<[u8; 2]>, b: B<[u8; 2]>, c: C<[u8; 2]>) {
159 [334; 335) 'x': C<[T]> 159 [334; 335) 'x': C<[T]>
160 [355; 360) '{ x }': C<[T]> 160 [355; 360) '{ x }': C<[T]>
161 [357; 358) 'x': C<[T]> 161 [357; 358) 'x': C<[T]>
162 [370; 371) 'a': A<[u8;_]> 162 [370; 371) 'a': A<[u8; _]>
163 [385; 386) 'b': B<[u8;_]> 163 [385; 386) 'b': B<[u8; _]>
164 [400; 401) 'c': C<[u8;_]> 164 [400; 401) 'c': C<[u8; _]>
165 [415; 481) '{ ...(c); }': () 165 [415; 481) '{ ...(c); }': ()
166 [425; 426) 'd': A<[{unknown}]> 166 [425; 426) 'd': A<[{unknown}]>
167 [429; 433) 'foo1': fn foo1<{unknown}>(A<[T]>) -> A<[T]> 167 [429; 433) 'foo1': fn foo1<{unknown}>(A<[T]>) -> A<[T]>
168 [429; 436) 'foo1(a)': A<[{unknown}]> 168 [429; 436) 'foo1(a)': A<[{unknown}]>
169 [434; 435) 'a': A<[u8;_]> 169 [434; 435) 'a': A<[u8; _]>
170 [446; 447) 'e': B<[u8]> 170 [446; 447) 'e': B<[u8]>
171 [450; 454) 'foo2': fn foo2<u8>(B<[T]>) -> B<[T]> 171 [450; 454) 'foo2': fn foo2<u8>(B<[T]>) -> B<[T]>
172 [450; 457) 'foo2(b)': B<[u8]> 172 [450; 457) 'foo2(b)': B<[u8]>
173 [455; 456) 'b': B<[u8;_]> 173 [455; 456) 'b': B<[u8; _]>
174 [467; 468) 'f': C<[u8]> 174 [467; 468) 'f': C<[u8]>
175 [471; 475) 'foo3': fn foo3<u8>(C<[T]>) -> C<[T]> 175 [471; 475) 'foo3': fn foo3<u8>(C<[T]>) -> C<[T]>
176 [471; 478) 'foo3(c)': C<[u8]> 176 [471; 478) 'foo3(c)': C<[u8]>
177 [476; 477) 'c': C<[u8;_]> 177 [476; 477) 'c': C<[u8; _]>
178 "### 178 "###
179 ); 179 );
180} 180}
@@ -204,12 +204,12 @@ fn test() {
204 [72; 97) '{ ... }': &[i32] 204 [72; 97) '{ ... }': &[i32]
205 [82; 85) 'foo': fn foo<i32>(&[T]) -> &[T] 205 [82; 85) 'foo': fn foo<i32>(&[T]) -> &[T]
206 [82; 91) 'foo(&[1])': &[i32] 206 [82; 91) 'foo(&[1])': &[i32]
207 [86; 90) '&[1]': &[i32;_] 207 [86; 90) '&[1]': &[i32; _]
208 [87; 90) '[1]': [i32;_] 208 [87; 90) '[1]': [i32; _]
209 [88; 89) '1': i32 209 [88; 89) '1': i32
210 [103; 123) '{ ... }': &[i32;_] 210 [103; 123) '{ ... }': &[i32; _]
211 [113; 117) '&[1]': &[i32;_] 211 [113; 117) '&[1]': &[i32; _]
212 [114; 117) '[1]': [i32;_] 212 [114; 117) '[1]': [i32; _]
213 [115; 116) '1': i32 213 [115; 116) '1': i32
214 "### 214 "###
215 ); 215 );
@@ -237,15 +237,15 @@ fn test() {
237 [60; 61) 'x': &[i32] 237 [60; 61) 'x': &[i32]
238 [64; 123) 'if tru... }': &[i32] 238 [64; 123) 'if tru... }': &[i32]
239 [67; 71) 'true': bool 239 [67; 71) 'true': bool
240 [72; 92) '{ ... }': &[i32;_] 240 [72; 92) '{ ... }': &[i32; _]
241 [82; 86) '&[1]': &[i32;_] 241 [82; 86) '&[1]': &[i32; _]
242 [83; 86) '[1]': [i32;_] 242 [83; 86) '[1]': [i32; _]
243 [84; 85) '1': i32 243 [84; 85) '1': i32
244 [98; 123) '{ ... }': &[i32] 244 [98; 123) '{ ... }': &[i32]
245 [108; 111) 'foo': fn foo<i32>(&[T]) -> &[T] 245 [108; 111) 'foo': fn foo<i32>(&[T]) -> &[T]
246 [108; 117) 'foo(&[1])': &[i32] 246 [108; 117) 'foo(&[1])': &[i32]
247 [112; 116) '&[1]': &[i32;_] 247 [112; 116) '&[1]': &[i32; _]
248 [113; 116) '[1]': [i32;_] 248 [113; 116) '[1]': [i32; _]
249 [114; 115) '1': i32 249 [114; 115) '1': i32
250 "### 250 "###
251 ); 251 );
@@ -277,16 +277,16 @@ fn test(i: i32) {
277 [88; 89) '2': i32 277 [88; 89) '2': i32
278 [93; 96) 'foo': fn foo<i32>(&[T]) -> &[T] 278 [93; 96) 'foo': fn foo<i32>(&[T]) -> &[T]
279 [93; 102) 'foo(&[2])': &[i32] 279 [93; 102) 'foo(&[2])': &[i32]
280 [97; 101) '&[2]': &[i32;_] 280 [97; 101) '&[2]': &[i32; _]
281 [98; 101) '[2]': [i32;_] 281 [98; 101) '[2]': [i32; _]
282 [99; 100) '2': i32 282 [99; 100) '2': i32
283 [112; 113) '1': i32 283 [112; 113) '1': i32
284 [117; 121) '&[1]': &[i32;_] 284 [117; 121) '&[1]': &[i32; _]
285 [118; 121) '[1]': [i32;_] 285 [118; 121) '[1]': [i32; _]
286 [119; 120) '1': i32 286 [119; 120) '1': i32
287 [131; 132) '_': i32 287 [131; 132) '_': i32
288 [136; 140) '&[3]': &[i32;_] 288 [136; 140) '&[3]': &[i32; _]
289 [137; 140) '[3]': [i32;_] 289 [137; 140) '[3]': [i32; _]
290 [138; 139) '3': i32 290 [138; 139) '3': i32
291 "### 291 "###
292 ); 292 );
@@ -316,18 +316,18 @@ fn test(i: i32) {
316 [70; 147) 'match ... }': &[i32] 316 [70; 147) 'match ... }': &[i32]
317 [76; 77) 'i': i32 317 [76; 77) 'i': i32
318 [88; 89) '1': i32 318 [88; 89) '1': i32
319 [93; 97) '&[1]': &[i32;_] 319 [93; 97) '&[1]': &[i32; _]
320 [94; 97) '[1]': [i32;_] 320 [94; 97) '[1]': [i32; _]
321 [95; 96) '1': i32 321 [95; 96) '1': i32
322 [107; 108) '2': i32 322 [107; 108) '2': i32
323 [112; 115) 'foo': fn foo<i32>(&[T]) -> &[T] 323 [112; 115) 'foo': fn foo<i32>(&[T]) -> &[T]
324 [112; 121) 'foo(&[2])': &[i32] 324 [112; 121) 'foo(&[2])': &[i32]
325 [116; 120) '&[2]': &[i32;_] 325 [116; 120) '&[2]': &[i32; _]
326 [117; 120) '[2]': [i32;_] 326 [117; 120) '[2]': [i32; _]
327 [118; 119) '2': i32 327 [118; 119) '2': i32
328 [131; 132) '_': i32 328 [131; 132) '_': i32
329 [136; 140) '&[3]': &[i32;_] 329 [136; 140) '&[3]': &[i32; _]
330 [137; 140) '[3]': [i32;_] 330 [137; 140) '[3]': [i32; _]
331 [138; 139) '3': i32 331 [138; 139) '3': i32
332 "### 332 "###
333 ); 333 );
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs
index aa948dcbf..02bab6dbe 100644
--- a/crates/ra_hir_ty/src/tests/regression.rs
+++ b/crates/ra_hir_ty/src/tests/regression.rs
@@ -102,7 +102,7 @@ fn test() {
102 [11; 48) '{ ...&y]; }': () 102 [11; 48) '{ ...&y]; }': ()
103 [21; 22) 'y': &{unknown} 103 [21; 22) 'y': &{unknown}
104 [25; 32) 'unknown': &{unknown} 104 [25; 32) 'unknown': &{unknown}
105 [38; 45) '[y, &y]': [&&{unknown};_] 105 [38; 45) '[y, &y]': [&&{unknown}; _]
106 [39; 40) 'y': &{unknown} 106 [39; 40) 'y': &{unknown}
107 [42; 44) '&y': &&{unknown} 107 [42; 44) '&y': &&{unknown}
108 [43; 44) 'y': &{unknown} 108 [43; 44) 'y': &{unknown}
@@ -128,7 +128,7 @@ fn test() {
128 [25; 32) 'unknown': &&{unknown} 128 [25; 32) 'unknown': &&{unknown}
129 [42; 43) 'y': &&{unknown} 129 [42; 43) 'y': &&{unknown}
130 [46; 53) 'unknown': &&{unknown} 130 [46; 53) 'unknown': &&{unknown}
131 [59; 77) '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown});_] 131 [59; 77) '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _]
132 [60; 66) '(x, y)': (&&&{unknown}, &&&{unknown}) 132 [60; 66) '(x, y)': (&&&{unknown}, &&&{unknown})
133 [61; 62) 'x': &&{unknown} 133 [61; 62) 'x': &&{unknown}
134 [64; 65) 'y': &&{unknown} 134 [64; 65) 'y': &&{unknown}
@@ -180,8 +180,8 @@ fn test_line_buffer() {
180"#), 180"#),
181 @r###" 181 @r###"
182 [23; 53) '{ ...n']; }': () 182 [23; 53) '{ ...n']; }': ()
183 [29; 50) '&[0, b...b'\n']': &[u8;_] 183 [29; 50) '&[0, b...b'\n']': &[u8; _]
184 [30; 50) '[0, b'...b'\n']': [u8;_] 184 [30; 50) '[0, b'...b'\n']': [u8; _]
185 [31; 32) '0': u8 185 [31; 32) '0': u8
186 [34; 39) 'b'\n'': u8 186 [34; 39) 'b'\n'': u8
187 [41; 42) '1': u8 187 [41; 42) '1': u8
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs
index b7204ec00..fdab9c187 100644
--- a/crates/ra_hir_ty/src/tests/simple.rs
+++ b/crates/ra_hir_ty/src/tests/simple.rs
@@ -28,7 +28,7 @@ mod boxed {
28 28
29"#, 29"#,
30 ); 30 );
31 assert_eq!("(Box<i32>, Box<Box<i32>>, Box<&i32>, Box<[i32;_]>)", type_at_pos(&db, pos)); 31 assert_eq!("(Box<i32>, Box<Box<i32>>, Box<&i32>, Box<[i32; _]>)", type_at_pos(&db, pos));
32} 32}
33 33
34#[test] 34#[test]
@@ -1061,55 +1061,55 @@ fn test(x: &str, y: isize) {
1061 [9; 10) 'x': &str 1061 [9; 10) 'x': &str
1062 [18; 19) 'y': isize 1062 [18; 19) 'y': isize
1063 [28; 293) '{ ... []; }': () 1063 [28; 293) '{ ... []; }': ()
1064 [38; 39) 'a': [&str;_] 1064 [38; 39) 'a': [&str; _]
1065 [42; 45) '[x]': [&str;_] 1065 [42; 45) '[x]': [&str; _]
1066 [43; 44) 'x': &str 1066 [43; 44) 'x': &str
1067 [55; 56) 'b': [[&str;_];_] 1067 [55; 56) 'b': [[&str; _]; _]
1068 [59; 65) '[a, a]': [[&str;_];_] 1068 [59; 65) '[a, a]': [[&str; _]; _]
1069 [60; 61) 'a': [&str;_] 1069 [60; 61) 'a': [&str; _]
1070 [63; 64) 'a': [&str;_] 1070 [63; 64) 'a': [&str; _]
1071 [75; 76) 'c': [[[&str;_];_];_] 1071 [75; 76) 'c': [[[&str; _]; _]; _]
1072 [79; 85) '[b, b]': [[[&str;_];_];_] 1072 [79; 85) '[b, b]': [[[&str; _]; _]; _]
1073 [80; 81) 'b': [[&str;_];_] 1073 [80; 81) 'b': [[&str; _]; _]
1074 [83; 84) 'b': [[&str;_];_] 1074 [83; 84) 'b': [[&str; _]; _]
1075 [96; 97) 'd': [isize;_] 1075 [96; 97) 'd': [isize; _]
1076 [100; 112) '[y, 1, 2, 3]': [isize;_] 1076 [100; 112) '[y, 1, 2, 3]': [isize; _]
1077 [101; 102) 'y': isize 1077 [101; 102) 'y': isize
1078 [104; 105) '1': isize 1078 [104; 105) '1': isize
1079 [107; 108) '2': isize 1079 [107; 108) '2': isize
1080 [110; 111) '3': isize 1080 [110; 111) '3': isize
1081 [122; 123) 'd': [isize;_] 1081 [122; 123) 'd': [isize; _]
1082 [126; 138) '[1, y, 2, 3]': [isize;_] 1082 [126; 138) '[1, y, 2, 3]': [isize; _]
1083 [127; 128) '1': isize 1083 [127; 128) '1': isize
1084 [130; 131) 'y': isize 1084 [130; 131) 'y': isize
1085 [133; 134) '2': isize 1085 [133; 134) '2': isize
1086 [136; 137) '3': isize 1086 [136; 137) '3': isize
1087 [148; 149) 'e': [isize;_] 1087 [148; 149) 'e': [isize; _]
1088 [152; 155) '[y]': [isize;_] 1088 [152; 155) '[y]': [isize; _]
1089 [153; 154) 'y': isize 1089 [153; 154) 'y': isize
1090 [165; 166) 'f': [[isize;_];_] 1090 [165; 166) 'f': [[isize; _]; _]
1091 [169; 175) '[d, d]': [[isize;_];_] 1091 [169; 175) '[d, d]': [[isize; _]; _]
1092 [170; 171) 'd': [isize;_] 1092 [170; 171) 'd': [isize; _]
1093 [173; 174) 'd': [isize;_] 1093 [173; 174) 'd': [isize; _]
1094 [185; 186) 'g': [[isize;_];_] 1094 [185; 186) 'g': [[isize; _]; _]
1095 [189; 195) '[e, e]': [[isize;_];_] 1095 [189; 195) '[e, e]': [[isize; _]; _]
1096 [190; 191) 'e': [isize;_] 1096 [190; 191) 'e': [isize; _]
1097 [193; 194) 'e': [isize;_] 1097 [193; 194) 'e': [isize; _]
1098 [206; 207) 'h': [i32;_] 1098 [206; 207) 'h': [i32; _]
1099 [210; 216) '[1, 2]': [i32;_] 1099 [210; 216) '[1, 2]': [i32; _]
1100 [211; 212) '1': i32 1100 [211; 212) '1': i32
1101 [214; 215) '2': i32 1101 [214; 215) '2': i32
1102 [226; 227) 'i': [&str;_] 1102 [226; 227) 'i': [&str; _]
1103 [230; 240) '["a", "b"]': [&str;_] 1103 [230; 240) '["a", "b"]': [&str; _]
1104 [231; 234) '"a"': &str 1104 [231; 234) '"a"': &str
1105 [236; 239) '"b"': &str 1105 [236; 239) '"b"': &str
1106 [251; 252) 'b': [[&str;_];_] 1106 [251; 252) 'b': [[&str; _]; _]
1107 [255; 265) '[a, ["b"]]': [[&str;_];_] 1107 [255; 265) '[a, ["b"]]': [[&str; _]; _]
1108 [256; 257) 'a': [&str;_] 1108 [256; 257) 'a': [&str; _]
1109 [259; 264) '["b"]': [&str;_] 1109 [259; 264) '["b"]': [&str; _]
1110 [260; 263) '"b"': &str 1110 [260; 263) '"b"': &str
1111 [275; 276) 'x': [u8;_] 1111 [275; 276) 'x': [u8; _]
1112 [288; 290) '[]': [u8;_] 1112 [288; 290) '[]': [u8; _]
1113 "### 1113 "###
1114 ); 1114 );
1115} 1115}
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index 4b268510c..a6ac18f86 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -479,7 +479,7 @@ fn indexing_arrays() {
479 @r###" 479 @r###"
480 [10; 26) '{ &mut...[2]; }': () 480 [10; 26) '{ &mut...[2]; }': ()
481 [12; 23) '&mut [9][2]': &mut {unknown} 481 [12; 23) '&mut [9][2]': &mut {unknown}
482 [17; 20) '[9]': [i32;_] 482 [17; 20) '[9]': [i32; _]
483 [17; 23) '[9][2]': {unknown} 483 [17; 23) '[9][2]': {unknown}
484 [18; 19) '9': i32 484 [18; 19) '9': i32
485 [21; 22) '2': i32 485 [21; 22) '2': i32
@@ -850,6 +850,7 @@ fn test<T: ApplyL>(t: T) {
850} 850}
851 851
852#[test] 852#[test]
853#[ignore]
853fn impl_trait() { 854fn impl_trait() {
854 assert_snapshot!( 855 assert_snapshot!(
855 infer(r#" 856 infer(r#"
@@ -1021,6 +1022,7 @@ fn test() {
1021} 1022}
1022 1023
1023#[test] 1024#[test]
1025#[ignore]
1024fn error_bound_chalk() { 1026fn error_bound_chalk() {
1025 let t = type_at( 1027 let t = type_at(
1026 r#" 1028 r#"
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 4aabd66dc..88af61e87 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -50,10 +50,19 @@ impl TraitSolver {
50 Err(_) => ra_db::Canceled::throw(), 50 Err(_) => ra_db::Canceled::throw(),
51 }; 51 };
52 52
53 let fuel = std::cell::Cell::new(CHALK_SOLVER_FUEL);
54
53 let solution = panic::catch_unwind({ 55 let solution = panic::catch_unwind({
54 let solver = panic::AssertUnwindSafe(&mut solver); 56 let solver = panic::AssertUnwindSafe(&mut solver);
55 let context = panic::AssertUnwindSafe(&context); 57 let context = panic::AssertUnwindSafe(&context);
56 move || solver.0.solve(context.0, goal) 58 move || {
59 solver.0.solve_limited(context.0, goal, || {
60 context.0.db.check_canceled();
61 let remaining = fuel.get();
62 fuel.set(remaining - 1);
63 remaining > 0
64 })
65 }
57 }); 66 });
58 67
59 let solution = match solution { 68 let solution = match solution {
@@ -78,7 +87,9 @@ impl TraitSolver {
78/// This controls the maximum size of types Chalk considers. If we set this too 87/// This controls the maximum size of types Chalk considers. If we set this too
79/// high, we can run into slow edge cases; if we set it too low, Chalk won't 88/// high, we can run into slow edge cases; if we set it too low, Chalk won't
80/// find some solutions. 89/// find some solutions.
81const CHALK_SOLVER_MAX_SIZE: usize = 4; 90const CHALK_SOLVER_MAX_SIZE: usize = 10;
91/// This controls how much 'time' we give the Chalk solver before giving up.
92const CHALK_SOLVER_FUEL: i32 = 100;
82 93
83#[derive(Debug, Copy, Clone)] 94#[derive(Debug, Copy, Clone)]
84struct ChalkContext<'a, DB> { 95struct ChalkContext<'a, DB> {
@@ -97,7 +108,8 @@ pub(crate) fn trait_solver_query(
97} 108}
98 109
99fn create_chalk_solver() -> chalk_solve::Solver<TypeFamily> { 110fn create_chalk_solver() -> chalk_solve::Solver<TypeFamily> {
100 let solver_choice = chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE }; 111 let solver_choice =
112 chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE, expected_answers: None };
101 solver_choice.into_solver() 113 solver_choice.into_solver()
102} 114}
103 115
@@ -232,7 +244,6 @@ fn solution_from_chalk(
232 let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<TypeFamily>>| { 244 let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<TypeFamily>>| {
233 let value = subst 245 let value = subst
234 .value 246 .value
235 .parameters
236 .into_iter() 247 .into_iter()
237 .map(|p| { 248 .map(|p| {
238 let ty = match p.ty() { 249 let ty = match p.ty() {
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 555930c9b..fe9cb556c 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -3,7 +3,7 @@ use std::{fmt, sync::Arc};
3 3
4use log::debug; 4use log::debug;
5 5
6use chalk_ir::{cast::Cast, Parameter, PlaceholderIndex, TypeName, UniverseIndex}; 6use chalk_ir::{cast::Cast, GoalData, Parameter, PlaceholderIndex, TypeName, UniverseIndex};
7 7
8use hir_def::{AssocContainerId, AssocItemId, GenericDefId, HasModule, Lookup, TypeAliasId}; 8use hir_def::{AssocContainerId, AssocItemId, GenericDefId, HasModule, Lookup, TypeAliasId};
9use ra_db::{ 9use ra_db::{
@@ -24,6 +24,8 @@ impl chalk_ir::family::TypeFamily for TypeFamily {
24 type InternedType = Box<chalk_ir::TyData<Self>>; 24 type InternedType = Box<chalk_ir::TyData<Self>>;
25 type InternedLifetime = chalk_ir::LifetimeData<Self>; 25 type InternedLifetime = chalk_ir::LifetimeData<Self>;
26 type InternedParameter = chalk_ir::ParameterData<Self>; 26 type InternedParameter = chalk_ir::ParameterData<Self>;
27 type InternedGoal = Arc<GoalData<Self>>;
28 type InternedSubstitution = Vec<Parameter<Self>>;
27 type DefId = InternId; 29 type DefId = InternId;
28 30
29 // FIXME: implement these 31 // FIXME: implement these
@@ -48,8 +50,8 @@ impl chalk_ir::family::TypeFamily for TypeFamily {
48 None 50 None
49 } 51 }
50 52
51 fn debug_projection( 53 fn debug_alias(
52 _projection: &chalk_ir::ProjectionTy<Self>, 54 _projection: &chalk_ir::AliasTy<Self>,
53 _fmt: &mut fmt::Formatter<'_>, 55 _fmt: &mut fmt::Formatter<'_>,
54 ) -> Option<fmt::Result> { 56 ) -> Option<fmt::Result> {
55 None 57 None
@@ -78,6 +80,24 @@ impl chalk_ir::family::TypeFamily for TypeFamily {
78 fn parameter_data(parameter: &chalk_ir::ParameterData<Self>) -> &chalk_ir::ParameterData<Self> { 80 fn parameter_data(parameter: &chalk_ir::ParameterData<Self>) -> &chalk_ir::ParameterData<Self> {
79 parameter 81 parameter
80 } 82 }
83
84 fn intern_goal(goal: GoalData<Self>) -> Arc<GoalData<Self>> {
85 Arc::new(goal)
86 }
87
88 fn goal_data(goal: &Arc<GoalData<Self>>) -> &GoalData<Self> {
89 goal
90 }
91
92 fn intern_substitution<E>(
93 data: impl IntoIterator<Item = Result<Parameter<Self>, E>>,
94 ) -> Result<Vec<Parameter<Self>>, E> {
95 data.into_iter().collect()
96 }
97
98 fn substitution_data(substitution: &Vec<Parameter<Self>>) -> &[Parameter<Self>] {
99 substitution
100 }
81} 101}
82 102
83impl chalk_ir::family::HasTypeFamily for TypeFamily { 103impl chalk_ir::family::HasTypeFamily for TypeFamily {
@@ -114,13 +134,13 @@ impl ToChalk for Ty {
114 match self { 134 match self {
115 Ty::Apply(apply_ty) => { 135 Ty::Apply(apply_ty) => {
116 let name = apply_ty.ctor.to_chalk(db); 136 let name = apply_ty.ctor.to_chalk(db);
117 let parameters = apply_ty.parameters.to_chalk(db); 137 let substitution = apply_ty.parameters.to_chalk(db);
118 chalk_ir::ApplicationTy { name, parameters }.cast().intern() 138 chalk_ir::ApplicationTy { name, substitution }.cast().intern()
119 } 139 }
120 Ty::Projection(proj_ty) => { 140 Ty::Projection(proj_ty) => {
121 let associated_ty_id = proj_ty.associated_ty.to_chalk(db); 141 let associated_ty_id = proj_ty.associated_ty.to_chalk(db);
122 let parameters = proj_ty.parameters.to_chalk(db); 142 let substitution = proj_ty.parameters.to_chalk(db);
123 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast().intern() 143 chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern()
124 } 144 }
125 Ty::Param { idx, .. } => { 145 Ty::Param { idx, .. } => {
126 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize } 146 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }
@@ -135,23 +155,13 @@ impl ToChalk for Ty {
135 .cloned() 155 .cloned()
136 .map(|p| p.to_chalk(db)) 156 .map(|p| p.to_chalk(db))
137 .collect(); 157 .collect();
138 let bounded_ty = chalk_ir::BoundedTy { bounds: make_binders(where_clauses, 1) }; 158 let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) };
139 chalk_ir::TyData::Dyn(bounded_ty).intern() 159 chalk_ir::TyData::Dyn(bounded_ty).intern()
140 } 160 }
141 Ty::Opaque(predicates) => { 161 Ty::Opaque(_) | Ty::Unknown => {
142 let where_clauses = predicates 162 let substitution = chalk_ir::Substitution::empty();
143 .iter()
144 .filter(|p| !p.is_error())
145 .cloned()
146 .map(|p| p.to_chalk(db))
147 .collect();
148 let bounded_ty = chalk_ir::BoundedTy { bounds: make_binders(where_clauses, 1) };
149 chalk_ir::TyData::Opaque(bounded_ty).intern()
150 }
151 Ty::Unknown => {
152 let parameters = Vec::new();
153 let name = TypeName::Error; 163 let name = TypeName::Error;
154 chalk_ir::ApplicationTy { name, parameters }.cast().intern() 164 chalk_ir::ApplicationTy { name, substitution }.cast().intern()
155 } 165 }
156 } 166 }
157 } 167 }
@@ -161,7 +171,7 @@ impl ToChalk for Ty {
161 TypeName::Error => Ty::Unknown, 171 TypeName::Error => Ty::Unknown,
162 _ => { 172 _ => {
163 let ctor = from_chalk(db, apply_ty.name); 173 let ctor = from_chalk(db, apply_ty.name);
164 let parameters = from_chalk(db, apply_ty.parameters); 174 let parameters = from_chalk(db, apply_ty.substitution);
165 Ty::Apply(ApplicationTy { ctor, parameters }) 175 Ty::Apply(ApplicationTy { ctor, parameters })
166 } 176 }
167 }, 177 },
@@ -169,12 +179,12 @@ impl ToChalk for Ty {
169 assert_eq!(idx.ui, UniverseIndex::ROOT); 179 assert_eq!(idx.ui, UniverseIndex::ROOT);
170 Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() } 180 Ty::Param { idx: idx.idx as u32, name: crate::Name::missing() }
171 } 181 }
172 chalk_ir::TyData::Projection(proj) => { 182 chalk_ir::TyData::Alias(proj) => {
173 let associated_ty = from_chalk(db, proj.associated_ty_id); 183 let associated_ty = from_chalk(db, proj.associated_ty_id);
174 let parameters = from_chalk(db, proj.parameters); 184 let parameters = from_chalk(db, proj.substitution);
175 Ty::Projection(ProjectionTy { associated_ty, parameters }) 185 Ty::Projection(ProjectionTy { associated_ty, parameters })
176 } 186 }
177 chalk_ir::TyData::ForAll(_) => unimplemented!(), 187 chalk_ir::TyData::Function(_) => unimplemented!(),
178 chalk_ir::TyData::BoundVar(idx) => Ty::Bound(idx as u32), 188 chalk_ir::TyData::BoundVar(idx) => Ty::Bound(idx as u32),
179 chalk_ir::TyData::InferenceVar(_iv) => Ty::Unknown, 189 chalk_ir::TyData::InferenceVar(_iv) => Ty::Unknown,
180 chalk_ir::TyData::Dyn(where_clauses) => { 190 chalk_ir::TyData::Dyn(where_clauses) => {
@@ -183,27 +193,18 @@ impl ToChalk for Ty {
183 where_clauses.bounds.value.into_iter().map(|c| from_chalk(db, c)).collect(); 193 where_clauses.bounds.value.into_iter().map(|c| from_chalk(db, c)).collect();
184 Ty::Dyn(predicates) 194 Ty::Dyn(predicates)
185 } 195 }
186 chalk_ir::TyData::Opaque(where_clauses) => {
187 assert_eq!(where_clauses.bounds.binders.len(), 1);
188 let predicates =
189 where_clauses.bounds.value.into_iter().map(|c| from_chalk(db, c)).collect();
190 Ty::Opaque(predicates)
191 }
192 } 196 }
193 } 197 }
194} 198}
195 199
196impl ToChalk for Substs { 200impl ToChalk for Substs {
197 type Chalk = Vec<chalk_ir::Parameter<TypeFamily>>; 201 type Chalk = chalk_ir::Substitution<TypeFamily>;
198 202
199 fn to_chalk(self, db: &impl HirDatabase) -> Vec<Parameter<TypeFamily>> { 203 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Substitution<TypeFamily> {
200 self.iter().map(|ty| ty.clone().to_chalk(db).cast()).collect() 204 chalk_ir::Substitution::from(self.iter().map(|ty| ty.clone().to_chalk(db)))
201 } 205 }
202 206
203 fn from_chalk( 207 fn from_chalk(db: &impl HirDatabase, parameters: chalk_ir::Substitution<TypeFamily>) -> Substs {
204 db: &impl HirDatabase,
205 parameters: Vec<chalk_ir::Parameter<TypeFamily>>,
206 ) -> Substs {
207 let tys = parameters 208 let tys = parameters
208 .into_iter() 209 .into_iter()
209 .map(|p| match p.ty() { 210 .map(|p| match p.ty() {
@@ -220,13 +221,13 @@ impl ToChalk for TraitRef {
220 221
221 fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef<TypeFamily> { 222 fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef<TypeFamily> {
222 let trait_id = self.trait_.to_chalk(db); 223 let trait_id = self.trait_.to_chalk(db);
223 let parameters = self.substs.to_chalk(db); 224 let substitution = self.substs.to_chalk(db);
224 chalk_ir::TraitRef { trait_id, parameters } 225 chalk_ir::TraitRef { trait_id, substitution }
225 } 226 }
226 227
227 fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef<TypeFamily>) -> Self { 228 fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef<TypeFamily>) -> Self {
228 let trait_ = from_chalk(db, trait_ref.trait_id); 229 let trait_ = from_chalk(db, trait_ref.trait_id);
229 let substs = from_chalk(db, trait_ref.parameters); 230 let substs = from_chalk(db, trait_ref.substitution);
230 TraitRef { trait_, substs } 231 TraitRef { trait_, substs }
231 } 232 }
232} 233}
@@ -317,8 +318,8 @@ impl ToChalk for GenericPredicate {
317 make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0) 318 make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0)
318 } 319 }
319 GenericPredicate::Projection(projection_pred) => make_binders( 320 GenericPredicate::Projection(projection_pred) => make_binders(
320 chalk_ir::WhereClause::ProjectionEq(chalk_ir::ProjectionEq { 321 chalk_ir::WhereClause::AliasEq(chalk_ir::AliasEq {
321 projection: projection_pred.projection_ty.to_chalk(db), 322 alias: projection_pred.projection_ty.to_chalk(db),
322 ty: projection_pred.ty.to_chalk(db), 323 ty: projection_pred.ty.to_chalk(db),
323 }), 324 }),
324 0, 325 0,
@@ -335,8 +336,8 @@ impl ToChalk for GenericPredicate {
335 chalk_ir::WhereClause::Implemented(tr) => { 336 chalk_ir::WhereClause::Implemented(tr) => {
336 GenericPredicate::Implemented(from_chalk(db, tr)) 337 GenericPredicate::Implemented(from_chalk(db, tr))
337 } 338 }
338 chalk_ir::WhereClause::ProjectionEq(projection_eq) => { 339 chalk_ir::WhereClause::AliasEq(projection_eq) => {
339 let projection_ty = from_chalk(db, projection_eq.projection); 340 let projection_ty = from_chalk(db, projection_eq.alias);
340 let ty = from_chalk(db, projection_eq.ty); 341 let ty = from_chalk(db, projection_eq.ty);
341 GenericPredicate::Projection(super::ProjectionPredicate { projection_ty, ty }) 342 GenericPredicate::Projection(super::ProjectionPredicate { projection_ty, ty })
342 } 343 }
@@ -345,22 +346,22 @@ impl ToChalk for GenericPredicate {
345} 346}
346 347
347impl ToChalk for ProjectionTy { 348impl ToChalk for ProjectionTy {
348 type Chalk = chalk_ir::ProjectionTy<TypeFamily>; 349 type Chalk = chalk_ir::AliasTy<TypeFamily>;
349 350
350 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ProjectionTy<TypeFamily> { 351 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::AliasTy<TypeFamily> {
351 chalk_ir::ProjectionTy { 352 chalk_ir::AliasTy {
352 associated_ty_id: self.associated_ty.to_chalk(db), 353 associated_ty_id: self.associated_ty.to_chalk(db),
353 parameters: self.parameters.to_chalk(db), 354 substitution: self.parameters.to_chalk(db),
354 } 355 }
355 } 356 }
356 357
357 fn from_chalk( 358 fn from_chalk(
358 db: &impl HirDatabase, 359 db: &impl HirDatabase,
359 projection_ty: chalk_ir::ProjectionTy<TypeFamily>, 360 projection_ty: chalk_ir::AliasTy<TypeFamily>,
360 ) -> ProjectionTy { 361 ) -> ProjectionTy {
361 ProjectionTy { 362 ProjectionTy {
362 associated_ty: from_chalk(db, projection_ty.associated_ty_id), 363 associated_ty: from_chalk(db, projection_ty.associated_ty_id),
363 parameters: from_chalk(db, projection_ty.parameters), 364 parameters: from_chalk(db, projection_ty.substitution),
364 } 365 }
365 } 366 }
366} 367}
@@ -369,10 +370,7 @@ impl ToChalk for super::ProjectionPredicate {
369 type Chalk = chalk_ir::Normalize<TypeFamily>; 370 type Chalk = chalk_ir::Normalize<TypeFamily>;
370 371
371 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize<TypeFamily> { 372 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize<TypeFamily> {
372 chalk_ir::Normalize { 373 chalk_ir::Normalize { alias: self.projection_ty.to_chalk(db), ty: self.ty.to_chalk(db) }
373 projection: self.projection_ty.to_chalk(db),
374 ty: self.ty.to_chalk(db),
375 }
376 } 374 }
377 375
378 fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize<TypeFamily>) -> Self { 376 fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize<TypeFamily>) -> Self {
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index 2c9f9dce0..53817d1f7 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -39,7 +39,7 @@ ra_assists = { path = "../ra_assists" }
39hir = { path = "../ra_hir", package = "ra_hir" } 39hir = { path = "../ra_hir", package = "ra_hir" }
40 40
41[dev-dependencies] 41[dev-dependencies]
42insta = "0.12.0" 42insta = "0.13.0"
43 43
44[dev-dependencies.proptest] 44[dev-dependencies.proptest]
45version = "0.9.0" 45version = "0.9.0"
diff --git a/crates/ra_ide/src/assists.rs b/crates/ra_ide/src/assists.rs
index a936900da..c43c45c65 100644
--- a/crates/ra_ide/src/assists.rs
+++ b/crates/ra_ide/src/assists.rs
@@ -2,8 +2,9 @@
2 2
3use ra_db::{FilePosition, FileRange}; 3use ra_db::{FilePosition, FileRange};
4 4
5use crate::{db::RootDatabase, FileId, SourceChange, SourceFileEdit}; 5use crate::{
6 6 db::RootDatabase, imports_locator::ImportsLocatorIde, FileId, SourceChange, SourceFileEdit,
7};
7use either::Either; 8use either::Either;
8pub use ra_assists::AssistId; 9pub use ra_assists::AssistId;
9use ra_assists::{AssistAction, AssistLabel}; 10use ra_assists::{AssistAction, AssistLabel};
@@ -16,7 +17,7 @@ pub struct Assist {
16} 17}
17 18
18pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> { 19pub(crate) fn assists(db: &RootDatabase, frange: FileRange) -> Vec<Assist> {
19 ra_assists::assists(db, frange) 20 ra_assists::assists_with_imports_locator(db, frange, ImportsLocatorIde::new(db))
20 .into_iter() 21 .into_iter()
21 .map(|assist| { 22 .map(|assist| {
22 let file_id = frange.file_id; 23 let file_id = frange.file_id;
diff --git a/crates/ra_ide/src/change.rs b/crates/ra_ide/src/change.rs
index b0aa2c8e0..45a58690b 100644
--- a/crates/ra_ide/src/change.rs
+++ b/crates/ra_ide/src/change.rs
@@ -166,13 +166,15 @@ impl LibraryData {
166const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100); 166const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
167 167
168impl RootDatabase { 168impl RootDatabase {
169 pub(crate) fn request_cancellation(&mut self) {
170 let _p = profile("RootDatabase::request_cancellation");
171 self.salsa_runtime_mut().synthetic_write(Durability::LOW);
172 }
173
169 pub(crate) fn apply_change(&mut self, change: AnalysisChange) { 174 pub(crate) fn apply_change(&mut self, change: AnalysisChange) {
170 let _p = profile("RootDatabase::apply_change"); 175 let _p = profile("RootDatabase::apply_change");
176 self.request_cancellation();
171 log::info!("apply_change {:?}", change); 177 log::info!("apply_change {:?}", change);
172 {
173 let _p = profile("RootDatabase::apply_change/cancellation");
174 self.salsa_runtime_mut().synthetic_write(Durability::LOW);
175 }
176 if !change.new_roots.is_empty() { 178 if !change.new_roots.is_empty() {
177 let mut local_roots = Vec::clone(&self.local_roots()); 179 let mut local_roots = Vec::clone(&self.local_roots());
178 for (root_id, is_local) in change.new_roots { 180 for (root_id, is_local) in change.new_roots {
@@ -299,45 +301,74 @@ impl RootDatabase {
299 )*} 301 )*}
300 } 302 }
301 sweep_each_query![ 303 sweep_each_query![
304 // SourceDatabase
302 ra_db::ParseQuery 305 ra_db::ParseQuery
303 ra_db::SourceRootCratesQuery 306 ra_db::SourceRootCratesQuery
307
308 // AstDatabase
304 hir::db::AstIdMapQuery 309 hir::db::AstIdMapQuery
305 hir::db::ParseMacroQuery 310 hir::db::InternMacroQuery
306 hir::db::MacroDefQuery
307 hir::db::MacroArgQuery 311 hir::db::MacroArgQuery
312 hir::db::MacroDefQuery
313 hir::db::ParseMacroQuery
308 hir::db::MacroExpandQuery 314 hir::db::MacroExpandQuery
315
316 // DefDatabase
317 hir::db::RawItemsQuery
318 hir::db::ComputeCrateDefMapQuery
309 hir::db::StructDataQuery 319 hir::db::StructDataQuery
320 hir::db::UnionDataQuery
310 hir::db::EnumDataQuery 321 hir::db::EnumDataQuery
322 hir::db::ImplDataQuery
311 hir::db::TraitDataQuery 323 hir::db::TraitDataQuery
312 hir::db::RawItemsQuery
313 hir::db::ComputeCrateDefMapQuery
314 hir::db::GenericParamsQuery
315 hir::db::FunctionDataQuery
316 hir::db::TypeAliasDataQuery 324 hir::db::TypeAliasDataQuery
325 hir::db::FunctionDataQuery
317 hir::db::ConstDataQuery 326 hir::db::ConstDataQuery
318 hir::db::StaticDataQuery 327 hir::db::StaticDataQuery
328 hir::db::BodyWithSourceMapQuery
329 hir::db::BodyQuery
330 hir::db::ExprScopesQuery
331 hir::db::GenericParamsQuery
332 hir::db::AttrsQuery
319 hir::db::ModuleLangItemsQuery 333 hir::db::ModuleLangItemsQuery
320 hir::db::CrateLangItemsQuery 334 hir::db::CrateLangItemsQuery
321 hir::db::LangItemQuery 335 hir::db::LangItemQuery
322 hir::db::DocumentationQuery 336 hir::db::DocumentationQuery
323 hir::db::ExprScopesQuery 337
338 // InternDatabase
339 hir::db::InternFunctionQuery
340 hir::db::InternStructQuery
341 hir::db::InternUnionQuery
342 hir::db::InternEnumQuery
343 hir::db::InternConstQuery
344 hir::db::InternStaticQuery
345 hir::db::InternTraitQuery
346 hir::db::InternTypeAliasQuery
347 hir::db::InternImplQuery
348
349 // HirDatabase
324 hir::db::DoInferQuery 350 hir::db::DoInferQuery
325 hir::db::TyQuery 351 hir::db::TyQuery
326 hir::db::ValueTyQuery 352 hir::db::ValueTyQuery
353 hir::db::ImplSelfTyQuery
354 hir::db::ImplTraitQuery
327 hir::db::FieldTypesQuery 355 hir::db::FieldTypesQuery
328 hir::db::CallableItemSignatureQuery 356 hir::db::CallableItemSignatureQuery
357 hir::db::GenericPredicatesForParamQuery
329 hir::db::GenericPredicatesQuery 358 hir::db::GenericPredicatesQuery
330 hir::db::GenericDefaultsQuery 359 hir::db::GenericDefaultsQuery
331 hir::db::BodyWithSourceMapQuery
332 hir::db::BodyQuery
333 hir::db::ImplsInCrateQuery 360 hir::db::ImplsInCrateQuery
334 hir::db::ImplsForTraitQuery 361 hir::db::ImplsForTraitQuery
362 hir::db::TraitSolverQuery
363 hir::db::InternTypeCtorQuery
364 hir::db::InternChalkImplQuery
365 hir::db::InternAssocTyValueQuery
335 hir::db::AssociatedTyDataQuery 366 hir::db::AssociatedTyDataQuery
367 hir::db::AssociatedTyValueQuery
368 hir::db::TraitSolveQuery
336 hir::db::TraitDatumQuery 369 hir::db::TraitDatumQuery
337 hir::db::StructDatumQuery 370 hir::db::StructDatumQuery
338 hir::db::ImplDatumQuery 371 hir::db::ImplDatumQuery
339 hir::db::ImplDataQuery
340 hir::db::TraitSolveQuery
341 ]; 372 ];
342 acc.sort_by_key(|it| std::cmp::Reverse(it.1)); 373 acc.sort_by_key(|it| std::cmp::Reverse(it.1));
343 acc 374 acc
diff --git a/crates/ra_ide/src/expand.rs b/crates/ra_ide/src/expand.rs
index b82259a3d..831438c09 100644
--- a/crates/ra_ide/src/expand.rs
+++ b/crates/ra_ide/src/expand.rs
@@ -79,6 +79,14 @@ pub(crate) fn descend_into_macros(
79 let source_analyzer = 79 let source_analyzer =
80 hir::SourceAnalyzer::new(db, src.with_value(src.value.parent()).as_ref(), None); 80 hir::SourceAnalyzer::new(db, src.with_value(src.value.parent()).as_ref(), None);
81 81
82 descend_into_macros_with_analyzer(db, &source_analyzer, src)
83}
84
85pub(crate) fn descend_into_macros_with_analyzer(
86 db: &RootDatabase,
87 source_analyzer: &hir::SourceAnalyzer,
88 src: InFile<SyntaxToken>,
89) -> InFile<SyntaxToken> {
82 successors(Some(src), |token| { 90 successors(Some(src), |token| {
83 let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; 91 let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?;
84 let tt = macro_call.token_tree()?; 92 let tt = macro_call.token_tree()?;
diff --git a/crates/ra_ide/src/imports_locator.rs b/crates/ra_ide/src/imports_locator.rs
new file mode 100644
index 000000000..48b014c7d
--- /dev/null
+++ b/crates/ra_ide/src/imports_locator.rs
@@ -0,0 +1,76 @@
1//! This module contains an import search funcionality that is provided to the ra_assists module.
2//! Later, this should be moved away to a separate crate that is accessible from the ra_assists module.
3
4use crate::{
5 db::RootDatabase,
6 references::{classify_name, NameDefinition, NameKind},
7 symbol_index::{self, FileSymbol},
8 Query,
9};
10use hir::{db::HirDatabase, ModuleDef, SourceBinder};
11use ra_assists::ImportsLocator;
12use ra_prof::profile;
13use ra_syntax::{ast, AstNode, SyntaxKind::NAME};
14
15pub(crate) struct ImportsLocatorIde<'a> {
16 source_binder: SourceBinder<'a, RootDatabase>,
17}
18
19impl<'a> ImportsLocatorIde<'a> {
20 pub(crate) fn new(db: &'a RootDatabase) -> Self {
21 Self { source_binder: SourceBinder::new(db) }
22 }
23
24 fn get_name_definition(
25 &mut self,
26 db: &impl HirDatabase,
27 import_candidate: &FileSymbol,
28 ) -> Option<NameDefinition> {
29 let _p = profile("get_name_definition");
30 let file_id = import_candidate.file_id.into();
31 let candidate_node = import_candidate.ptr.to_node(&db.parse_or_expand(file_id)?);
32 let candidate_name_node = if candidate_node.kind() != NAME {
33 candidate_node.children().find(|it| it.kind() == NAME)?
34 } else {
35 candidate_node
36 };
37 classify_name(
38 &mut self.source_binder,
39 hir::InFile { file_id, value: &ast::Name::cast(candidate_name_node)? },
40 )
41 }
42}
43
44impl ImportsLocator for ImportsLocatorIde<'_> {
45 fn find_imports(&mut self, name_to_import: &str) -> Vec<ModuleDef> {
46 let _p = profile("search_for_imports");
47 let db = self.source_binder.db;
48
49 let project_results = {
50 let mut query = Query::new(name_to_import.to_string());
51 query.exact();
52 query.limit(40);
53 symbol_index::world_symbols(db, query)
54 };
55 let lib_results = {
56 let mut query = Query::new(name_to_import.to_string());
57 query.libs();
58 query.exact();
59 query.limit(40);
60 symbol_index::world_symbols(db, query)
61 };
62
63 project_results
64 .into_iter()
65 .chain(lib_results.into_iter())
66 .filter_map(|import_candidate| self.get_name_definition(db, &import_candidate))
67 .filter_map(|name_definition_to_import| {
68 if let NameKind::Def(module_def) = name_definition_to_import.kind {
69 Some(module_def)
70 } else {
71 None
72 }
73 })
74 .collect()
75 }
76}
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 4d8deb21c..03ad6b2c1 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -30,6 +30,7 @@ mod syntax_highlighting;
30mod parent_module; 30mod parent_module;
31mod references; 31mod references;
32mod impls; 32mod impls;
33mod imports_locator;
33mod assists; 34mod assists;
34mod diagnostics; 35mod diagnostics;
35mod syntax_tree; 36mod syntax_tree;
@@ -202,6 +203,9 @@ impl AnalysisHost {
202 pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> { 203 pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> {
203 self.db.per_query_memory_usage() 204 self.db.per_query_memory_usage()
204 } 205 }
206 pub fn request_cancellation(&mut self) {
207 self.db.request_cancellation();
208 }
205 pub fn raw_database( 209 pub fn raw_database(
206 &self, 210 &self,
207 ) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) { 211 ) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) {
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index 5e2fe1905..ebded715d 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -112,25 +112,20 @@ impl IntoIterator for ReferenceSearchResult {
112 112
113pub(crate) fn find_all_refs( 113pub(crate) fn find_all_refs(
114 db: &RootDatabase, 114 db: &RootDatabase,
115 mut position: FilePosition, 115 position: FilePosition,
116 search_scope: Option<SearchScope>, 116 search_scope: Option<SearchScope>,
117) -> Option<RangeInfo<ReferenceSearchResult>> { 117) -> Option<RangeInfo<ReferenceSearchResult>> {
118 let parse = db.parse(position.file_id); 118 let parse = db.parse(position.file_id);
119 let syntax = parse.tree().syntax().clone(); 119 let syntax = parse.tree().syntax().clone();
120 120
121 let token = syntax.token_at_offset(position.offset); 121 let (opt_name, search_kind) =
122 let mut search_kind = ReferenceKind::Other; 122 if let Some(name) = get_struct_def_name_for_struc_litetal_search(&syntax, position) {
123 (Some(name), ReferenceKind::StructLiteral)
124 } else {
125 (find_node_at_offset::<ast::Name>(&syntax, position.offset), ReferenceKind::Other)
126 };
123 127
124 if let TokenAtOffset::Between(ref left, ref right) = token { 128 let RangeInfo { range, info: (name, def) } = find_name(db, &syntax, position, opt_name)?;
125 if (right.kind() == SyntaxKind::L_CURLY || right.kind() == SyntaxKind::L_PAREN)
126 && left.kind() != SyntaxKind::IDENT
127 {
128 position = FilePosition { offset: left.text_range().start(), ..position };
129 search_kind = ReferenceKind::StructLiteral;
130 }
131 }
132
133 let RangeInfo { range, info: (name, def) } = find_name(db, &syntax, position)?;
134 129
135 let declaration = match def.kind { 130 let declaration = match def.kind {
136 NameKind::Macro(mac) => mac.to_nav(db), 131 NameKind::Macro(mac) => mac.to_nav(db),
@@ -170,9 +165,10 @@ fn find_name(
170 db: &RootDatabase, 165 db: &RootDatabase,
171 syntax: &SyntaxNode, 166 syntax: &SyntaxNode,
172 position: FilePosition, 167 position: FilePosition,
168 opt_name: Option<ast::Name>,
173) -> Option<RangeInfo<(String, NameDefinition)>> { 169) -> Option<RangeInfo<(String, NameDefinition)>> {
174 let mut sb = SourceBinder::new(db); 170 let mut sb = SourceBinder::new(db);
175 if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, position.offset) { 171 if let Some(name) = opt_name {
176 let def = classify_name(&mut sb, InFile::new(position.file_id.into(), &name))?; 172 let def = classify_name(&mut sb, InFile::new(position.file_id.into(), &name))?;
177 let range = name.syntax().text_range(); 173 let range = name.syntax().text_range();
178 return Some(RangeInfo::new(range, (name.text().to_string(), def))); 174 return Some(RangeInfo::new(range, (name.text().to_string(), def)));
@@ -218,15 +214,8 @@ fn process_definition(
218 if let Some(d) = classify_name_ref(&mut sb, InFile::new(file_id.into(), &name_ref)) 214 if let Some(d) = classify_name_ref(&mut sb, InFile::new(file_id.into(), &name_ref))
219 { 215 {
220 if d == def { 216 if d == def {
221 let kind = if name_ref 217 let kind = if is_record_lit_name_ref(&name_ref)
222 .syntax() 218 || is_call_expr_name_ref(&name_ref)
223 .ancestors()
224 .find_map(ast::RecordLit::cast)
225 .and_then(|l| l.path())
226 .and_then(|p| p.segment())
227 .and_then(|p| p.name_ref())
228 .map(|n| n == name_ref)
229 .unwrap_or(false)
230 { 219 {
231 ReferenceKind::StructLiteral 220 ReferenceKind::StructLiteral
232 } else { 221 } else {
@@ -301,6 +290,49 @@ fn reference_access(kind: &NameKind, name_ref: &ast::NameRef) -> Option<Referenc
301 mode.or(Some(ReferenceAccess::Read)) 290 mode.or(Some(ReferenceAccess::Read))
302} 291}
303 292
293fn is_record_lit_name_ref(name_ref: &ast::NameRef) -> bool {
294 name_ref
295 .syntax()
296 .ancestors()
297 .find_map(ast::RecordLit::cast)
298 .and_then(|l| l.path())
299 .and_then(|p| p.segment())
300 .map(|p| p.name_ref().as_ref() == Some(name_ref))
301 .unwrap_or(false)
302}
303
304fn get_struct_def_name_for_struc_litetal_search(
305 syntax: &SyntaxNode,
306 position: FilePosition,
307) -> Option<ast::Name> {
308 if let TokenAtOffset::Between(ref left, ref right) = syntax.token_at_offset(position.offset) {
309 if right.kind() != SyntaxKind::L_CURLY && right.kind() != SyntaxKind::L_PAREN {
310 return None;
311 }
312 if let Some(name) = find_node_at_offset::<ast::Name>(&syntax, left.text_range().start()) {
313 return name.syntax().ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name());
314 }
315 if find_node_at_offset::<ast::TypeParamList>(&syntax, left.text_range().start()).is_some() {
316 return left.ancestors().find_map(ast::StructDef::cast).and_then(|l| l.name());
317 }
318 }
319 None
320}
321
322fn is_call_expr_name_ref(name_ref: &ast::NameRef) -> bool {
323 name_ref
324 .syntax()
325 .ancestors()
326 .find_map(ast::CallExpr::cast)
327 .and_then(|c| match c.expr()? {
328 ast::Expr::PathExpr(p) => {
329 Some(p.path()?.segment()?.name_ref().as_ref() == Some(name_ref))
330 }
331 _ => None,
332 })
333 .unwrap_or(false)
334}
335
304#[cfg(test)] 336#[cfg(test)]
305mod tests { 337mod tests {
306 use crate::{ 338 use crate::{
@@ -309,7 +341,7 @@ mod tests {
309 }; 341 };
310 342
311 #[test] 343 #[test]
312 fn test_struct_literal() { 344 fn test_struct_literal_after_space() {
313 let code = r#" 345 let code = r#"
314 struct Foo <|>{ 346 struct Foo <|>{
315 a: i32, 347 a: i32,
@@ -331,6 +363,58 @@ mod tests {
331 } 363 }
332 364
333 #[test] 365 #[test]
366 fn test_struct_literal_befor_space() {
367 let code = r#"
368 struct Foo<|> {}
369 fn main() {
370 let f: Foo;
371 f = Foo {};
372 }"#;
373
374 let refs = get_all_refs(code);
375 check_result(
376 refs,
377 "Foo STRUCT_DEF FileId(1) [5; 18) [12; 15) Other",
378 &["FileId(1) [54; 57) Other", "FileId(1) [71; 74) StructLiteral"],
379 );
380 }
381
382 #[test]
383 fn test_struct_literal_with_generic_type() {
384 let code = r#"
385 struct Foo<T> <|>{}
386 fn main() {
387 let f: Foo::<i32>;
388 f = Foo {};
389 }"#;
390
391 let refs = get_all_refs(code);
392 check_result(
393 refs,
394 "Foo STRUCT_DEF FileId(1) [5; 21) [12; 15) Other",
395 &["FileId(1) [81; 84) StructLiteral"],
396 );
397 }
398
399 #[test]
400 fn test_struct_literal_for_tuple() {
401 let code = r#"
402 struct Foo<|>(i32);
403
404 fn main() {
405 let f: Foo;
406 f = Foo(1);
407 }"#;
408
409 let refs = get_all_refs(code);
410 check_result(
411 refs,
412 "Foo STRUCT_DEF FileId(1) [5; 21) [12; 15) Other",
413 &["FileId(1) [71; 74) StructLiteral"],
414 );
415 }
416
417 #[test]
334 fn test_find_all_refs_for_local() { 418 fn test_find_all_refs_for_local() {
335 let code = r#" 419 let code = r#"