diff options
459 files changed, 7551 insertions, 7804 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 20663196d..2acd44012 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml | |||
@@ -61,9 +61,6 @@ jobs: | |||
61 | override: true | 61 | override: true |
62 | components: rustfmt, rust-src | 62 | components: rustfmt, rust-src |
63 | 63 | ||
64 | - if: matrix.os == 'ubuntu-latest' | ||
65 | run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ | ||
66 | |||
67 | - name: Cache cargo directories | 64 | - name: Cache cargo directories |
68 | uses: actions/cache@v2 | 65 | uses: actions/cache@v2 |
69 | with: | 66 | with: |
@@ -108,8 +105,6 @@ jobs: | |||
108 | override: true | 105 | override: true |
109 | target: 'powerpc-unknown-linux-gnu' | 106 | target: 'powerpc-unknown-linux-gnu' |
110 | 107 | ||
111 | - run: sudo chown -R $(whoami):$(id -ng) ~/.cargo/ | ||
112 | |||
113 | - name: Cache cargo directories | 108 | - name: Cache cargo directories |
114 | uses: actions/cache@v2 | 109 | uses: actions/cache@v2 |
115 | with: | 110 | with: |
diff --git a/.github/workflows/metrics.yaml b/.github/workflows/metrics.yaml new file mode 100644 index 000000000..ea780e875 --- /dev/null +++ b/.github/workflows/metrics.yaml | |||
@@ -0,0 +1,32 @@ | |||
1 | name: metrics | ||
2 | on: | ||
3 | push: | ||
4 | branches: | ||
5 | - master | ||
6 | |||
7 | env: | ||
8 | CARGO_INCREMENTAL: 0 | ||
9 | CARGO_NET_RETRY: 10 | ||
10 | RUSTFLAGS: -D warnings | ||
11 | RUSTUP_MAX_RETRIES: 10 | ||
12 | |||
13 | jobs: | ||
14 | metrics: | ||
15 | runs-on: ubuntu-latest | ||
16 | |||
17 | steps: | ||
18 | - name: Checkout repository | ||
19 | uses: actions/checkout@v2 | ||
20 | |||
21 | - name: Install Rust toolchain | ||
22 | uses: actions-rs/toolchain@v1 | ||
23 | with: | ||
24 | toolchain: stable | ||
25 | profile: minimal | ||
26 | override: true | ||
27 | components: rust-src | ||
28 | |||
29 | - name: Collect metrics | ||
30 | run: cargo xtask metrics | ||
31 | env: | ||
32 | METRICS_TOKEN: ${{ secrets.METRICS_TOKEN }} | ||
diff --git a/Cargo.lock b/Cargo.lock index 0a35eb793..234c31406 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -35,9 +35,9 @@ dependencies = [ | |||
35 | 35 | ||
36 | [[package]] | 36 | [[package]] |
37 | name = "anyhow" | 37 | name = "anyhow" |
38 | version = "1.0.31" | 38 | version = "1.0.32" |
39 | source = "registry+https://github.com/rust-lang/crates.io-index" | 39 | source = "registry+https://github.com/rust-lang/crates.io-index" |
40 | checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" | 40 | checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" |
41 | 41 | ||
42 | [[package]] | 42 | [[package]] |
43 | name = "anymap" | 43 | name = "anymap" |
@@ -102,13 +102,12 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" | |||
102 | 102 | ||
103 | [[package]] | 103 | [[package]] |
104 | name = "cargo_metadata" | 104 | name = "cargo_metadata" |
105 | version = "0.10.1" | 105 | version = "0.11.1" |
106 | source = "registry+https://github.com/rust-lang/crates.io-index" | 106 | source = "registry+https://github.com/rust-lang/crates.io-index" |
107 | checksum = "052dbdd9db69a339d5fa9ac87bfe2e1319f709119f0345988a597af82bb1011c" | 107 | checksum = "89fec17b16f1ac67908af82e47d0a90a7afd0e1827b181cd77504323d3263d35" |
108 | dependencies = [ | 108 | dependencies = [ |
109 | "semver", | 109 | "semver", |
110 | "serde", | 110 | "serde", |
111 | "serde_derive", | ||
112 | "serde_json", | 111 | "serde_json", |
113 | ] | 112 | ] |
114 | 113 | ||
@@ -126,9 +125,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" | |||
126 | 125 | ||
127 | [[package]] | 126 | [[package]] |
128 | name = "chalk-derive" | 127 | name = "chalk-derive" |
129 | version = "0.18.0" | 128 | version = "0.19.0" |
130 | source = "registry+https://github.com/rust-lang/crates.io-index" | 129 | source = "registry+https://github.com/rust-lang/crates.io-index" |
131 | checksum = "eea3a22f0c30b2504ac4ab58934dac0d00b92a4d7788df32795cabca24c3f929" | 130 | checksum = "654c611946ba2629c5028cb7708687af975faf2c29d731824cb294c873df4697" |
132 | dependencies = [ | 131 | dependencies = [ |
133 | "proc-macro2", | 132 | "proc-macro2", |
134 | "quote", | 133 | "quote", |
@@ -138,9 +137,9 @@ dependencies = [ | |||
138 | 137 | ||
139 | [[package]] | 138 | [[package]] |
140 | name = "chalk-ir" | 139 | name = "chalk-ir" |
141 | version = "0.18.0" | 140 | version = "0.19.0" |
142 | source = "registry+https://github.com/rust-lang/crates.io-index" | 141 | source = "registry+https://github.com/rust-lang/crates.io-index" |
143 | checksum = "fb617b643e145e3b151502799e91a9625dd5daf1cf05dc2cb821bc75ae0c9cbd" | 142 | checksum = "0a5341fbc654ca886b73b804a36aebf0e621057ccc1a68e9815b5b39b3ac9ae8" |
144 | dependencies = [ | 143 | dependencies = [ |
145 | "chalk-derive", | 144 | "chalk-derive", |
146 | "lazy_static", | 145 | "lazy_static", |
@@ -148,9 +147,9 @@ dependencies = [ | |||
148 | 147 | ||
149 | [[package]] | 148 | [[package]] |
150 | name = "chalk-recursive" | 149 | name = "chalk-recursive" |
151 | version = "0.18.0" | 150 | version = "0.19.0" |
152 | source = "registry+https://github.com/rust-lang/crates.io-index" | 151 | source = "registry+https://github.com/rust-lang/crates.io-index" |
153 | checksum = "d280565c8eefbf9b2bc615df49c7dfd971faad37774bf65734e626fd23864bd6" | 152 | checksum = "4484807b155b5a411e6135d330295f9ba5042e2920b8712c6574ca6ea91e9ee5" |
154 | dependencies = [ | 153 | dependencies = [ |
155 | "chalk-derive", | 154 | "chalk-derive", |
156 | "chalk-ir", | 155 | "chalk-ir", |
@@ -161,9 +160,9 @@ dependencies = [ | |||
161 | 160 | ||
162 | [[package]] | 161 | [[package]] |
163 | name = "chalk-solve" | 162 | name = "chalk-solve" |
164 | version = "0.18.0" | 163 | version = "0.19.0" |
165 | source = "registry+https://github.com/rust-lang/crates.io-index" | 164 | source = "registry+https://github.com/rust-lang/crates.io-index" |
166 | checksum = "be906fbca3f3077dce0e76d9864771d0f450c946af0d86b569fb9504148a065a" | 165 | checksum = "281f82facd2538997fbe52132b1941ed213d266748215c31d15f62a8664429ad" |
167 | dependencies = [ | 166 | dependencies = [ |
168 | "chalk-derive", | 167 | "chalk-derive", |
169 | "chalk-ir", | 168 | "chalk-ir", |
@@ -319,9 +318,9 @@ dependencies = [ | |||
319 | 318 | ||
320 | [[package]] | 319 | [[package]] |
321 | name = "filetime" | 320 | name = "filetime" |
322 | version = "0.2.10" | 321 | version = "0.2.11" |
323 | source = "registry+https://github.com/rust-lang/crates.io-index" | 322 | source = "registry+https://github.com/rust-lang/crates.io-index" |
324 | checksum = "affc17579b132fc2461adf7c575cc6e8b134ebca52c51f5411388965227dc695" | 323 | checksum = "e500da2fab70bdc43f8f0e0b350a227f31c72311c56aba48f01d5cd62bb0345b" |
325 | dependencies = [ | 324 | dependencies = [ |
326 | "cfg-if", | 325 | "cfg-if", |
327 | "libc", | 326 | "libc", |
@@ -401,17 +400,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
401 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" | 400 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" |
402 | 401 | ||
403 | [[package]] | 402 | [[package]] |
404 | name = "getrandom" | ||
405 | version = "0.1.14" | ||
406 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
407 | checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" | ||
408 | dependencies = [ | ||
409 | "cfg-if", | ||
410 | "libc", | ||
411 | "wasi", | ||
412 | ] | ||
413 | |||
414 | [[package]] | ||
415 | name = "gimli" | 403 | name = "gimli" |
416 | version = "0.22.0" | 404 | version = "0.22.0" |
417 | source = "registry+https://github.com/rust-lang/crates.io-index" | 405 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -565,9 +553,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" | |||
565 | 553 | ||
566 | [[package]] | 554 | [[package]] |
567 | name = "libc" | 555 | name = "libc" |
568 | version = "0.2.73" | 556 | version = "0.2.74" |
569 | source = "registry+https://github.com/rust-lang/crates.io-index" | 557 | source = "registry+https://github.com/rust-lang/crates.io-index" |
570 | checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" | 558 | checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" |
571 | 559 | ||
572 | [[package]] | 560 | [[package]] |
573 | name = "libloading" | 561 | name = "libloading" |
@@ -619,9 +607,9 @@ dependencies = [ | |||
619 | 607 | ||
620 | [[package]] | 608 | [[package]] |
621 | name = "lsp-types" | 609 | name = "lsp-types" |
622 | version = "0.78.0" | 610 | version = "0.79.0" |
623 | source = "registry+https://github.com/rust-lang/crates.io-index" | 611 | source = "registry+https://github.com/rust-lang/crates.io-index" |
624 | checksum = "d2e6cf68e3492cfa2035f0382c1da1b6ab045db0320feca505b86b4f13d66c27" | 612 | checksum = "7f1f86677fdbe8df5f88b99131b1424e50aad27bbe3e5900d221bc414bd72e9b" |
625 | dependencies = [ | 613 | dependencies = [ |
626 | "base64", | 614 | "base64", |
627 | "bitflags", | 615 | "bitflags", |
@@ -811,6 +799,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
811 | checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" | 799 | checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" |
812 | 800 | ||
813 | [[package]] | 801 | [[package]] |
802 | name = "oorandom" | ||
803 | version = "11.1.2" | ||
804 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
805 | checksum = "a170cebd8021a008ea92e4db85a72f80b35df514ec664b296fdcbb654eac0b2c" | ||
806 | |||
807 | [[package]] | ||
814 | name = "parking_lot" | 808 | name = "parking_lot" |
815 | version = "0.11.0" | 809 | version = "0.11.0" |
816 | source = "registry+https://github.com/rust-lang/crates.io-index" | 810 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -847,6 +841,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
847 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" | 841 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" |
848 | 842 | ||
849 | [[package]] | 843 | [[package]] |
844 | name = "perf-event" | ||
845 | version = "0.4.4" | ||
846 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
847 | checksum = "76c42ba5d85a2f4472b99f475fb60cf336d9b4c85b1ea8bb300fef2e3c7c8f89" | ||
848 | dependencies = [ | ||
849 | "libc", | ||
850 | "perf-event-open-sys", | ||
851 | ] | ||
852 | |||
853 | [[package]] | ||
854 | name = "perf-event-open-sys" | ||
855 | version = "0.3.1" | ||
856 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
857 | checksum = "95db63e37862bc1b842135d2234ef9418f222cc660c6752f45e7cf9ddfb97f96" | ||
858 | dependencies = [ | ||
859 | "libc", | ||
860 | ] | ||
861 | |||
862 | [[package]] | ||
850 | name = "petgraph" | 863 | name = "petgraph" |
851 | version = "0.5.1" | 864 | version = "0.5.1" |
852 | source = "registry+https://github.com/rust-lang/crates.io-index" | 865 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -869,12 +882,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
869 | checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" | 882 | checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" |
870 | 883 | ||
871 | [[package]] | 884 | [[package]] |
872 | name = "ppv-lite86" | ||
873 | version = "0.2.8" | ||
874 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
875 | checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" | ||
876 | |||
877 | [[package]] | ||
878 | name = "proc-macro2" | 885 | name = "proc-macro2" |
879 | version = "1.0.19" | 886 | version = "1.0.19" |
880 | source = "registry+https://github.com/rust-lang/crates.io-index" | 887 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1046,6 +1053,7 @@ dependencies = [ | |||
1046 | "indexmap", | 1053 | "indexmap", |
1047 | "itertools", | 1054 | "itertools", |
1048 | "log", | 1055 | "log", |
1056 | "oorandom", | ||
1049 | "ra_assists", | 1057 | "ra_assists", |
1050 | "ra_cfg", | 1058 | "ra_cfg", |
1051 | "ra_db", | 1059 | "ra_db", |
@@ -1056,7 +1064,6 @@ dependencies = [ | |||
1056 | "ra_ssr", | 1064 | "ra_ssr", |
1057 | "ra_syntax", | 1065 | "ra_syntax", |
1058 | "ra_text_edit", | 1066 | "ra_text_edit", |
1059 | "rand", | ||
1060 | "rustc-hash", | 1067 | "rustc-hash", |
1061 | "stdx", | 1068 | "stdx", |
1062 | "test_utils", | 1069 | "test_utils", |
@@ -1138,6 +1145,7 @@ dependencies = [ | |||
1138 | "cfg-if", | 1145 | "cfg-if", |
1139 | "libc", | 1146 | "libc", |
1140 | "once_cell", | 1147 | "once_cell", |
1148 | "perf-event", | ||
1141 | "ra_arena", | 1149 | "ra_arena", |
1142 | ] | 1150 | ] |
1143 | 1151 | ||
@@ -1164,6 +1172,7 @@ dependencies = [ | |||
1164 | name = "ra_ssr" | 1172 | name = "ra_ssr" |
1165 | version = "0.1.0" | 1173 | version = "0.1.0" |
1166 | dependencies = [ | 1174 | dependencies = [ |
1175 | "expect", | ||
1167 | "ra_db", | 1176 | "ra_db", |
1168 | "ra_hir", | 1177 | "ra_hir", |
1169 | "ra_ide_db", | 1178 | "ra_ide_db", |
@@ -1217,57 +1226,6 @@ dependencies = [ | |||
1217 | ] | 1226 | ] |
1218 | 1227 | ||
1219 | [[package]] | 1228 | [[package]] |
1220 | name = "rand" | ||
1221 | version = "0.7.3" | ||
1222 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1223 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" | ||
1224 | dependencies = [ | ||
1225 | "getrandom", | ||
1226 | "libc", | ||
1227 | "rand_chacha", | ||
1228 | "rand_core", | ||
1229 | "rand_hc", | ||
1230 | "rand_pcg", | ||
1231 | ] | ||
1232 | |||
1233 | [[package]] | ||
1234 | name = "rand_chacha" | ||
1235 | version = "0.2.2" | ||
1236 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1237 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" | ||
1238 | dependencies = [ | ||
1239 | "ppv-lite86", | ||
1240 | "rand_core", | ||
1241 | ] | ||
1242 | |||
1243 | [[package]] | ||
1244 | name = "rand_core" | ||
1245 | version = "0.5.1" | ||
1246 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1247 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" | ||
1248 | dependencies = [ | ||
1249 | "getrandom", | ||
1250 | ] | ||
1251 | |||
1252 | [[package]] | ||
1253 | name = "rand_hc" | ||
1254 | version = "0.2.0" | ||
1255 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1256 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" | ||
1257 | dependencies = [ | ||
1258 | "rand_core", | ||
1259 | ] | ||
1260 | |||
1261 | [[package]] | ||
1262 | name = "rand_pcg" | ||
1263 | version = "0.2.1" | ||
1264 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1265 | checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" | ||
1266 | dependencies = [ | ||
1267 | "rand_core", | ||
1268 | ] | ||
1269 | |||
1270 | [[package]] | ||
1271 | name = "rayon" | 1229 | name = "rayon" |
1272 | version = "1.3.1" | 1230 | version = "1.3.1" |
1273 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1231 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1353,6 +1311,7 @@ dependencies = [ | |||
1353 | "lsp-server", | 1311 | "lsp-server", |
1354 | "lsp-types", | 1312 | "lsp-types", |
1355 | "mimalloc", | 1313 | "mimalloc", |
1314 | "oorandom", | ||
1356 | "parking_lot", | 1315 | "parking_lot", |
1357 | "pico-args", | 1316 | "pico-args", |
1358 | "ra_cfg", | 1317 | "ra_cfg", |
@@ -1371,7 +1330,6 @@ dependencies = [ | |||
1371 | "ra_text_edit", | 1330 | "ra_text_edit", |
1372 | "ra_toolchain", | 1331 | "ra_toolchain", |
1373 | "ra_tt", | 1332 | "ra_tt", |
1374 | "rand", | ||
1375 | "rayon", | 1333 | "rayon", |
1376 | "rustc-hash", | 1334 | "rustc-hash", |
1377 | "serde", | 1335 | "serde", |
@@ -1386,9 +1344,9 @@ dependencies = [ | |||
1386 | 1344 | ||
1387 | [[package]] | 1345 | [[package]] |
1388 | name = "rustc-ap-rustc_lexer" | 1346 | name = "rustc-ap-rustc_lexer" |
1389 | version = "669.0.0" | 1347 | version = "671.0.0" |
1390 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1348 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1391 | checksum = "456af5f09c006cf6c22c1a433ee0232c4bb74bdc6c647a010166a47c94ed2a63" | 1349 | checksum = "22e1221f3bfa2943c942cf8da319ab2346887f8757778c29c7f1822cd27b521f" |
1392 | dependencies = [ | 1350 | dependencies = [ |
1393 | "unicode-xid", | 1351 | "unicode-xid", |
1394 | ] | 1352 | ] |
@@ -1413,16 +1371,16 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" | |||
1413 | 1371 | ||
1414 | [[package]] | 1372 | [[package]] |
1415 | name = "salsa" | 1373 | name = "salsa" |
1416 | version = "0.15.0" | 1374 | version = "0.15.1" |
1417 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1375 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1418 | checksum = "885b4b99dde959decc84e85dd943bd140b4aabd62db2f8206ef5270f77ec20b9" | 1376 | checksum = "d4cdc109fcc9e9450c7ef47fb7474e99bffd51799da03ed0a6c7f0e2cb3848a6" |
1419 | dependencies = [ | 1377 | dependencies = [ |
1420 | "crossbeam-utils", | 1378 | "crossbeam-utils", |
1421 | "indexmap", | 1379 | "indexmap", |
1422 | "lock_api", | 1380 | "lock_api", |
1423 | "log", | 1381 | "log", |
1382 | "oorandom", | ||
1424 | "parking_lot", | 1383 | "parking_lot", |
1425 | "rand", | ||
1426 | "rustc-hash", | 1384 | "rustc-hash", |
1427 | "salsa-macros", | 1385 | "salsa-macros", |
1428 | "smallvec", | 1386 | "smallvec", |
@@ -1519,9 +1477,9 @@ dependencies = [ | |||
1519 | 1477 | ||
1520 | [[package]] | 1478 | [[package]] |
1521 | name = "serde_json" | 1479 | name = "serde_json" |
1522 | version = "1.0.56" | 1480 | version = "1.0.57" |
1523 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1481 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1524 | checksum = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" | 1482 | checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" |
1525 | dependencies = [ | 1483 | dependencies = [ |
1526 | "itoa", | 1484 | "itoa", |
1527 | "ryu", | 1485 | "ryu", |
@@ -1575,9 +1533,9 @@ version = "0.1.0" | |||
1575 | 1533 | ||
1576 | [[package]] | 1534 | [[package]] |
1577 | name = "syn" | 1535 | name = "syn" |
1578 | version = "1.0.35" | 1536 | version = "1.0.36" |
1579 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1537 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1580 | checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0" | 1538 | checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250" |
1581 | dependencies = [ | 1539 | dependencies = [ |
1582 | "proc-macro2", | 1540 | "proc-macro2", |
1583 | "quote", | 1541 | "quote", |
@@ -1716,9 +1674,9 @@ dependencies = [ | |||
1716 | 1674 | ||
1717 | [[package]] | 1675 | [[package]] |
1718 | name = "tracing-subscriber" | 1676 | name = "tracing-subscriber" |
1719 | version = "0.2.8" | 1677 | version = "0.2.9" |
1720 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1678 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1721 | checksum = "cafe899b943f5433c6cab468d75a17ea92948fe9fe60b00f41e13d5e0d4fd054" | 1679 | checksum = "e4f5dd7095c2481b7b3cbed71c8de53085fb3542bc3c2b4c73cba43e8f11c7ba" |
1722 | dependencies = [ | 1680 | dependencies = [ |
1723 | "ansi_term", | 1681 | "ansi_term", |
1724 | "chrono", | 1682 | "chrono", |
@@ -1749,6 +1707,12 @@ dependencies = [ | |||
1749 | ] | 1707 | ] |
1750 | 1708 | ||
1751 | [[package]] | 1709 | [[package]] |
1710 | name = "ungrammar" | ||
1711 | version = "0.1.0" | ||
1712 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1713 | checksum = "0ee12e4891ab3acc2d95d5023022ace22020247bb8a8d1ece875a443f7dab37d" | ||
1714 | |||
1715 | [[package]] | ||
1752 | name = "unicode-bidi" | 1716 | name = "unicode-bidi" |
1753 | version = "0.3.4" | 1717 | version = "0.3.4" |
1754 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1718 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1825,12 +1789,6 @@ dependencies = [ | |||
1825 | ] | 1789 | ] |
1826 | 1790 | ||
1827 | [[package]] | 1791 | [[package]] |
1828 | name = "wasi" | ||
1829 | version = "0.9.0+wasi-snapshot-preview1" | ||
1830 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
1831 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" | ||
1832 | |||
1833 | [[package]] | ||
1834 | name = "winapi" | 1792 | name = "winapi" |
1835 | version = "0.2.8" | 1793 | version = "0.2.8" |
1836 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1794 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -1892,5 +1850,6 @@ dependencies = [ | |||
1892 | "pico-args", | 1850 | "pico-args", |
1893 | "proc-macro2", | 1851 | "proc-macro2", |
1894 | "quote", | 1852 | "quote", |
1853 | "ungrammar", | ||
1895 | "walkdir", | 1854 | "walkdir", |
1896 | ] | 1855 | ] |
@@ -2,11 +2,8 @@ | |||
2 | <img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo"> | 2 | <img src="https://user-images.githubusercontent.com/1711539/72443316-5a79f280-37ae-11ea-858f-035209ece2dd.png" alt="rust-analyzer logo"> |
3 | </p> | 3 | </p> |
4 | 4 | ||
5 | rust-analyzer is an **experimental** modular compiler frontend for the Rust | 5 | rust-analyzer is an **experimental** modular compiler frontend for the Rust language. |
6 | language. It is a part of a larger rls-2.0 effort to create excellent IDE | 6 | It is a part of a larger rls-2.0 effort to create excellent IDE support for Rust. |
7 | support for Rust. If you want to get involved, check the rls-2.0 working group: | ||
8 | |||
9 | https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 | ||
10 | 7 | ||
11 | Work on rust-analyzer is sponsored by | 8 | Work on rust-analyzer is sponsored by |
12 | 9 | ||
@@ -25,8 +22,8 @@ If you want to **contribute** to rust-analyzer or are just curious about how | |||
25 | things work under the hood, check the [./docs/dev](./docs/dev) folder. | 22 | things work under the hood, check the [./docs/dev](./docs/dev) folder. |
26 | 23 | ||
27 | If you want to **use** rust-analyzer's language server with your editor of | 24 | If you want to **use** rust-analyzer's language server with your editor of |
28 | choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder. It also contains some tips & tricks to help | 25 | choice, check [the manual](https://rust-analyzer.github.io/manual.html) folder. |
29 | you be more productive when using rust-analyzer. | 26 | It also contains some tips & tricks to help you be more productive when using rust-analyzer. |
30 | 27 | ||
31 | ## Communication | 28 | ## Communication |
32 | 29 | ||
@@ -40,8 +37,9 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frls-2.2E0 | |||
40 | 37 | ||
41 | ## Quick Links | 38 | ## Quick Links |
42 | 39 | ||
43 | * API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ | ||
44 | * Website: https://rust-analyzer.github.io/ | 40 | * Website: https://rust-analyzer.github.io/ |
41 | * Metrics: https://rust-analyzer.github.io/metrics/ | ||
42 | * API docs: https://rust-analyzer.github.io/rust-analyzer/ra_ide/ | ||
45 | 43 | ||
46 | ## License | 44 | ## License |
47 | 45 | ||
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index bea485694..ff8a1e568 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml | |||
@@ -11,7 +11,7 @@ doctest = false | |||
11 | [dependencies] | 11 | [dependencies] |
12 | crossbeam-channel = "0.4.0" | 12 | crossbeam-channel = "0.4.0" |
13 | log = "0.4.8" | 13 | log = "0.4.8" |
14 | cargo_metadata = "0.10.0" | 14 | cargo_metadata = "0.11.1" |
15 | serde_json = "1.0.48" | 15 | serde_json = "1.0.48" |
16 | jod-thread = "0.1.1" | 16 | jod-thread = "0.1.1" |
17 | ra_toolchain = { path = "../ra_toolchain" } | 17 | ra_toolchain = { path = "../ra_toolchain" } |
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index ad376ad18..7c38f5ef9 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs | |||
@@ -24,6 +24,7 @@ pub enum FlycheckConfig { | |||
24 | command: String, | 24 | command: String, |
25 | target_triple: Option<String>, | 25 | target_triple: Option<String>, |
26 | all_targets: bool, | 26 | all_targets: bool, |
27 | no_default_features: bool, | ||
27 | all_features: bool, | 28 | all_features: bool, |
28 | features: Vec<String>, | 29 | features: Vec<String>, |
29 | extra_args: Vec<String>, | 30 | extra_args: Vec<String>, |
@@ -180,6 +181,7 @@ impl FlycheckActor { | |||
180 | FlycheckConfig::CargoCommand { | 181 | FlycheckConfig::CargoCommand { |
181 | command, | 182 | command, |
182 | target_triple, | 183 | target_triple, |
184 | no_default_features, | ||
183 | all_targets, | 185 | all_targets, |
184 | all_features, | 186 | all_features, |
185 | extra_args, | 187 | extra_args, |
@@ -198,9 +200,14 @@ impl FlycheckActor { | |||
198 | } | 200 | } |
199 | if *all_features { | 201 | if *all_features { |
200 | cmd.arg("--all-features"); | 202 | cmd.arg("--all-features"); |
201 | } else if !features.is_empty() { | 203 | } else { |
202 | cmd.arg("--features"); | 204 | if *no_default_features { |
203 | cmd.arg(features.join(" ")); | 205 | cmd.arg("--no-default-features"); |
206 | } | ||
207 | if !features.is_empty() { | ||
208 | cmd.arg("--features"); | ||
209 | cmd.arg(features.join(" ")); | ||
210 | } | ||
204 | } | 211 | } |
205 | cmd.args(extra_args); | 212 | cmd.args(extra_args); |
206 | cmd | 213 | cmd |
diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 01adb834c..3265bd406 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs | |||
@@ -32,7 +32,7 @@ impl<'a> AstTransform<'a> for NullTransformer { | |||
32 | 32 | ||
33 | pub struct SubstituteTypeParams<'a> { | 33 | pub struct SubstituteTypeParams<'a> { |
34 | source_scope: &'a SemanticsScope<'a>, | 34 | source_scope: &'a SemanticsScope<'a>, |
35 | substs: FxHashMap<hir::TypeParam, ast::TypeRef>, | 35 | substs: FxHashMap<hir::TypeParam, ast::Type>, |
36 | previous: Box<dyn AstTransform<'a> + 'a>, | 36 | previous: Box<dyn AstTransform<'a> + 'a>, |
37 | } | 37 | } |
38 | 38 | ||
@@ -41,7 +41,7 @@ impl<'a> SubstituteTypeParams<'a> { | |||
41 | source_scope: &'a SemanticsScope<'a>, | 41 | source_scope: &'a SemanticsScope<'a>, |
42 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... | 42 | // FIXME: there's implicit invariant that `trait_` and `source_scope` match... |
43 | trait_: hir::Trait, | 43 | trait_: hir::Trait, |
44 | impl_def: ast::ImplDef, | 44 | impl_def: ast::Impl, |
45 | ) -> SubstituteTypeParams<'a> { | 45 | ) -> SubstituteTypeParams<'a> { |
46 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); | 46 | let substs = get_syntactic_substs(impl_def).unwrap_or_default(); |
47 | let generic_def: hir::GenericDef = trait_.into(); | 47 | let generic_def: hir::GenericDef = trait_.into(); |
@@ -80,17 +80,17 @@ impl<'a> SubstituteTypeParams<'a> { | |||
80 | 80 | ||
81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the | 81 | // FIXME: It would probably be nicer if we could get this via HIR (i.e. get the |
82 | // trait ref, and then go from the types in the substs back to the syntax) | 82 | // trait ref, and then go from the types in the substs back to the syntax) |
83 | fn get_syntactic_substs(impl_def: ast::ImplDef) -> Option<Vec<ast::TypeRef>> { | 83 | fn get_syntactic_substs(impl_def: ast::Impl) -> Option<Vec<ast::Type>> { |
84 | let target_trait = impl_def.target_trait()?; | 84 | let target_trait = impl_def.target_trait()?; |
85 | let path_type = match target_trait { | 85 | let path_type = match target_trait { |
86 | ast::TypeRef::PathType(path) => path, | 86 | ast::Type::PathType(path) => path, |
87 | _ => return None, | 87 | _ => return None, |
88 | }; | 88 | }; |
89 | let type_arg_list = path_type.path()?.segment()?.type_arg_list()?; | 89 | let type_arg_list = path_type.path()?.segment()?.type_arg_list()?; |
90 | let mut result = Vec::new(); | 90 | let mut result = Vec::new(); |
91 | for type_arg in type_arg_list.type_args() { | 91 | for type_arg in type_arg_list.type_args() { |
92 | let type_arg: ast::TypeArg = type_arg; | 92 | let type_arg: ast::TypeArg = type_arg; |
93 | result.push(type_arg.type_ref()?); | 93 | result.push(type_arg.ty()?); |
94 | } | 94 | } |
95 | Some(result) | 95 | Some(result) |
96 | } | 96 | } |
@@ -99,9 +99,9 @@ impl<'a> SubstituteTypeParams<'a> { | |||
99 | &self, | 99 | &self, |
100 | node: &ra_syntax::SyntaxNode, | 100 | node: &ra_syntax::SyntaxNode, |
101 | ) -> Option<ra_syntax::SyntaxNode> { | 101 | ) -> Option<ra_syntax::SyntaxNode> { |
102 | let type_ref = ast::TypeRef::cast(node.clone())?; | 102 | let type_ref = ast::Type::cast(node.clone())?; |
103 | let path = match &type_ref { | 103 | let path = match &type_ref { |
104 | ast::TypeRef::PathType(path_type) => path_type.path()?, | 104 | ast::Type::PathType(path_type) => path_type.path()?, |
105 | _ => return None, | 105 | _ => return None, |
106 | }; | 106 | }; |
107 | // FIXME: use `hir::Path::from_src` instead. | 107 | // FIXME: use `hir::Path::from_src` instead. |
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index acb07e36a..b67438b6b 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -29,8 +29,8 @@ use crate::{ | |||
29 | // } | 29 | // } |
30 | // ``` | 30 | // ``` |
31 | pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 31 | pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
32 | let input = ctx.find_node_at_offset::<ast::AttrInput>()?; | 32 | let attr = ctx.find_node_at_offset::<ast::Attr>()?; |
33 | let attr = input.syntax().parent().and_then(ast::Attr::cast)?; | 33 | let input = attr.token_tree()?; |
34 | 34 | ||
35 | let attr_name = attr | 35 | let attr_name = attr |
36 | .syntax() | 36 | .syntax() |
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 39a5321d1..e69f0a89b 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use hir::HirDisplay; | 1 | use hir::HirDisplay; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, | 3 | ast::{self, AstNode, LetStmt, NameOwner}, |
4 | TextRange, | 4 | TextRange, |
5 | }; | 5 | }; |
6 | 6 | ||
@@ -22,11 +22,11 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
22 | // } | 22 | // } |
23 | // ``` | 23 | // ``` |
24 | pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 24 | pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
25 | let stmt = ctx.find_node_at_offset::<LetStmt>()?; | 25 | let let_stmt = ctx.find_node_at_offset::<LetStmt>()?; |
26 | let module = ctx.sema.scope(stmt.syntax()).module()?; | 26 | let module = ctx.sema.scope(let_stmt.syntax()).module()?; |
27 | let expr = stmt.initializer()?; | 27 | let expr = let_stmt.initializer()?; |
28 | // Must be a binding | 28 | // Must be a binding |
29 | let pat = match stmt.pat()? { | 29 | let pat = match let_stmt.pat()? { |
30 | ast::Pat::BindPat(bind_pat) => bind_pat, | 30 | ast::Pat::BindPat(bind_pat) => bind_pat, |
31 | _ => return None, | 31 | _ => return None, |
32 | }; | 32 | }; |
@@ -34,8 +34,8 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
34 | // The binding must have a name | 34 | // The binding must have a name |
35 | let name = pat.name()?; | 35 | let name = pat.name()?; |
36 | let name_range = name.syntax().text_range(); | 36 | let name_range = name.syntax().text_range(); |
37 | let stmt_range = stmt.syntax().text_range(); | 37 | let stmt_range = let_stmt.syntax().text_range(); |
38 | let eq_range = stmt.eq_token()?.text_range(); | 38 | let eq_range = let_stmt.eq_token()?.text_range(); |
39 | // Assist should only be applicable if cursor is between 'let' and '=' | 39 | // Assist should only be applicable if cursor is between 'let' and '=' |
40 | let let_range = TextRange::new(stmt_range.start(), eq_range.start()); | 40 | let let_range = TextRange::new(stmt_range.start(), eq_range.start()); |
41 | let cursor_in_range = let_range.contains_range(ctx.frange.range); | 41 | let cursor_in_range = let_range.contains_range(ctx.frange.range); |
@@ -44,7 +44,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
44 | } | 44 | } |
45 | // Assist not applicable if the type has already been specified | 45 | // Assist not applicable if the type has already been specified |
46 | // and it has no placeholders | 46 | // and it has no placeholders |
47 | let ascribed_ty = stmt.ascribed_type(); | 47 | let ascribed_ty = let_stmt.ty(); |
48 | if let Some(ty) = &ascribed_ty { | 48 | if let Some(ty) = &ascribed_ty { |
49 | if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() { | 49 | if ty.syntax().descendants().find_map(ast::PlaceholderType::cast).is_none() { |
50 | return None; | 50 | return None; |
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index f185e61e5..95a750aee 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -111,16 +111,17 @@ fn add_missing_impl_members_inner( | |||
111 | label: &'static str, | 111 | label: &'static str, |
112 | ) -> Option<()> { | 112 | ) -> Option<()> { |
113 | let _p = ra_prof::profile("add_missing_impl_members_inner"); | 113 | let _p = ra_prof::profile("add_missing_impl_members_inner"); |
114 | let impl_def = ctx.find_node_at_offset::<ast::ImplDef>()?; | 114 | let impl_def = ctx.find_node_at_offset::<ast::Impl>()?; |
115 | let impl_item_list = impl_def.item_list()?; | 115 | let impl_item_list = impl_def.assoc_item_list()?; |
116 | 116 | ||
117 | let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; | 117 | let trait_ = resolve_target_trait(&ctx.sema, &impl_def)?; |
118 | 118 | ||
119 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { | 119 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { |
120 | match item { | 120 | match item { |
121 | ast::AssocItem::FnDef(def) => def.name(), | 121 | ast::AssocItem::Fn(def) => def.name(), |
122 | ast::AssocItem::TypeAliasDef(def) => def.name(), | 122 | ast::AssocItem::TypeAlias(def) => def.name(), |
123 | ast::AssocItem::ConstDef(def) => def.name(), | 123 | ast::AssocItem::Const(def) => def.name(), |
124 | ast::AssocItem::MacroCall(_) => None, | ||
124 | } | 125 | } |
125 | .map(|it| it.text().clone()) | 126 | .map(|it| it.text().clone()) |
126 | }; | 127 | }; |
@@ -128,13 +129,13 @@ fn add_missing_impl_members_inner( | |||
128 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) | 129 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) |
129 | .iter() | 130 | .iter() |
130 | .map(|i| match i { | 131 | .map(|i| match i { |
131 | hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), | 132 | hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), |
132 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), | 133 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value), |
133 | hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), | 134 | hir::AssocItem::Const(i) => ast::AssocItem::Const(i.source(ctx.db()).value), |
134 | }) | 135 | }) |
135 | .filter(|t| def_name(&t).is_some()) | 136 | .filter(|t| def_name(&t).is_some()) |
136 | .filter(|t| match t { | 137 | .filter(|t| match t { |
137 | ast::AssocItem::FnDef(def) => match mode { | 138 | ast::AssocItem::Fn(def) => match mode { |
138 | AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), | 139 | AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), |
139 | AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), | 140 | AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), |
140 | }, | 141 | }, |
@@ -157,10 +158,8 @@ fn add_missing_impl_members_inner( | |||
157 | .into_iter() | 158 | .into_iter() |
158 | .map(|it| ast_transform::apply(&*ast_transform, it)) | 159 | .map(|it| ast_transform::apply(&*ast_transform, it)) |
159 | .map(|it| match it { | 160 | .map(|it| match it { |
160 | ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), | 161 | ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), |
161 | ast::AssocItem::TypeAliasDef(def) => { | 162 | ast::AssocItem::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()), |
162 | ast::AssocItem::TypeAliasDef(def.remove_bounds()) | ||
163 | } | ||
164 | _ => it, | 163 | _ => it, |
165 | }) | 164 | }) |
166 | .map(|it| edit::remove_attrs_and_docs(&it)); | 165 | .map(|it| edit::remove_attrs_and_docs(&it)); |
@@ -173,7 +172,7 @@ fn add_missing_impl_members_inner( | |||
173 | Some(cap) => { | 172 | Some(cap) => { |
174 | let mut cursor = Cursor::Before(first_new_item.syntax()); | 173 | let mut cursor = Cursor::Before(first_new_item.syntax()); |
175 | let placeholder; | 174 | let placeholder; |
176 | if let ast::AssocItem::FnDef(func) = &first_new_item { | 175 | if let ast::AssocItem::Fn(func) = &first_new_item { |
177 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { | 176 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { |
178 | if m.syntax().text() == "todo!()" { | 177 | if m.syntax().text() == "todo!()" { |
179 | placeholder = m; | 178 | placeholder = m; |
@@ -191,7 +190,7 @@ fn add_missing_impl_members_inner( | |||
191 | }) | 190 | }) |
192 | } | 191 | } |
193 | 192 | ||
194 | fn add_body(fn_def: ast::FnDef) -> ast::FnDef { | 193 | fn add_body(fn_def: ast::Fn) -> ast::Fn { |
195 | if fn_def.body().is_some() { | 194 | if fn_def.body().is_some() { |
196 | return fn_def; | 195 | return fn_def; |
197 | } | 196 | } |
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 947be3b9b..01e7b7a44 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs | |||
@@ -92,7 +92,7 @@ impl AutoImportAssets { | |||
92 | 92 | ||
93 | fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> { | 93 | fn for_regular_path(path_under_caret: ast::Path, ctx: &AssistContext) -> Option<Self> { |
94 | let syntax_under_caret = path_under_caret.syntax().to_owned(); | 94 | let syntax_under_caret = path_under_caret.syntax().to_owned(); |
95 | if syntax_under_caret.ancestors().find_map(ast::UseItem::cast).is_some() { | 95 | if syntax_under_caret.ancestors().find_map(ast::Use::cast).is_some() { |
96 | return None; | 96 | return None; |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index def00f7d8..167e162d8 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs | |||
@@ -20,9 +20,9 @@ use test_utils::mark; | |||
20 | pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 20 | pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
21 | let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; | 21 | let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; |
22 | // FIXME: extend to lambdas as well | 22 | // FIXME: extend to lambdas as well |
23 | let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?; | 23 | let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?; |
24 | 24 | ||
25 | let type_ref = &ret_type.type_ref()?; | 25 | let type_ref = &ret_type.ty()?; |
26 | let ret_type_str = type_ref.syntax().text().to_string(); | 26 | let ret_type_str = type_ref.syntax().text().to_string(); |
27 | let first_part_ret_type = ret_type_str.splitn(2, '<').next(); | 27 | let first_part_ret_type = ret_type_str.splitn(2, '<').next(); |
28 | if let Some(ret_type_first_part) = first_part_ret_type { | 28 | if let Some(ret_type_first_part) = first_part_ret_type { |
@@ -240,7 +240,7 @@ fn get_tail_expr_from_block(expr: &Expr) -> Option<Vec<NodeType>> { | |||
240 | Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 240 | Expr::ParenExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
241 | Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 241 | Expr::PathExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
242 | Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 242 | Expr::Label(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
243 | Expr::RecordLit(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 243 | Expr::RecordExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
244 | Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 244 | Expr::IndexExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
245 | Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 245 | Expr::MethodCallExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
246 | Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), | 246 | Expr::AwaitExpr(expr) => Some(vec![NodeType::Leaf(expr.syntax().clone())]), |
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 4343b423c..724daa93f 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs | |||
@@ -1,9 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, NameOwner, VisibilityOwner}, | 2 | ast::{self, NameOwner, VisibilityOwner}, |
3 | AstNode, | 3 | AstNode, |
4 | SyntaxKind::{ | 4 | SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY}, |
5 | CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, | ||
6 | }, | ||
7 | T, | 5 | T, |
8 | }; | 6 | }; |
9 | use test_utils::mark; | 7 | use test_utils::mark; |
@@ -38,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
38 | 36 | ||
39 | let (offset, target) = if let Some(keyword) = item_keyword { | 37 | let (offset, target) = if let Some(keyword) = item_keyword { |
40 | let parent = keyword.parent(); | 38 | let parent = keyword.parent(); |
41 | let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; | 39 | let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT]; |
42 | // Parent is not a definition, can't add visibility | 40 | // Parent is not a definition, can't add visibility |
43 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { | 41 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { |
44 | return None; | 42 | return None; |
@@ -49,7 +47,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
49 | } | 47 | } |
50 | (vis_offset(&parent), keyword.text_range()) | 48 | (vis_offset(&parent), keyword.text_range()) |
51 | } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { | 49 | } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { |
52 | let field = field_name.syntax().ancestors().find_map(ast::RecordFieldDef::cast)?; | 50 | let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?; |
53 | if field.name()? != field_name { | 51 | if field.name()? != field_name { |
54 | mark::hit!(change_visibility_field_false_positive); | 52 | mark::hit!(change_visibility_field_false_positive); |
55 | return None; | 53 | return None; |
@@ -58,7 +56,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
58 | return None; | 56 | return None; |
59 | } | 57 | } |
60 | (vis_offset(field.syntax()), field_name.syntax().text_range()) | 58 | (vis_offset(field.syntax()), field_name.syntax().text_range()) |
61 | } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleFieldDef>() { | 59 | } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleField>() { |
62 | if field.visibility().is_some() { | 60 | if field.visibility().is_some() { |
63 | return None; | 61 | return None; |
64 | } | 62 | } |
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 330459f3c..3650289fd 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::{ | |||
8 | make, | 8 | make, |
9 | }, | 9 | }, |
10 | AstNode, | 10 | AstNode, |
11 | SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, | 11 | SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, |
12 | SyntaxNode, | 12 | SyntaxNode, |
13 | }; | 13 | }; |
14 | 14 | ||
@@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) | |||
88 | 88 | ||
89 | let early_expression: ast::Expr = match parent_container.kind() { | 89 | let early_expression: ast::Expr = match parent_container.kind() { |
90 | WHILE_EXPR | LOOP_EXPR => make::expr_continue(), | 90 | WHILE_EXPR | LOOP_EXPR => make::expr_continue(), |
91 | FN_DEF => make::expr_return(), | 91 | FN => make::expr_return(), |
92 | _ => return None, | 92 | _ => return None, |
93 | }; | 93 | }; |
94 | 94 | ||
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index 2b8e273b3..ccec688ca 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -31,7 +31,7 @@ pub(crate) fn extract_struct_from_enum_variant( | |||
31 | acc: &mut Assists, | 31 | acc: &mut Assists, |
32 | ctx: &AssistContext, | 32 | ctx: &AssistContext, |
33 | ) -> Option<()> { | 33 | ) -> Option<()> { |
34 | let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; | 34 | let variant = ctx.find_node_at_offset::<ast::Variant>()?; |
35 | let field_list = match variant.kind() { | 35 | let field_list = match variant.kind() { |
36 | ast::StructKind::Tuple(field_list) => field_list, | 36 | ast::StructKind::Tuple(field_list) => field_list, |
37 | _ => return None, | 37 | _ => return None, |
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs index 098adf078..b925a2884 100644 --- a/crates/ra_assists/src/handlers/extract_variable.rs +++ b/crates/ra_assists/src/handlers/extract_variable.rs | |||
@@ -45,7 +45,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
45 | target, | 45 | target, |
46 | move |edit| { | 46 | move |edit| { |
47 | let field_shorthand = | 47 | let field_shorthand = |
48 | match to_extract.syntax().parent().and_then(ast::RecordField::cast) { | 48 | match to_extract.syntax().parent().and_then(ast::RecordExprField::cast) { |
49 | Some(field) => field.name_ref(), | 49 | Some(field) => field.name_ref(), |
50 | None => None, | 50 | None => None, |
51 | }; | 51 | }; |
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 1d3ed3c6a..1aefa79cc 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -82,7 +82,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O | |||
82 | } | 82 | } |
83 | 83 | ||
84 | fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 84 | fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
85 | let record_field: ast::RecordField = ctx.find_node_at_offset()?; | 85 | let record_field: ast::RecordExprField = ctx.find_node_at_offset()?; |
86 | let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; | 86 | let (record_field_def, _) = ctx.sema.resolve_record_field(&record_field)?; |
87 | 87 | ||
88 | let current_module = ctx.sema.scope(record_field.syntax()).module()?; | 88 | let current_module = ctx.sema.scope(record_field.syntax()).module()?; |
diff --git a/crates/ra_assists/src/handlers/generate_derive.rs b/crates/ra_assists/src/handlers/generate_derive.rs index 6ccf39900..90ece9fab 100644 --- a/crates/ra_assists/src/handlers/generate_derive.rs +++ b/crates/ra_assists/src/handlers/generate_derive.rs | |||
@@ -26,7 +26,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
26 | // ``` | 26 | // ``` |
27 | pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 27 | pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
28 | let cap = ctx.config.snippet_cap?; | 28 | let cap = ctx.config.snippet_cap?; |
29 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; | 29 | let nominal = ctx.find_node_at_offset::<ast::AdtDef>()?; |
30 | let node_start = derive_insertion_offset(&nominal)?; | 30 | let node_start = derive_insertion_offset(&nominal)?; |
31 | let target = nominal.syntax().text_range(); | 31 | let target = nominal.syntax().text_range(); |
32 | acc.add( | 32 | acc.add( |
@@ -58,7 +58,7 @@ pub(crate) fn generate_derive(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
58 | } | 58 | } |
59 | 59 | ||
60 | // Insert `derive` after doc comments. | 60 | // Insert `derive` after doc comments. |
61 | fn derive_insertion_offset(nominal: &ast::NominalDef) -> Option<TextSize> { | 61 | fn derive_insertion_offset(nominal: &ast::AdtDef) -> Option<TextSize> { |
62 | let non_ws_child = nominal | 62 | let non_ws_child = nominal |
63 | .syntax() | 63 | .syntax() |
64 | .children_with_tokens() | 64 | .children_with_tokens() |
diff --git a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs index a347e3c2e..4c1aef8a2 100644 --- a/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/generate_from_impl_for_enum.rs | |||
@@ -22,7 +22,7 @@ use crate::{utils::FamousDefs, AssistContext, AssistId, AssistKind, Assists}; | |||
22 | // } | 22 | // } |
23 | // ``` | 23 | // ``` |
24 | pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 24 | pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
25 | let variant = ctx.find_node_at_offset::<ast::EnumVariant>()?; | 25 | let variant = ctx.find_node_at_offset::<ast::Variant>()?; |
26 | let variant_name = variant.name()?; | 26 | let variant_name = variant.name()?; |
27 | let enum_name = variant.parent_enum().name()?; | 27 | let enum_name = variant.parent_enum().name()?; |
28 | let field_list = match variant.kind() { | 28 | let field_list = match variant.kind() { |
@@ -32,9 +32,9 @@ pub(crate) fn generate_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext | |||
32 | if field_list.fields().count() != 1 { | 32 | if field_list.fields().count() != 1 { |
33 | return None; | 33 | return None; |
34 | } | 34 | } |
35 | let field_type = field_list.fields().next()?.type_ref()?; | 35 | let field_type = field_list.fields().next()?.ty()?; |
36 | let path = match field_type { | 36 | let path = match field_type { |
37 | ast::TypeRef::PathType(it) => it, | 37 | ast::Type::PathType(it) => it, |
38 | _ => return None, | 38 | _ => return None, |
39 | }; | 39 | }; |
40 | 40 | ||
@@ -69,7 +69,7 @@ impl From<{0}> for {1} {{ | |||
69 | 69 | ||
70 | fn existing_from_impl( | 70 | fn existing_from_impl( |
71 | sema: &'_ hir::Semantics<'_, RootDatabase>, | 71 | sema: &'_ hir::Semantics<'_, RootDatabase>, |
72 | variant: &ast::EnumVariant, | 72 | variant: &ast::Variant, |
73 | ) -> Option<()> { | 73 | ) -> Option<()> { |
74 | let variant = sema.to_def(variant)?; | 74 | let variant = sema.to_def(variant)?; |
75 | let enum_ = variant.parent_enum(sema.db); | 75 | let enum_ = variant.parent_enum(sema.db); |
diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index b721b96bb..56510861d 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs | |||
@@ -82,7 +82,7 @@ struct FunctionTemplate { | |||
82 | insert_offset: TextSize, | 82 | insert_offset: TextSize, |
83 | placeholder_expr: ast::MacroCall, | 83 | placeholder_expr: ast::MacroCall, |
84 | leading_ws: String, | 84 | leading_ws: String, |
85 | fn_def: ast::FnDef, | 85 | fn_def: ast::Fn, |
86 | trailing_ws: String, | 86 | trailing_ws: String, |
87 | file: FileId, | 87 | file: FileId, |
88 | } | 88 | } |
@@ -104,7 +104,7 @@ impl FunctionTemplate { | |||
104 | struct FunctionBuilder { | 104 | struct FunctionBuilder { |
105 | target: GeneratedFunctionTarget, | 105 | target: GeneratedFunctionTarget, |
106 | fn_name: ast::Name, | 106 | fn_name: ast::Name, |
107 | type_params: Option<ast::TypeParamList>, | 107 | type_params: Option<ast::GenericParamList>, |
108 | params: ast::ParamList, | 108 | params: ast::ParamList, |
109 | file: FileId, | 109 | file: FileId, |
110 | needs_pub: bool, | 110 | needs_pub: bool, |
@@ -200,7 +200,7 @@ fn fn_args( | |||
200 | ctx: &AssistContext, | 200 | ctx: &AssistContext, |
201 | target_module: hir::Module, | 201 | target_module: hir::Module, |
202 | call: &ast::CallExpr, | 202 | call: &ast::CallExpr, |
203 | ) -> Option<(Option<ast::TypeParamList>, ast::ParamList)> { | 203 | ) -> Option<(Option<ast::GenericParamList>, ast::ParamList)> { |
204 | let mut arg_names = Vec::new(); | 204 | let mut arg_names = Vec::new(); |
205 | let mut arg_types = Vec::new(); | 205 | let mut arg_types = Vec::new(); |
206 | for arg in call.arg_list()?.args() { | 206 | for arg in call.arg_list()?.args() { |
diff --git a/crates/ra_assists/src/handlers/generate_impl.rs b/crates/ra_assists/src/handlers/generate_impl.rs index cbbac1d7f..d9b87c9c0 100644 --- a/crates/ra_assists/src/handlers/generate_impl.rs +++ b/crates/ra_assists/src/handlers/generate_impl.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_syntax::ast::{self, AstNode, NameOwner, TypeParamsOwner}; | 1 | use ra_syntax::ast::{self, AstNode, GenericParamsOwner, NameOwner}; |
2 | use stdx::{format_to, SepBy}; | 2 | use stdx::{format_to, SepBy}; |
3 | 3 | ||
4 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 4 | use crate::{AssistContext, AssistId, AssistKind, Assists}; |
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
23 | // } | 23 | // } |
24 | // ``` | 24 | // ``` |
25 | pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 25 | pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
26 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; | 26 | let nominal = ctx.find_node_at_offset::<ast::AdtDef>()?; |
27 | let name = nominal.name()?; | 27 | let name = nominal.name()?; |
28 | let target = nominal.syntax().text_range(); | 28 | let target = nominal.syntax().text_range(); |
29 | acc.add( | 29 | acc.add( |
@@ -31,7 +31,7 @@ pub(crate) fn generate_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<() | |||
31 | format!("Generate impl for `{}`", name), | 31 | format!("Generate impl for `{}`", name), |
32 | target, | 32 | target, |
33 | |edit| { | 33 | |edit| { |
34 | let type_params = nominal.type_param_list(); | 34 | let type_params = nominal.generic_param_list(); |
35 | let start_offset = nominal.syntax().text_range().end(); | 35 | let start_offset = nominal.syntax().text_range().end(); |
36 | let mut buf = String::new(); | 36 | let mut buf = String::new(); |
37 | buf.push_str("\n\nimpl"); | 37 | buf.push_str("\n\nimpl"); |
diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index e27def1d8..b84aa24b6 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs | |||
@@ -1,8 +1,6 @@ | |||
1 | use hir::Adt; | 1 | use hir::Adt; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{ | 3 | ast::{self, AstNode, GenericParamsOwner, NameOwner, StructKind, VisibilityOwner}, |
4 | self, AstNode, NameOwner, StructKind, TypeAscriptionOwner, TypeParamsOwner, VisibilityOwner, | ||
5 | }, | ||
6 | T, | 4 | T, |
7 | }; | 5 | }; |
8 | use stdx::{format_to, SepBy}; | 6 | use stdx::{format_to, SepBy}; |
@@ -30,7 +28,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
30 | // | 28 | // |
31 | // ``` | 29 | // ``` |
32 | pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 30 | pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
33 | let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; | 31 | let strukt = ctx.find_node_at_offset::<ast::Struct>()?; |
34 | 32 | ||
35 | // We want to only apply this to non-union structs with named fields | 33 | // We want to only apply this to non-union structs with named fields |
36 | let field_list = match strukt.kind() { | 34 | let field_list = match strukt.kind() { |
@@ -53,9 +51,7 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
53 | 51 | ||
54 | let params = field_list | 52 | let params = field_list |
55 | .fields() | 53 | .fields() |
56 | .filter_map(|f| { | 54 | .filter_map(|f| Some(format!("{}: {}", f.name()?.syntax(), f.ty()?.syntax()))) |
57 | Some(format!("{}: {}", f.name()?.syntax(), f.ascribed_type()?.syntax())) | ||
58 | }) | ||
59 | .sep_by(", "); | 55 | .sep_by(", "); |
60 | let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", "); | 56 | let fields = field_list.fields().filter_map(|f| f.name()).sep_by(", "); |
61 | 57 | ||
@@ -90,8 +86,8 @@ pub(crate) fn generate_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
90 | 86 | ||
91 | // Generates the surrounding `impl Type { <code> }` including type and lifetime | 87 | // Generates the surrounding `impl Type { <code> }` including type and lifetime |
92 | // parameters | 88 | // parameters |
93 | fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | 89 | fn generate_impl_text(strukt: &ast::Struct, code: &str) -> String { |
94 | let type_params = strukt.type_param_list(); | 90 | let type_params = strukt.generic_param_list(); |
95 | let mut buf = String::with_capacity(code.len()); | 91 | let mut buf = String::with_capacity(code.len()); |
96 | buf.push_str("\n\nimpl"); | 92 | buf.push_str("\n\nimpl"); |
97 | if let Some(type_params) = &type_params { | 93 | if let Some(type_params) = &type_params { |
@@ -121,7 +117,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | |||
121 | // | 117 | // |
122 | // FIXME: change the new fn checking to a more semantic approach when that's more | 118 | // FIXME: change the new fn checking to a more semantic approach when that's more |
123 | // viable (e.g. we process proc macros, etc) | 119 | // viable (e.g. we process proc macros, etc) |
124 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { | 120 | fn find_struct_impl(ctx: &AssistContext, strukt: &ast::Struct) -> Option<Option<ast::Impl>> { |
125 | let db = ctx.db(); | 121 | let db = ctx.db(); |
126 | let module = strukt.syntax().ancestors().find(|node| { | 122 | let module = strukt.syntax().ancestors().find(|node| { |
127 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) | 123 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) |
@@ -129,7 +125,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti | |||
129 | 125 | ||
130 | let struct_def = ctx.sema.to_def(strukt)?; | 126 | let struct_def = ctx.sema.to_def(strukt)?; |
131 | 127 | ||
132 | let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| { | 128 | let block = module.descendants().filter_map(ast::Impl::cast).find_map(|impl_blk| { |
133 | let blk = ctx.sema.to_def(&impl_blk)?; | 129 | let blk = ctx.sema.to_def(&impl_blk)?; |
134 | 130 | ||
135 | // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` | 131 | // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` |
@@ -157,10 +153,10 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option<Opti | |||
157 | Some(block) | 153 | Some(block) |
158 | } | 154 | } |
159 | 155 | ||
160 | fn has_new_fn(imp: &ast::ImplDef) -> bool { | 156 | fn has_new_fn(imp: &ast::Impl) -> bool { |
161 | if let Some(il) = imp.item_list() { | 157 | if let Some(il) = imp.assoc_item_list() { |
162 | for item in il.assoc_items() { | 158 | for item in il.assoc_items() { |
163 | if let ast::AssocItem::FnDef(f) = item { | 159 | if let ast::AssocItem::Fn(f) = item { |
164 | if let Some(name) = f.name() { | 160 | if let Some(name) = f.name() { |
165 | if name.text().eq_ignore_ascii_case("new") { | 161 | if name.text().eq_ignore_ascii_case("new") { |
166 | return true; | 162 | return true; |
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index 967593031..4537c73a1 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, NameOwner, TypeAscriptionOwner, TypeParamsOwner}, | 2 | ast::{self, GenericParamsOwner, NameOwner}, |
3 | AstNode, SyntaxKind, TextRange, TextSize, | 3 | AstNode, SyntaxKind, TextRange, TextSize, |
4 | }; | 4 | }; |
5 | use rustc_hash::FxHashSet; | 5 | use rustc_hash::FxHashSet; |
@@ -38,9 +38,9 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - | |||
38 | let lifetime_token = ctx | 38 | let lifetime_token = ctx |
39 | .find_token_at_offset(SyntaxKind::LIFETIME) | 39 | .find_token_at_offset(SyntaxKind::LIFETIME) |
40 | .filter(|lifetime| lifetime.text() == "'_")?; | 40 | .filter(|lifetime| lifetime.text() == "'_")?; |
41 | if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) { | 41 | if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { |
42 | generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) | 42 | generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) |
43 | } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { | 43 | } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::Impl::cast) { |
44 | generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) | 44 | generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) |
45 | } else { | 45 | } else { |
46 | None | 46 | None |
@@ -50,11 +50,11 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - | |||
50 | /// Generate the assist for the fn def case | 50 | /// Generate the assist for the fn def case |
51 | fn generate_fn_def_assist( | 51 | fn generate_fn_def_assist( |
52 | acc: &mut Assists, | 52 | acc: &mut Assists, |
53 | fn_def: &ast::FnDef, | 53 | fn_def: &ast::Fn, |
54 | lifetime_loc: TextRange, | 54 | lifetime_loc: TextRange, |
55 | ) -> Option<()> { | 55 | ) -> Option<()> { |
56 | let param_list: ast::ParamList = fn_def.param_list()?; | 56 | let param_list: ast::ParamList = fn_def.param_list()?; |
57 | let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.type_param_list())?; | 57 | let new_lifetime_param = generate_unique_lifetime_param_name(&fn_def.generic_param_list())?; |
58 | let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end(); | 58 | let end_of_fn_ident = fn_def.name()?.ident_token()?.text_range().end(); |
59 | let self_param = | 59 | let self_param = |
60 | // use the self if it's a reference and has no explicit lifetime | 60 | // use the self if it's a reference and has no explicit lifetime |
@@ -67,8 +67,8 @@ fn generate_fn_def_assist( | |||
67 | // otherwise, if there's a single reference parameter without a named liftime, use that | 67 | // otherwise, if there's a single reference parameter without a named liftime, use that |
68 | let fn_params_without_lifetime: Vec<_> = param_list | 68 | let fn_params_without_lifetime: Vec<_> = param_list |
69 | .params() | 69 | .params() |
70 | .filter_map(|param| match param.ascribed_type() { | 70 | .filter_map(|param| match param.ty() { |
71 | Some(ast::TypeRef::ReferenceType(ascribed_type)) | 71 | Some(ast::Type::ReferenceType(ascribed_type)) |
72 | if ascribed_type.lifetime_token() == None => | 72 | if ascribed_type.lifetime_token() == None => |
73 | { | 73 | { |
74 | Some(ascribed_type.amp_token()?.text_range().end()) | 74 | Some(ascribed_type.amp_token()?.text_range().end()) |
@@ -93,10 +93,10 @@ fn generate_fn_def_assist( | |||
93 | /// Generate the assist for the impl def case | 93 | /// Generate the assist for the impl def case |
94 | fn generate_impl_def_assist( | 94 | fn generate_impl_def_assist( |
95 | acc: &mut Assists, | 95 | acc: &mut Assists, |
96 | impl_def: &ast::ImplDef, | 96 | impl_def: &ast::Impl, |
97 | lifetime_loc: TextRange, | 97 | lifetime_loc: TextRange, |
98 | ) -> Option<()> { | 98 | ) -> Option<()> { |
99 | let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; | 99 | let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.generic_param_list())?; |
100 | let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); | 100 | let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); |
101 | acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { | 101 | acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { |
102 | add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); | 102 | add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); |
@@ -107,7 +107,7 @@ fn generate_impl_def_assist( | |||
107 | /// Given a type parameter list, generate a unique lifetime parameter name | 107 | /// Given a type parameter list, generate a unique lifetime parameter name |
108 | /// which is not in the list | 108 | /// which is not in the list |
109 | fn generate_unique_lifetime_param_name( | 109 | fn generate_unique_lifetime_param_name( |
110 | existing_type_param_list: &Option<ast::TypeParamList>, | 110 | existing_type_param_list: &Option<ast::GenericParamList>, |
111 | ) -> Option<char> { | 111 | ) -> Option<char> { |
112 | match existing_type_param_list { | 112 | match existing_type_param_list { |
113 | Some(type_params) => { | 113 | Some(type_params) => { |
@@ -123,13 +123,13 @@ fn generate_unique_lifetime_param_name( | |||
123 | 123 | ||
124 | /// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise | 124 | /// Add the lifetime param to `builder`. If there are type parameters in `type_params_owner`, add it to the end. Otherwise |
125 | /// add new type params brackets with the lifetime parameter at `new_type_params_loc`. | 125 | /// add new type params brackets with the lifetime parameter at `new_type_params_loc`. |
126 | fn add_lifetime_param<TypeParamsOwner: ast::TypeParamsOwner>( | 126 | fn add_lifetime_param<TypeParamsOwner: ast::GenericParamsOwner>( |
127 | type_params_owner: &TypeParamsOwner, | 127 | type_params_owner: &TypeParamsOwner, |
128 | builder: &mut AssistBuilder, | 128 | builder: &mut AssistBuilder, |
129 | new_type_params_loc: TextSize, | 129 | new_type_params_loc: TextSize, |
130 | new_lifetime_param: char, | 130 | new_lifetime_param: char, |
131 | ) { | 131 | ) { |
132 | match type_params_owner.type_param_list() { | 132 | match type_params_owner.generic_param_list() { |
133 | // add the new lifetime parameter to an existing type param list | 133 | // add the new lifetime parameter to an existing type param list |
134 | Some(type_params) => { | 134 | Some(type_params) => { |
135 | builder.insert( | 135 | builder.insert( |
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index 1beccb61c..c775fe25c 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -28,7 +28,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<() | |||
28 | let mut rewriter = SyntaxRewriter::default(); | 28 | let mut rewriter = SyntaxRewriter::default(); |
29 | let mut offset = ctx.offset(); | 29 | let mut offset = ctx.offset(); |
30 | 30 | ||
31 | if let Some(use_item) = tree.syntax().parent().and_then(ast::UseItem::cast) { | 31 | if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) { |
32 | let (merged, to_delete) = next_prev() | 32 | let (merged, to_delete) = next_prev() |
33 | .filter_map(|dir| neighbor(&use_item, dir)) | 33 | .filter_map(|dir| neighbor(&use_item, dir)) |
34 | .filter_map(|it| Some((it.clone(), it.use_tree()?))) | 34 | .filter_map(|it| Some((it.clone(), it.use_tree()?))) |
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index ba3dafb99..6d394443e 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs | |||
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
23 | // } | 23 | // } |
24 | // ``` | 24 | // ``` |
25 | pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 25 | pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
26 | let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?; | 26 | let type_param_list = ctx.find_node_at_offset::<ast::GenericParamList>()?; |
27 | 27 | ||
28 | let mut type_params = type_param_list.type_params(); | 28 | let mut type_params = type_param_list.type_params(); |
29 | if type_params.all(|p| p.type_bound_list().is_none()) { | 29 | if type_params.all(|p| p.type_bound_list().is_none()) { |
@@ -37,13 +37,13 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext | |||
37 | 37 | ||
38 | let anchor = match_ast! { | 38 | let anchor = match_ast! { |
39 | match parent { | 39 | match parent { |
40 | ast::FnDef(it) => it.body()?.syntax().clone().into(), | 40 | ast::Fn(it) => it.body()?.syntax().clone().into(), |
41 | ast::TraitDef(it) => it.item_list()?.syntax().clone().into(), | 41 | ast::Trait(it) => it.assoc_item_list()?.syntax().clone().into(), |
42 | ast::ImplDef(it) => it.item_list()?.syntax().clone().into(), | 42 | ast::Impl(it) => it.assoc_item_list()?.syntax().clone().into(), |
43 | ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), | 43 | ast::Enum(it) => it.variant_list()?.syntax().clone().into(), |
44 | ast::StructDef(it) => { | 44 | ast::Struct(it) => { |
45 | it.syntax().children_with_tokens() | 45 | it.syntax().children_with_tokens() |
46 | .find(|it| it.kind() == RECORD_FIELD_DEF_LIST || it.kind() == T![;])? | 46 | .find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])? |
47 | }, | 47 | }, |
48 | _ => return None | 48 | _ => return None |
49 | } | 49 | } |
diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs index a616cca57..9430ce1b5 100644 --- a/crates/ra_assists/src/handlers/remove_dbg.rs +++ b/crates/ra_assists/src/handlers/remove_dbg.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
3 | TextSize, T, | 3 | TextRange, TextSize, T, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 6 | use crate::{AssistContext, AssistId, AssistKind, Assists}; |
@@ -27,19 +27,33 @@ pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
27 | return None; | 27 | return None; |
28 | } | 28 | } |
29 | 29 | ||
30 | let macro_range = macro_call.syntax().text_range(); | 30 | let is_leaf = macro_call.syntax().next_sibling().is_none(); |
31 | 31 | ||
32 | let macro_content = { | 32 | let macro_end = if macro_call.semicolon_token().is_some() { |
33 | let macro_args = macro_call.token_tree()?.syntax().clone(); | 33 | macro_call.syntax().text_range().end() - TextSize::of(';') |
34 | } else { | ||
35 | macro_call.syntax().text_range().end() | ||
36 | }; | ||
34 | 37 | ||
35 | let text = macro_args.text(); | 38 | // macro_range determines what will be deleted and replaced with macro_content |
36 | let without_parens = TextSize::of('(')..text.len() - TextSize::of(')'); | 39 | let macro_range = TextRange::new(macro_call.syntax().text_range().start(), macro_end); |
37 | text.slice(without_parens).to_string() | 40 | let paste_instead_of_dbg = { |
41 | let text = macro_call.token_tree()?.syntax().text(); | ||
42 | |||
43 | // leafiness determines if we should include the parenthesis or not | ||
44 | let slice_index: TextRange = if is_leaf { | ||
45 | // leaf means - we can extract the contents of the dbg! in text | ||
46 | TextRange::new(TextSize::of('('), text.len() - TextSize::of(')')) | ||
47 | } else { | ||
48 | // not leaf - means we should keep the parens | ||
49 | TextRange::up_to(text.len()) | ||
50 | }; | ||
51 | text.slice(slice_index).to_string() | ||
38 | }; | 52 | }; |
39 | 53 | ||
40 | let target = macro_call.syntax().text_range(); | 54 | let target = macro_call.syntax().text_range(); |
41 | acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| { | 55 | acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| { |
42 | builder.replace(macro_range, macro_content); | 56 | builder.replace(macro_range, paste_instead_of_dbg); |
43 | }) | 57 | }) |
44 | } | 58 | } |
45 | 59 | ||
@@ -99,6 +113,7 @@ fn foo(n: usize) { | |||
99 | ", | 113 | ", |
100 | ); | 114 | ); |
101 | } | 115 | } |
116 | |||
102 | #[test] | 117 | #[test] |
103 | fn test_remove_dbg_with_brackets_and_braces() { | 118 | fn test_remove_dbg_with_brackets_and_braces() { |
104 | check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1"); | 119 | check_assist(remove_dbg, "dbg![<|>1 + 1]", "1 + 1"); |
@@ -113,7 +128,7 @@ fn foo(n: usize) { | |||
113 | } | 128 | } |
114 | 129 | ||
115 | #[test] | 130 | #[test] |
116 | fn remove_dbg_target() { | 131 | fn test_remove_dbg_target() { |
117 | check_assist_target( | 132 | check_assist_target( |
118 | remove_dbg, | 133 | remove_dbg, |
119 | " | 134 | " |
@@ -126,4 +141,65 @@ fn foo(n: usize) { | |||
126 | "dbg!(n.checked_sub(4))", | 141 | "dbg!(n.checked_sub(4))", |
127 | ); | 142 | ); |
128 | } | 143 | } |
144 | |||
145 | #[test] | ||
146 | fn test_remove_dbg_keep_semicolon() { | ||
147 | // https://github.com/rust-analyzer/rust-analyzer/issues/5129#issuecomment-651399779 | ||
148 | // not quite though | ||
149 | // adding a comment at the end of the line makes | ||
150 | // the ast::MacroCall to include the semicolon at the end | ||
151 | check_assist( | ||
152 | remove_dbg, | ||
153 | r#"let res = <|>dbg!(1 * 20); // needless comment"#, | ||
154 | r#"let res = 1 * 20; // needless comment"#, | ||
155 | ); | ||
156 | } | ||
157 | |||
158 | #[test] | ||
159 | fn test_remove_dbg_keep_expression() { | ||
160 | check_assist( | ||
161 | remove_dbg, | ||
162 | r#"let res = <|>dbg!(a + b).foo();"#, | ||
163 | r#"let res = (a + b).foo();"#, | ||
164 | ); | ||
165 | } | ||
166 | |||
167 | #[test] | ||
168 | fn test_remove_dbg_from_inside_fn() { | ||
169 | check_assist_target( | ||
170 | remove_dbg, | ||
171 | r#" | ||
172 | fn square(x: u32) -> u32 { | ||
173 | x * x | ||
174 | } | ||
175 | |||
176 | fn main() { | ||
177 | let x = square(dbg<|>!(5 + 10)); | ||
178 | println!("{}", x); | ||
179 | }"#, | ||
180 | "dbg!(5 + 10)", | ||
181 | ); | ||
182 | |||
183 | check_assist( | ||
184 | remove_dbg, | ||
185 | r#" | ||
186 | fn square(x: u32) -> u32 { | ||
187 | x * x | ||
188 | } | ||
189 | |||
190 | fn main() { | ||
191 | let x = square(dbg<|>!(5 + 10)); | ||
192 | println!("{}", x); | ||
193 | }"#, | ||
194 | r#" | ||
195 | fn square(x: u32) -> u32 { | ||
196 | x * x | ||
197 | } | ||
198 | |||
199 | fn main() { | ||
200 | let x = square(5 + 10); | ||
201 | println!("{}", x); | ||
202 | }"#, | ||
203 | ); | ||
204 | } | ||
129 | } | 205 | } |
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index 2ac1c56cf..120250e79 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs | |||
@@ -23,7 +23,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
23 | // ``` | 23 | // ``` |
24 | // | 24 | // |
25 | pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 25 | pub(crate) fn reorder_fields(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
26 | reorder::<ast::RecordLit>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) | 26 | reorder::<ast::RecordExpr>(acc, ctx).or_else(|| reorder::<ast::RecordPat>(acc, ctx)) |
27 | } | 27 | } |
28 | 28 | ||
29 | fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 29 | fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
@@ -56,7 +56,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
56 | 56 | ||
57 | fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { | 57 | fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { |
58 | match node.kind() { | 58 | match node.kind() { |
59 | RECORD_LIT => vec![RECORD_FIELD], | 59 | RECORD_EXPR => vec![RECORD_EXPR_FIELD], |
60 | RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], | 60 | RECORD_PAT => vec![RECORD_FIELD_PAT, BIND_PAT], |
61 | _ => vec![], | 61 | _ => vec![], |
62 | } | 62 | } |
@@ -65,7 +65,7 @@ fn get_fields_kind(node: &SyntaxNode) -> Vec<SyntaxKind> { | |||
65 | fn get_field_name(node: &SyntaxNode) -> String { | 65 | fn get_field_name(node: &SyntaxNode) -> String { |
66 | let res = match_ast! { | 66 | let res = match_ast! { |
67 | match node { | 67 | match node { |
68 | ast::RecordField(field) => field.field_name().map(|it| it.to_string()), | 68 | ast::RecordExprField(field) => field.field_name().map(|it| it.to_string()), |
69 | ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), | 69 | ast::RecordFieldPat(field) => field.field_name().map(|it| it.to_string()), |
70 | _ => None, | 70 | _ => None, |
71 | } | 71 | } |
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index 3d51faa54..53496ede1 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -25,7 +25,7 @@ pub(crate) fn replace_qualified_name_with_use( | |||
25 | ) -> Option<()> { | 25 | ) -> Option<()> { |
26 | let path: ast::Path = ctx.find_node_at_offset()?; | 26 | let path: ast::Path = ctx.find_node_at_offset()?; |
27 | // We don't want to mess with use statements | 27 | // We don't want to mess with use statements |
28 | if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() { | 28 | if path.syntax().ancestors().find_map(ast::Use::cast).is_some() { |
29 | return None; | 29 | return None; |
30 | } | 30 | } |
31 | 31 | ||
@@ -85,7 +85,7 @@ fn shorten_paths(rewriter: &mut SyntaxRewriter<'static>, node: SyntaxNode, path: | |||
85 | match child { | 85 | match child { |
86 | // Don't modify `use` items, as this can break the `use` item when injecting a new | 86 | // Don't modify `use` items, as this can break the `use` item when injecting a new |
87 | // import into the use tree. | 87 | // import into the use tree. |
88 | ast::UseItem(_it) => continue, | 88 | ast::Use(_it) => continue, |
89 | // Don't descend into submodules, they don't have the same `use` items in scope. | 89 | // Don't descend into submodules, they don't have the same `use` items in scope. |
90 | ast::Module(_it) => continue, | 90 | ast::Module(_it) => continue, |
91 | 91 | ||
diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 02de902d6..bb16ebd4e 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs | |||
@@ -56,33 +56,34 @@ pub(crate) fn render_snippet(_cap: SnippetCap, node: &SyntaxNode, cursor: Cursor | |||
56 | 56 | ||
57 | pub fn get_missing_assoc_items( | 57 | pub fn get_missing_assoc_items( |
58 | sema: &Semantics<RootDatabase>, | 58 | sema: &Semantics<RootDatabase>, |
59 | impl_def: &ast::ImplDef, | 59 | impl_def: &ast::Impl, |
60 | ) -> Vec<hir::AssocItem> { | 60 | ) -> Vec<hir::AssocItem> { |
61 | // Names must be unique between constants and functions. However, type aliases | 61 | // Names must be unique between constants and functions. However, type aliases |
62 | // may share the same name as a function or constant. | 62 | // may share the same name as a function or constant. |
63 | let mut impl_fns_consts = FxHashSet::default(); | 63 | let mut impl_fns_consts = FxHashSet::default(); |
64 | let mut impl_type = FxHashSet::default(); | 64 | let mut impl_type = FxHashSet::default(); |
65 | 65 | ||
66 | if let Some(item_list) = impl_def.item_list() { | 66 | if let Some(item_list) = impl_def.assoc_item_list() { |
67 | for item in item_list.assoc_items() { | 67 | for item in item_list.assoc_items() { |
68 | match item { | 68 | match item { |
69 | ast::AssocItem::FnDef(f) => { | 69 | ast::AssocItem::Fn(f) => { |
70 | if let Some(n) = f.name() { | 70 | if let Some(n) = f.name() { |
71 | impl_fns_consts.insert(n.syntax().to_string()); | 71 | impl_fns_consts.insert(n.syntax().to_string()); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | ast::AssocItem::TypeAliasDef(t) => { | 75 | ast::AssocItem::TypeAlias(t) => { |
76 | if let Some(n) = t.name() { | 76 | if let Some(n) = t.name() { |
77 | impl_type.insert(n.syntax().to_string()); | 77 | impl_type.insert(n.syntax().to_string()); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | ast::AssocItem::ConstDef(c) => { | 81 | ast::AssocItem::Const(c) => { |
82 | if let Some(n) = c.name() { | 82 | if let Some(n) = c.name() { |
83 | impl_fns_consts.insert(n.syntax().to_string()); | 83 | impl_fns_consts.insert(n.syntax().to_string()); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | ast::AssocItem::MacroCall(_) => (), | ||
86 | } | 87 | } |
87 | } | 88 | } |
88 | } | 89 | } |
@@ -108,7 +109,7 @@ pub fn get_missing_assoc_items( | |||
108 | 109 | ||
109 | pub(crate) fn resolve_target_trait( | 110 | pub(crate) fn resolve_target_trait( |
110 | sema: &Semantics<RootDatabase>, | 111 | sema: &Semantics<RootDatabase>, |
111 | impl_def: &ast::ImplDef, | 112 | impl_def: &ast::Impl, |
112 | ) -> Option<hir::Trait> { | 113 | ) -> Option<hir::Trait> { |
113 | let ast_path = impl_def | 114 | let ast_path = impl_def |
114 | .target_trait() | 115 | .target_trait() |
diff --git a/crates/ra_assists/src/utils/insert_use.rs b/crates/ra_assists/src/utils/insert_use.rs index 8c4f33e59..617afe2e9 100644 --- a/crates/ra_assists/src/utils/insert_use.rs +++ b/crates/ra_assists/src/utils/insert_use.rs | |||
@@ -215,7 +215,7 @@ fn walk_use_tree_for_best_action( | |||
215 | let prev_len = current_path_segments.len(); | 215 | let prev_len = current_path_segments.len(); |
216 | 216 | ||
217 | let tree_list = current_use_tree.use_tree_list(); | 217 | let tree_list = current_use_tree.use_tree_list(); |
218 | let alias = current_use_tree.alias(); | 218 | let alias = current_use_tree.rename(); |
219 | 219 | ||
220 | let path = match current_use_tree.path() { | 220 | let path = match current_use_tree.path() { |
221 | Some(path) => path, | 221 | Some(path) => path, |
@@ -225,7 +225,7 @@ fn walk_use_tree_for_best_action( | |||
225 | current_use_tree | 225 | current_use_tree |
226 | .syntax() | 226 | .syntax() |
227 | .ancestors() | 227 | .ancestors() |
228 | .find_map(ast::UseItem::cast) | 228 | .find_map(ast::Use::cast) |
229 | .map(|it| it.syntax().clone()), | 229 | .map(|it| it.syntax().clone()), |
230 | true, | 230 | true, |
231 | ); | 231 | ); |
@@ -254,7 +254,7 @@ fn walk_use_tree_for_best_action( | |||
254 | current_use_tree | 254 | current_use_tree |
255 | .syntax() | 255 | .syntax() |
256 | .ancestors() | 256 | .ancestors() |
257 | .find_map(ast::UseItem::cast) | 257 | .find_map(ast::Use::cast) |
258 | .map(|it| it.syntax().clone()), | 258 | .map(|it| it.syntax().clone()), |
259 | true, | 259 | true, |
260 | ), | 260 | ), |
@@ -304,7 +304,7 @@ fn walk_use_tree_for_best_action( | |||
304 | current_use_tree | 304 | current_use_tree |
305 | .syntax() | 305 | .syntax() |
306 | .ancestors() | 306 | .ancestors() |
307 | .find_map(ast::UseItem::cast) | 307 | .find_map(ast::Use::cast) |
308 | .map(|it| it.syntax().clone()), | 308 | .map(|it| it.syntax().clone()), |
309 | true, | 309 | true, |
310 | ); | 310 | ); |
@@ -377,7 +377,7 @@ fn best_action_for_target( | |||
377 | let mut storage = Vec::with_capacity(16); // this should be the only allocation | 377 | let mut storage = Vec::with_capacity(16); // this should be the only allocation |
378 | let best_action = container | 378 | let best_action = container |
379 | .children() | 379 | .children() |
380 | .filter_map(ast::UseItem::cast) | 380 | .filter_map(ast::Use::cast) |
381 | .filter_map(|it| it.use_tree()) | 381 | .filter_map(|it| it.use_tree()) |
382 | .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target)) | 382 | .map(|u| walk_use_tree_for_best_action(&mut storage, None, u, target)) |
383 | .fold(None, |best, a| match best { | 383 | .fold(None, |best, a| match best { |
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 859bdfb3b..36c0bdc9e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -361,8 +361,8 @@ pub struct Field { | |||
361 | 361 | ||
362 | #[derive(Debug, PartialEq, Eq)] | 362 | #[derive(Debug, PartialEq, Eq)] |
363 | pub enum FieldSource { | 363 | pub enum FieldSource { |
364 | Named(ast::RecordFieldDef), | 364 | Named(ast::RecordField), |
365 | Pos(ast::TupleFieldDef), | 365 | Pos(ast::TupleField), |
366 | } | 366 | } |
367 | 367 | ||
368 | impl Field { | 368 | impl Field { |
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index 11a0ecb8b..266b513dc 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs | |||
@@ -1,6 +1,8 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | pub use hir_def::diagnostics::UnresolvedModule; | 2 | pub use hir_def::diagnostics::UnresolvedModule; |
3 | pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; | 3 | pub use hir_expand::diagnostics::{ |
4 | AstDiagnostic, Diagnostic, DiagnosticSink, DiagnosticSinkBuilder, | ||
5 | }; | ||
4 | pub use hir_ty::diagnostics::{ | 6 | pub use hir_ty::diagnostics::{ |
5 | MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, | 7 | MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, NoSuchField, |
6 | }; | 8 | }; |
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 76c32fc17..1c691d961 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs | |||
@@ -57,56 +57,56 @@ impl HasSource for Field { | |||
57 | } | 57 | } |
58 | } | 58 | } |
59 | impl HasSource for Struct { | 59 | impl HasSource for Struct { |
60 | type Ast = ast::StructDef; | 60 | type Ast = ast::Struct; |
61 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::StructDef> { | 61 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Struct> { |
62 | self.id.lookup(db.upcast()).source(db.upcast()) | 62 | self.id.lookup(db.upcast()).source(db.upcast()) |
63 | } | 63 | } |
64 | } | 64 | } |
65 | impl HasSource for Union { | 65 | impl HasSource for Union { |
66 | type Ast = ast::UnionDef; | 66 | type Ast = ast::Union; |
67 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::UnionDef> { | 67 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Union> { |
68 | self.id.lookup(db.upcast()).source(db.upcast()) | 68 | self.id.lookup(db.upcast()).source(db.upcast()) |
69 | } | 69 | } |
70 | } | 70 | } |
71 | impl HasSource for Enum { | 71 | impl HasSource for Enum { |
72 | type Ast = ast::EnumDef; | 72 | type Ast = ast::Enum; |
73 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::EnumDef> { | 73 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Enum> { |
74 | self.id.lookup(db.upcast()).source(db.upcast()) | 74 | self.id.lookup(db.upcast()).source(db.upcast()) |
75 | } | 75 | } |
76 | } | 76 | } |
77 | impl HasSource for EnumVariant { | 77 | impl HasSource for EnumVariant { |
78 | type Ast = ast::EnumVariant; | 78 | type Ast = ast::Variant; |
79 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::EnumVariant> { | 79 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Variant> { |
80 | self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone()) | 80 | self.parent.id.child_source(db.upcast()).map(|map| map[self.id].clone()) |
81 | } | 81 | } |
82 | } | 82 | } |
83 | impl HasSource for Function { | 83 | impl HasSource for Function { |
84 | type Ast = ast::FnDef; | 84 | type Ast = ast::Fn; |
85 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::FnDef> { | 85 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Fn> { |
86 | self.id.lookup(db.upcast()).source(db.upcast()) | 86 | self.id.lookup(db.upcast()).source(db.upcast()) |
87 | } | 87 | } |
88 | } | 88 | } |
89 | impl HasSource for Const { | 89 | impl HasSource for Const { |
90 | type Ast = ast::ConstDef; | 90 | type Ast = ast::Const; |
91 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::ConstDef> { | 91 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Const> { |
92 | self.id.lookup(db.upcast()).source(db.upcast()) | 92 | self.id.lookup(db.upcast()).source(db.upcast()) |
93 | } | 93 | } |
94 | } | 94 | } |
95 | impl HasSource for Static { | 95 | impl HasSource for Static { |
96 | type Ast = ast::StaticDef; | 96 | type Ast = ast::Static; |
97 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::StaticDef> { | 97 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Static> { |
98 | self.id.lookup(db.upcast()).source(db.upcast()) | 98 | self.id.lookup(db.upcast()).source(db.upcast()) |
99 | } | 99 | } |
100 | } | 100 | } |
101 | impl HasSource for Trait { | 101 | impl HasSource for Trait { |
102 | type Ast = ast::TraitDef; | 102 | type Ast = ast::Trait; |
103 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::TraitDef> { | 103 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Trait> { |
104 | self.id.lookup(db.upcast()).source(db.upcast()) | 104 | self.id.lookup(db.upcast()).source(db.upcast()) |
105 | } | 105 | } |
106 | } | 106 | } |
107 | impl HasSource for TypeAlias { | 107 | impl HasSource for TypeAlias { |
108 | type Ast = ast::TypeAliasDef; | 108 | type Ast = ast::TypeAlias; |
109 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::TypeAliasDef> { | 109 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::TypeAlias> { |
110 | self.id.lookup(db.upcast()).source(db.upcast()) | 110 | self.id.lookup(db.upcast()).source(db.upcast()) |
111 | } | 111 | } |
112 | } | 112 | } |
@@ -120,14 +120,14 @@ impl HasSource for MacroDef { | |||
120 | } | 120 | } |
121 | } | 121 | } |
122 | impl HasSource for ImplDef { | 122 | impl HasSource for ImplDef { |
123 | type Ast = ast::ImplDef; | 123 | type Ast = ast::Impl; |
124 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::ImplDef> { | 124 | fn source(self, db: &dyn HirDatabase) -> InFile<ast::Impl> { |
125 | self.id.lookup(db.upcast()).source(db.upcast()) | 125 | self.id.lookup(db.upcast()).source(db.upcast()) |
126 | } | 126 | } |
127 | } | 127 | } |
128 | 128 | ||
129 | impl HasSource for TypeParam { | 129 | impl HasSource for TypeParam { |
130 | type Ast = Either<ast::TraitDef, ast::TypeParam>; | 130 | type Ast = Either<ast::Trait, ast::TypeParam>; |
131 | fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> { | 131 | fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> { |
132 | let child_source = self.id.parent.child_source(db.upcast()); | 132 | let child_source = self.id.parent.child_source(db.upcast()); |
133 | child_source.map(|it| it[self.id.local_id].clone()) | 133 | child_source.map(|it| it[self.id.local_id].clone()) |
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index f5283ab22..6f3b3dc9a 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs | |||
@@ -89,6 +89,7 @@ pub struct Semantics<'db, DB> { | |||
89 | pub struct SemanticsImpl<'db> { | 89 | pub struct SemanticsImpl<'db> { |
90 | pub db: &'db dyn HirDatabase, | 90 | pub db: &'db dyn HirDatabase, |
91 | s2d_cache: RefCell<SourceToDefCache>, | 91 | s2d_cache: RefCell<SourceToDefCache>, |
92 | expansion_info_cache: RefCell<FxHashMap<HirFileId, Option<ExpansionInfo>>>, | ||
92 | cache: RefCell<FxHashMap<SyntaxNode, HirFileId>>, | 93 | cache: RefCell<FxHashMap<SyntaxNode, HirFileId>>, |
93 | } | 94 | } |
94 | 95 | ||
@@ -208,7 +209,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
208 | self.imp.resolve_field(field) | 209 | self.imp.resolve_field(field) |
209 | } | 210 | } |
210 | 211 | ||
211 | pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { | 212 | pub fn resolve_record_field( |
213 | &self, | ||
214 | field: &ast::RecordExprField, | ||
215 | ) -> Option<(Field, Option<Local>)> { | ||
212 | self.imp.resolve_record_field(field) | 216 | self.imp.resolve_record_field(field) |
213 | } | 217 | } |
214 | 218 | ||
@@ -224,7 +228,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
224 | self.imp.resolve_path(path) | 228 | self.imp.resolve_path(path) |
225 | } | 229 | } |
226 | 230 | ||
227 | pub fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantDef> { | 231 | pub fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantDef> { |
228 | self.imp.resolve_variant(record_lit).map(VariantDef::from) | 232 | self.imp.resolve_variant(record_lit).map(VariantDef::from) |
229 | } | 233 | } |
230 | 234 | ||
@@ -239,7 +243,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
239 | // FIXME: use this instead? | 243 | // FIXME: use this instead? |
240 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; | 244 | // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; |
241 | 245 | ||
242 | pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { | 246 | pub fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> { |
243 | self.imp.record_literal_missing_fields(literal) | 247 | self.imp.record_literal_missing_fields(literal) |
244 | } | 248 | } |
245 | 249 | ||
@@ -275,7 +279,12 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { | |||
275 | 279 | ||
276 | impl<'db> SemanticsImpl<'db> { | 280 | impl<'db> SemanticsImpl<'db> { |
277 | fn new(db: &'db dyn HirDatabase) -> Self { | 281 | fn new(db: &'db dyn HirDatabase) -> Self { |
278 | Self { db, s2d_cache: Default::default(), cache: Default::default() } | 282 | SemanticsImpl { |
283 | db, | ||
284 | s2d_cache: Default::default(), | ||
285 | cache: Default::default(), | ||
286 | expansion_info_cache: Default::default(), | ||
287 | } | ||
279 | } | 288 | } |
280 | 289 | ||
281 | fn parse(&self, file_id: FileId) -> ast::SourceFile { | 290 | fn parse(&self, file_id: FileId) -> ast::SourceFile { |
@@ -315,18 +324,26 @@ impl<'db> SemanticsImpl<'db> { | |||
315 | } | 324 | } |
316 | 325 | ||
317 | fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { | 326 | fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { |
327 | let _p = profile("descend_into_macros"); | ||
318 | let parent = token.parent(); | 328 | let parent = token.parent(); |
319 | let parent = self.find_file(parent); | 329 | let parent = self.find_file(parent); |
320 | let sa = self.analyze2(parent.as_ref(), None); | 330 | let sa = self.analyze2(parent.as_ref(), None); |
321 | 331 | ||
322 | let token = successors(Some(parent.with_value(token)), |token| { | 332 | let token = successors(Some(parent.with_value(token)), |token| { |
333 | self.db.check_canceled(); | ||
323 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; | 334 | let macro_call = token.value.ancestors().find_map(ast::MacroCall::cast)?; |
324 | let tt = macro_call.token_tree()?; | 335 | let tt = macro_call.token_tree()?; |
325 | if !tt.syntax().text_range().contains_range(token.value.text_range()) { | 336 | if !tt.syntax().text_range().contains_range(token.value.text_range()) { |
326 | return None; | 337 | return None; |
327 | } | 338 | } |
328 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; | 339 | let file_id = sa.expand(self.db, token.with_value(¯o_call))?; |
329 | let token = file_id.expansion_info(self.db.upcast())?.map_token_down(token.as_ref())?; | 340 | let token = self |
341 | .expansion_info_cache | ||
342 | .borrow_mut() | ||
343 | .entry(file_id) | ||
344 | .or_insert_with(|| file_id.expansion_info(self.db.upcast())) | ||
345 | .as_ref()? | ||
346 | .map_token_down(token.as_ref())?; | ||
330 | 347 | ||
331 | self.cache(find_root(&token.value.parent()), token.file_id); | 348 | self.cache(find_root(&token.value.parent()), token.file_id); |
332 | 349 | ||
@@ -408,7 +425,7 @@ impl<'db> SemanticsImpl<'db> { | |||
408 | self.analyze(field.syntax()).resolve_field(self.db, field) | 425 | self.analyze(field.syntax()).resolve_field(self.db, field) |
409 | } | 426 | } |
410 | 427 | ||
411 | fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> { | 428 | fn resolve_record_field(&self, field: &ast::RecordExprField) -> Option<(Field, Option<Local>)> { |
412 | self.analyze(field.syntax()).resolve_record_field(self.db, field) | 429 | self.analyze(field.syntax()).resolve_record_field(self.db, field) |
413 | } | 430 | } |
414 | 431 | ||
@@ -426,7 +443,7 @@ impl<'db> SemanticsImpl<'db> { | |||
426 | self.analyze(path.syntax()).resolve_path(self.db, path) | 443 | self.analyze(path.syntax()).resolve_path(self.db, path) |
427 | } | 444 | } |
428 | 445 | ||
429 | fn resolve_variant(&self, record_lit: ast::RecordLit) -> Option<VariantId> { | 446 | fn resolve_variant(&self, record_lit: ast::RecordExpr) -> Option<VariantId> { |
430 | self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) | 447 | self.analyze(record_lit.syntax()).resolve_variant(self.db, record_lit) |
431 | } | 448 | } |
432 | 449 | ||
@@ -439,7 +456,7 @@ impl<'db> SemanticsImpl<'db> { | |||
439 | self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) | 456 | self.analyze(pat.syntax()).resolve_bind_pat_to_const(self.db, pat) |
440 | } | 457 | } |
441 | 458 | ||
442 | fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> { | 459 | fn record_literal_missing_fields(&self, literal: &ast::RecordExpr) -> Vec<(Field, Type)> { |
443 | self.analyze(literal.syntax()) | 460 | self.analyze(literal.syntax()) |
444 | .record_literal_missing_fields(self.db, literal) | 461 | .record_literal_missing_fields(self.db, literal) |
445 | .unwrap_or_default() | 462 | .unwrap_or_default() |
@@ -563,18 +580,18 @@ macro_rules! to_def_impls { | |||
563 | 580 | ||
564 | to_def_impls![ | 581 | to_def_impls![ |
565 | (crate::Module, ast::Module, module_to_def), | 582 | (crate::Module, ast::Module, module_to_def), |
566 | (crate::Struct, ast::StructDef, struct_to_def), | 583 | (crate::Struct, ast::Struct, struct_to_def), |
567 | (crate::Enum, ast::EnumDef, enum_to_def), | 584 | (crate::Enum, ast::Enum, enum_to_def), |
568 | (crate::Union, ast::UnionDef, union_to_def), | 585 | (crate::Union, ast::Union, union_to_def), |
569 | (crate::Trait, ast::TraitDef, trait_to_def), | 586 | (crate::Trait, ast::Trait, trait_to_def), |
570 | (crate::ImplDef, ast::ImplDef, impl_to_def), | 587 | (crate::ImplDef, ast::Impl, impl_to_def), |
571 | (crate::TypeAlias, ast::TypeAliasDef, type_alias_to_def), | 588 | (crate::TypeAlias, ast::TypeAlias, type_alias_to_def), |
572 | (crate::Const, ast::ConstDef, const_to_def), | 589 | (crate::Const, ast::Const, const_to_def), |
573 | (crate::Static, ast::StaticDef, static_to_def), | 590 | (crate::Static, ast::Static, static_to_def), |
574 | (crate::Function, ast::FnDef, fn_to_def), | 591 | (crate::Function, ast::Fn, fn_to_def), |
575 | (crate::Field, ast::RecordFieldDef, record_field_to_def), | 592 | (crate::Field, ast::RecordField, record_field_to_def), |
576 | (crate::Field, ast::TupleFieldDef, tuple_field_to_def), | 593 | (crate::Field, ast::TupleField, tuple_field_to_def), |
577 | (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def), | 594 | (crate::EnumVariant, ast::Variant, enum_variant_to_def), |
578 | (crate::TypeParam, ast::TypeParam, type_param_to_def), | 595 | (crate::TypeParam, ast::TypeParam, type_param_to_def), |
579 | (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros | 596 | (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros |
580 | (crate::Local, ast::BindPat, bind_pat_to_def), | 597 | (crate::Local, ast::BindPat, bind_pat_to_def), |
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 42e5a1bdb..d1994e2e7 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs | |||
@@ -65,53 +65,44 @@ impl SourceToDefCtx<'_, '_> { | |||
65 | Some(ModuleId { krate: parent_module.krate, local_id: child_id }) | 65 | Some(ModuleId { krate: parent_module.krate, local_id: child_id }) |
66 | } | 66 | } |
67 | 67 | ||
68 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::TraitDef>) -> Option<TraitId> { | 68 | pub(super) fn trait_to_def(&mut self, src: InFile<ast::Trait>) -> Option<TraitId> { |
69 | self.to_def(src, keys::TRAIT) | 69 | self.to_def(src, keys::TRAIT) |
70 | } | 70 | } |
71 | pub(super) fn impl_to_def(&mut self, src: InFile<ast::ImplDef>) -> Option<ImplId> { | 71 | pub(super) fn impl_to_def(&mut self, src: InFile<ast::Impl>) -> Option<ImplId> { |
72 | self.to_def(src, keys::IMPL) | 72 | self.to_def(src, keys::IMPL) |
73 | } | 73 | } |
74 | pub(super) fn fn_to_def(&mut self, src: InFile<ast::FnDef>) -> Option<FunctionId> { | 74 | pub(super) fn fn_to_def(&mut self, src: InFile<ast::Fn>) -> Option<FunctionId> { |
75 | self.to_def(src, keys::FUNCTION) | 75 | self.to_def(src, keys::FUNCTION) |
76 | } | 76 | } |
77 | pub(super) fn struct_to_def(&mut self, src: InFile<ast::StructDef>) -> Option<StructId> { | 77 | pub(super) fn struct_to_def(&mut self, src: InFile<ast::Struct>) -> Option<StructId> { |
78 | self.to_def(src, keys::STRUCT) | 78 | self.to_def(src, keys::STRUCT) |
79 | } | 79 | } |
80 | pub(super) fn enum_to_def(&mut self, src: InFile<ast::EnumDef>) -> Option<EnumId> { | 80 | pub(super) fn enum_to_def(&mut self, src: InFile<ast::Enum>) -> Option<EnumId> { |
81 | self.to_def(src, keys::ENUM) | 81 | self.to_def(src, keys::ENUM) |
82 | } | 82 | } |
83 | pub(super) fn union_to_def(&mut self, src: InFile<ast::UnionDef>) -> Option<UnionId> { | 83 | pub(super) fn union_to_def(&mut self, src: InFile<ast::Union>) -> Option<UnionId> { |
84 | self.to_def(src, keys::UNION) | 84 | self.to_def(src, keys::UNION) |
85 | } | 85 | } |
86 | pub(super) fn static_to_def(&mut self, src: InFile<ast::StaticDef>) -> Option<StaticId> { | 86 | pub(super) fn static_to_def(&mut self, src: InFile<ast::Static>) -> Option<StaticId> { |
87 | self.to_def(src, keys::STATIC) | 87 | self.to_def(src, keys::STATIC) |
88 | } | 88 | } |
89 | pub(super) fn const_to_def(&mut self, src: InFile<ast::ConstDef>) -> Option<ConstId> { | 89 | pub(super) fn const_to_def(&mut self, src: InFile<ast::Const>) -> Option<ConstId> { |
90 | self.to_def(src, keys::CONST) | 90 | self.to_def(src, keys::CONST) |
91 | } | 91 | } |
92 | pub(super) fn type_alias_to_def( | 92 | pub(super) fn type_alias_to_def(&mut self, src: InFile<ast::TypeAlias>) -> Option<TypeAliasId> { |
93 | &mut self, | ||
94 | src: InFile<ast::TypeAliasDef>, | ||
95 | ) -> Option<TypeAliasId> { | ||
96 | self.to_def(src, keys::TYPE_ALIAS) | 93 | self.to_def(src, keys::TYPE_ALIAS) |
97 | } | 94 | } |
98 | pub(super) fn record_field_to_def( | 95 | pub(super) fn record_field_to_def(&mut self, src: InFile<ast::RecordField>) -> Option<FieldId> { |
99 | &mut self, | ||
100 | src: InFile<ast::RecordFieldDef>, | ||
101 | ) -> Option<FieldId> { | ||
102 | self.to_def(src, keys::RECORD_FIELD) | 96 | self.to_def(src, keys::RECORD_FIELD) |
103 | } | 97 | } |
104 | pub(super) fn tuple_field_to_def( | 98 | pub(super) fn tuple_field_to_def(&mut self, src: InFile<ast::TupleField>) -> Option<FieldId> { |
105 | &mut self, | ||
106 | src: InFile<ast::TupleFieldDef>, | ||
107 | ) -> Option<FieldId> { | ||
108 | self.to_def(src, keys::TUPLE_FIELD) | 99 | self.to_def(src, keys::TUPLE_FIELD) |
109 | } | 100 | } |
110 | pub(super) fn enum_variant_to_def( | 101 | pub(super) fn enum_variant_to_def( |
111 | &mut self, | 102 | &mut self, |
112 | src: InFile<ast::EnumVariant>, | 103 | src: InFile<ast::Variant>, |
113 | ) -> Option<EnumVariantId> { | 104 | ) -> Option<EnumVariantId> { |
114 | self.to_def(src, keys::ENUM_VARIANT) | 105 | self.to_def(src, keys::VARIANT) |
115 | } | 106 | } |
116 | pub(super) fn bind_pat_to_def( | 107 | pub(super) fn bind_pat_to_def( |
117 | &mut self, | 108 | &mut self, |
@@ -163,39 +154,39 @@ impl SourceToDefCtx<'_, '_> { | |||
163 | let def = self.module_to_def(container.with_value(it))?; | 154 | let def = self.module_to_def(container.with_value(it))?; |
164 | def.into() | 155 | def.into() |
165 | }, | 156 | }, |
166 | ast::TraitDef(it) => { | 157 | ast::Trait(it) => { |
167 | let def = self.trait_to_def(container.with_value(it))?; | 158 | let def = self.trait_to_def(container.with_value(it))?; |
168 | def.into() | 159 | def.into() |
169 | }, | 160 | }, |
170 | ast::ImplDef(it) => { | 161 | ast::Impl(it) => { |
171 | let def = self.impl_to_def(container.with_value(it))?; | 162 | let def = self.impl_to_def(container.with_value(it))?; |
172 | def.into() | 163 | def.into() |
173 | }, | 164 | }, |
174 | ast::FnDef(it) => { | 165 | ast::Fn(it) => { |
175 | let def = self.fn_to_def(container.with_value(it))?; | 166 | let def = self.fn_to_def(container.with_value(it))?; |
176 | DefWithBodyId::from(def).into() | 167 | DefWithBodyId::from(def).into() |
177 | }, | 168 | }, |
178 | ast::StructDef(it) => { | 169 | ast::Struct(it) => { |
179 | let def = self.struct_to_def(container.with_value(it))?; | 170 | let def = self.struct_to_def(container.with_value(it))?; |
180 | VariantId::from(def).into() | 171 | VariantId::from(def).into() |
181 | }, | 172 | }, |
182 | ast::EnumDef(it) => { | 173 | ast::Enum(it) => { |
183 | let def = self.enum_to_def(container.with_value(it))?; | 174 | let def = self.enum_to_def(container.with_value(it))?; |
184 | def.into() | 175 | def.into() |
185 | }, | 176 | }, |
186 | ast::UnionDef(it) => { | 177 | ast::Union(it) => { |
187 | let def = self.union_to_def(container.with_value(it))?; | 178 | let def = self.union_to_def(container.with_value(it))?; |
188 | VariantId::from(def).into() | 179 | VariantId::from(def).into() |
189 | }, | 180 | }, |
190 | ast::StaticDef(it) => { | 181 | ast::Static(it) => { |
191 | let def = self.static_to_def(container.with_value(it))?; | 182 | let def = self.static_to_def(container.with_value(it))?; |
192 | DefWithBodyId::from(def).into() | 183 | DefWithBodyId::from(def).into() |
193 | }, | 184 | }, |
194 | ast::ConstDef(it) => { | 185 | ast::Const(it) => { |
195 | let def = self.const_to_def(container.with_value(it))?; | 186 | let def = self.const_to_def(container.with_value(it))?; |
196 | DefWithBodyId::from(def).into() | 187 | DefWithBodyId::from(def).into() |
197 | }, | 188 | }, |
198 | ast::TypeAliasDef(it) => { | 189 | ast::TypeAlias(it) => { |
199 | let def = self.type_alias_to_def(container.with_value(it))?; | 190 | let def = self.type_alias_to_def(container.with_value(it))?; |
200 | def.into() | 191 | def.into() |
201 | }, | 192 | }, |
@@ -213,12 +204,12 @@ impl SourceToDefCtx<'_, '_> { | |||
213 | for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { | 204 | for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { |
214 | let res: GenericDefId = match_ast! { | 205 | let res: GenericDefId = match_ast! { |
215 | match (container.value) { | 206 | match (container.value) { |
216 | ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), | 207 | ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(), |
217 | ast::StructDef(it) => self.struct_to_def(container.with_value(it))?.into(), | 208 | ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(), |
218 | ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(), | 209 | ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(), |
219 | ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(), | 210 | ast::Trait(it) => self.trait_to_def(container.with_value(it))?.into(), |
220 | ast::TypeAliasDef(it) => self.type_alias_to_def(container.with_value(it))?.into(), | 211 | ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(), |
221 | ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), | 212 | ast::Impl(it) => self.impl_to_def(container.with_value(it))?.into(), |
222 | _ => continue, | 213 | _ => continue, |
223 | } | 214 | } |
224 | }; | 215 | }; |
@@ -231,9 +222,9 @@ impl SourceToDefCtx<'_, '_> { | |||
231 | for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { | 222 | for container in src.cloned().ancestors_with_macros(self.db.upcast()).skip(1) { |
232 | let res: DefWithBodyId = match_ast! { | 223 | let res: DefWithBodyId = match_ast! { |
233 | match (container.value) { | 224 | match (container.value) { |
234 | ast::ConstDef(it) => self.const_to_def(container.with_value(it))?.into(), | 225 | ast::Const(it) => self.const_to_def(container.with_value(it))?.into(), |
235 | ast::StaticDef(it) => self.static_to_def(container.with_value(it))?.into(), | 226 | ast::Static(it) => self.static_to_def(container.with_value(it))?.into(), |
236 | ast::FnDef(it) => self.fn_to_def(container.with_value(it))?.into(), | 227 | ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(), |
237 | _ => continue, | 228 | _ => continue, |
238 | } | 229 | } |
239 | }; | 230 | }; |
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 86a47a9e5..f2e630ef1 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs | |||
@@ -159,7 +159,7 @@ impl SourceAnalyzer { | |||
159 | pub(crate) fn resolve_record_field( | 159 | pub(crate) fn resolve_record_field( |
160 | &self, | 160 | &self, |
161 | db: &dyn HirDatabase, | 161 | db: &dyn HirDatabase, |
162 | field: &ast::RecordField, | 162 | field: &ast::RecordExprField, |
163 | ) -> Option<(Field, Option<Local>)> { | 163 | ) -> Option<(Field, Option<Local>)> { |
164 | let expr = field.expr()?; | 164 | let expr = field.expr()?; |
165 | let expr_id = self.expr_id(db, &expr)?; | 165 | let expr_id = self.expr_id(db, &expr)?; |
@@ -246,7 +246,7 @@ impl SourceAnalyzer { | |||
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordLit::cast) { | 249 | if let Some(rec_lit) = path.syntax().parent().and_then(ast::RecordExpr::cast) { |
250 | let expr_id = self.expr_id(db, &rec_lit.into())?; | 250 | let expr_id = self.expr_id(db, &rec_lit.into())?; |
251 | if let Some(VariantId::EnumVariantId(variant)) = | 251 | if let Some(VariantId::EnumVariantId(variant)) = |
252 | self.infer.as_ref()?.variant_resolution_for_expr(expr_id) | 252 | self.infer.as_ref()?.variant_resolution_for_expr(expr_id) |
@@ -284,7 +284,7 @@ impl SourceAnalyzer { | |||
284 | pub(crate) fn record_literal_missing_fields( | 284 | pub(crate) fn record_literal_missing_fields( |
285 | &self, | 285 | &self, |
286 | db: &dyn HirDatabase, | 286 | db: &dyn HirDatabase, |
287 | literal: &ast::RecordLit, | 287 | literal: &ast::RecordExpr, |
288 | ) -> Option<Vec<(Field, Type)>> { | 288 | ) -> Option<Vec<(Field, Type)>> { |
289 | let krate = self.resolver.krate()?; | 289 | let krate = self.resolver.krate()?; |
290 | let body = self.body.as_ref()?; | 290 | let body = self.body.as_ref()?; |
@@ -358,7 +358,7 @@ impl SourceAnalyzer { | |||
358 | pub(crate) fn resolve_variant( | 358 | pub(crate) fn resolve_variant( |
359 | &self, | 359 | &self, |
360 | db: &dyn HirDatabase, | 360 | db: &dyn HirDatabase, |
361 | record_lit: ast::RecordLit, | 361 | record_lit: ast::RecordExpr, |
362 | ) -> Option<VariantId> { | 362 | ) -> Option<VariantId> { |
363 | let infer = self.infer.as_ref()?; | 363 | let infer = self.infer.as_ref()?; |
364 | let expr_id = self.expr_id(db, &record_lit.into())?; | 364 | let expr_id = self.expr_id(db, &record_lit.into())?; |
@@ -405,8 +405,7 @@ fn scope_for_offset( | |||
405 | ) | 405 | ) |
406 | }) | 406 | }) |
407 | .map(|(expr_range, scope)| { | 407 | .map(|(expr_range, scope)| { |
408 | adjust(db, scopes, source_map, expr_range, offset.file_id, offset.value) | 408 | adjust(db, scopes, source_map, expr_range, offset).unwrap_or(*scope) |
409 | .unwrap_or(*scope) | ||
410 | }) | 409 | }) |
411 | } | 410 | } |
412 | 411 | ||
@@ -417,8 +416,7 @@ fn adjust( | |||
417 | scopes: &ExprScopes, | 416 | scopes: &ExprScopes, |
418 | source_map: &BodySourceMap, | 417 | source_map: &BodySourceMap, |
419 | expr_range: TextRange, | 418 | expr_range: TextRange, |
420 | file_id: HirFileId, | 419 | offset: InFile<TextSize>, |
421 | offset: TextSize, | ||
422 | ) -> Option<ScopeId> { | 420 | ) -> Option<ScopeId> { |
423 | let child_scopes = scopes | 421 | let child_scopes = scopes |
424 | .scope_by_expr() | 422 | .scope_by_expr() |
@@ -426,7 +424,7 @@ fn adjust( | |||
426 | .filter_map(|(id, scope)| { | 424 | .filter_map(|(id, scope)| { |
427 | let source = source_map.expr_syntax(*id).ok()?; | 425 | let source = source_map.expr_syntax(*id).ok()?; |
428 | // FIXME: correctly handle macro expansion | 426 | // FIXME: correctly handle macro expansion |
429 | if source.file_id != file_id { | 427 | if source.file_id != offset.file_id { |
430 | return None; | 428 | return None; |
431 | } | 429 | } |
432 | let root = source.file_syntax(db.upcast()); | 430 | let root = source.file_syntax(db.upcast()); |
@@ -434,7 +432,7 @@ fn adjust( | |||
434 | Some((node.syntax().text_range(), scope)) | 432 | Some((node.syntax().text_range(), scope)) |
435 | }) | 433 | }) |
436 | .filter(|&(range, _)| { | 434 | .filter(|&(range, _)| { |
437 | range.start() <= offset && expr_range.contains_range(range) && range != expr_range | 435 | range.start() <= offset.value && expr_range.contains_range(range) && range != expr_range |
438 | }); | 436 | }); |
439 | 437 | ||
440 | child_scopes | 438 | child_scopes |
diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 4994a2125..6cb56a1cd 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs | |||
@@ -8,7 +8,7 @@ use hir_expand::{ | |||
8 | InFile, | 8 | InFile, |
9 | }; | 9 | }; |
10 | use ra_arena::{map::ArenaMap, Arena}; | 10 | use ra_arena::{map::ArenaMap, Arena}; |
11 | use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner, VisibilityOwner}; | 11 | use ra_syntax::ast::{self, NameOwner, VisibilityOwner}; |
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | body::{CfgExpander, LowerCtx}, | 14 | body::{CfgExpander, LowerCtx}, |
@@ -112,7 +112,7 @@ impl EnumData { | |||
112 | 112 | ||
113 | impl HasChildSource for EnumId { | 113 | impl HasChildSource for EnumId { |
114 | type ChildId = LocalEnumVariantId; | 114 | type ChildId = LocalEnumVariantId; |
115 | type Value = ast::EnumVariant; | 115 | type Value = ast::Variant; |
116 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { | 116 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { |
117 | let src = self.lookup(db).source(db); | 117 | let src = self.lookup(db).source(db); |
118 | let mut trace = Trace::new_for_map(); | 118 | let mut trace = Trace::new_for_map(); |
@@ -123,8 +123,8 @@ impl HasChildSource for EnumId { | |||
123 | 123 | ||
124 | fn lower_enum( | 124 | fn lower_enum( |
125 | db: &dyn DefDatabase, | 125 | db: &dyn DefDatabase, |
126 | trace: &mut Trace<EnumVariantData, ast::EnumVariant>, | 126 | trace: &mut Trace<EnumVariantData, ast::Variant>, |
127 | ast: &InFile<ast::EnumDef>, | 127 | ast: &InFile<ast::Enum>, |
128 | module_id: ModuleId, | 128 | module_id: ModuleId, |
129 | ) { | 129 | ) { |
130 | let expander = CfgExpander::new(db, ast.file_id, module_id.krate); | 130 | let expander = CfgExpander::new(db, ast.file_id, module_id.krate); |
@@ -179,7 +179,7 @@ impl VariantData { | |||
179 | 179 | ||
180 | impl HasChildSource for VariantId { | 180 | impl HasChildSource for VariantId { |
181 | type ChildId = LocalFieldId; | 181 | type ChildId = LocalFieldId; |
182 | type Value = Either<ast::TupleFieldDef, ast::RecordFieldDef>; | 182 | type Value = Either<ast::TupleField, ast::RecordField>; |
183 | 183 | ||
184 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { | 184 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<ArenaMap<Self::ChildId, Self::Value>> { |
185 | let (src, module_id) = match self { | 185 | let (src, module_id) = match self { |
@@ -194,7 +194,7 @@ impl HasChildSource for VariantId { | |||
194 | } | 194 | } |
195 | VariantId::UnionId(it) => ( | 195 | VariantId::UnionId(it) => ( |
196 | it.lookup(db).source(db).map(|it| { | 196 | it.lookup(db).source(db).map(|it| { |
197 | it.record_field_def_list() | 197 | it.record_field_list() |
198 | .map(ast::StructKind::Record) | 198 | .map(ast::StructKind::Record) |
199 | .unwrap_or(ast::StructKind::Unit) | 199 | .unwrap_or(ast::StructKind::Unit) |
200 | }), | 200 | }), |
@@ -218,7 +218,7 @@ pub enum StructKind { | |||
218 | fn lower_struct( | 218 | fn lower_struct( |
219 | db: &dyn DefDatabase, | 219 | db: &dyn DefDatabase, |
220 | expander: &mut CfgExpander, | 220 | expander: &mut CfgExpander, |
221 | trace: &mut Trace<FieldData, Either<ast::TupleFieldDef, ast::RecordFieldDef>>, | 221 | trace: &mut Trace<FieldData, Either<ast::TupleField, ast::RecordField>>, |
222 | ast: &InFile<ast::StructKind>, | 222 | ast: &InFile<ast::StructKind>, |
223 | ) -> StructKind { | 223 | ) -> StructKind { |
224 | let ctx = LowerCtx::new(db, ast.file_id); | 224 | let ctx = LowerCtx::new(db, ast.file_id); |
@@ -234,7 +234,7 @@ fn lower_struct( | |||
234 | || Either::Left(fd.clone()), | 234 | || Either::Left(fd.clone()), |
235 | || FieldData { | 235 | || FieldData { |
236 | name: Name::new_tuple_field(i), | 236 | name: Name::new_tuple_field(i), |
237 | type_ref: TypeRef::from_ast_opt(&ctx, fd.type_ref()), | 237 | type_ref: TypeRef::from_ast_opt(&ctx, fd.ty()), |
238 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 238 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
239 | }, | 239 | }, |
240 | ); | 240 | ); |
@@ -251,7 +251,7 @@ fn lower_struct( | |||
251 | || Either::Right(fd.clone()), | 251 | || Either::Right(fd.clone()), |
252 | || FieldData { | 252 | || FieldData { |
253 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), | 253 | name: fd.name().map(|n| n.as_name()).unwrap_or_else(Name::missing), |
254 | type_ref: TypeRef::from_ast_opt(&ctx, fd.ascribed_type()), | 254 | type_ref: TypeRef::from_ast_opt(&ctx, fd.ty()), |
255 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), | 255 | visibility: RawVisibility::from_ast(db, ast.with_value(fd.visibility())), |
256 | }, | 256 | }, |
257 | ); | 257 | ); |
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 70ccd4305..050832ce0 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -151,18 +151,15 @@ pub enum AttrInput { | |||
151 | impl Attr { | 151 | impl Attr { |
152 | fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> { | 152 | fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> { |
153 | let path = ModPath::from_src(ast.path()?, hygiene)?; | 153 | let path = ModPath::from_src(ast.path()?, hygiene)?; |
154 | let input = match ast.input() { | 154 | let input = if let Some(lit) = ast.literal() { |
155 | None => None, | 155 | // FIXME: escape? raw string? |
156 | Some(ast::AttrInput::Literal(lit)) => { | 156 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); |
157 | // FIXME: escape? raw string? | 157 | Some(AttrInput::Literal(value)) |
158 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); | 158 | } else if let Some(tt) = ast.token_tree() { |
159 | Some(AttrInput::Literal(value)) | 159 | Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0)) |
160 | } | 160 | } else { |
161 | Some(ast::AttrInput::TokenTree(tt)) => { | 161 | None |
162 | Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0)) | ||
163 | } | ||
164 | }; | 162 | }; |
165 | |||
166 | Some(Attr { path, input }) | 163 | Some(Attr { path, input }) |
167 | } | 164 | } |
168 | } | 165 | } |
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 2fe04db2b..d5f18b920 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -216,7 +216,7 @@ pub struct BodySourceMap { | |||
216 | expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>, | 216 | expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>, |
217 | pat_map: FxHashMap<PatSource, PatId>, | 217 | pat_map: FxHashMap<PatSource, PatId>, |
218 | pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>, | 218 | pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>, |
219 | field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordField>>>, | 219 | field_map: FxHashMap<(ExprId, usize), InFile<AstPtr<ast::RecordExprField>>>, |
220 | expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, | 220 | expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, |
221 | } | 221 | } |
222 | 222 | ||
@@ -314,7 +314,7 @@ impl BodySourceMap { | |||
314 | self.pat_map.get(&src).cloned() | 314 | self.pat_map.get(&src).cloned() |
315 | } | 315 | } |
316 | 316 | ||
317 | pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordField>> { | 317 | pub fn field_syntax(&self, expr: ExprId, field: usize) -> InFile<AstPtr<ast::RecordExprField>> { |
318 | self.field_map[&(expr, field)].clone() | 318 | self.field_map[&(expr, field)].clone() |
319 | } | 319 | } |
320 | } | 320 | } |
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index c6bc85e2f..827ced4ad 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -11,7 +11,7 @@ use ra_arena::Arena; | |||
11 | use ra_syntax::{ | 11 | use ra_syntax::{ |
12 | ast::{ | 12 | ast::{ |
13 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner, | 13 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner, |
14 | SlicePatComponents, TypeAscriptionOwner, | 14 | SlicePatComponents, |
15 | }, | 15 | }, |
16 | AstNode, AstPtr, | 16 | AstNode, AstPtr, |
17 | }; | 17 | }; |
@@ -379,10 +379,10 @@ impl ExprCollector<'_> { | |||
379 | let expr = e.expr().map(|e| self.collect_expr(e)); | 379 | let expr = e.expr().map(|e| self.collect_expr(e)); |
380 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) | 380 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) |
381 | } | 381 | } |
382 | ast::Expr::RecordLit(e) => { | 382 | ast::Expr::RecordExpr(e) => { |
383 | let path = e.path().and_then(|path| self.expander.parse_path(path)); | 383 | let path = e.path().and_then(|path| self.expander.parse_path(path)); |
384 | let mut field_ptrs = Vec::new(); | 384 | let mut field_ptrs = Vec::new(); |
385 | let record_lit = if let Some(nfl) = e.record_field_list() { | 385 | let record_lit = if let Some(nfl) = e.record_expr_field_list() { |
386 | let fields = nfl | 386 | let fields = nfl |
387 | .fields() | 387 | .fields() |
388 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) | 388 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) |
@@ -432,7 +432,7 @@ impl ExprCollector<'_> { | |||
432 | } | 432 | } |
433 | ast::Expr::CastExpr(e) => { | 433 | ast::Expr::CastExpr(e) => { |
434 | let expr = self.collect_expr_opt(e.expr()); | 434 | let expr = self.collect_expr_opt(e.expr()); |
435 | let type_ref = TypeRef::from_ast_opt(&self.ctx(), e.type_ref()); | 435 | let type_ref = TypeRef::from_ast_opt(&self.ctx(), e.ty()); |
436 | self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr) | 436 | self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr) |
437 | } | 437 | } |
438 | ast::Expr::RefExpr(e) => { | 438 | ast::Expr::RefExpr(e) => { |
@@ -466,16 +466,13 @@ impl ExprCollector<'_> { | |||
466 | if let Some(pl) = e.param_list() { | 466 | if let Some(pl) = e.param_list() { |
467 | for param in pl.params() { | 467 | for param in pl.params() { |
468 | let pat = self.collect_pat_opt(param.pat()); | 468 | let pat = self.collect_pat_opt(param.pat()); |
469 | let type_ref = | 469 | let type_ref = param.ty().map(|it| TypeRef::from_ast(&self.ctx(), it)); |
470 | param.ascribed_type().map(|it| TypeRef::from_ast(&self.ctx(), it)); | ||
471 | args.push(pat); | 470 | args.push(pat); |
472 | arg_types.push(type_ref); | 471 | arg_types.push(type_ref); |
473 | } | 472 | } |
474 | } | 473 | } |
475 | let ret_type = e | 474 | let ret_type = |
476 | .ret_type() | 475 | e.ret_type().and_then(|r| r.ty()).map(|it| TypeRef::from_ast(&self.ctx(), it)); |
477 | .and_then(|r| r.type_ref()) | ||
478 | .map(|it| TypeRef::from_ast(&self.ctx(), it)); | ||
479 | let body = self.collect_expr_opt(e.body()); | 476 | let body = self.collect_expr_opt(e.body()); |
480 | self.alloc_expr(Expr::Lambda { args, arg_types, ret_type, body }, syntax_ptr) | 477 | self.alloc_expr(Expr::Lambda { args, arg_types, ret_type, body }, syntax_ptr) |
481 | } | 478 | } |
@@ -607,8 +604,7 @@ impl ExprCollector<'_> { | |||
607 | .map(|s| match s { | 604 | .map(|s| match s { |
608 | ast::Stmt::LetStmt(stmt) => { | 605 | ast::Stmt::LetStmt(stmt) => { |
609 | let pat = self.collect_pat_opt(stmt.pat()); | 606 | let pat = self.collect_pat_opt(stmt.pat()); |
610 | let type_ref = | 607 | let type_ref = stmt.ty().map(|it| TypeRef::from_ast(&self.ctx(), it)); |
611 | stmt.ascribed_type().map(|it| TypeRef::from_ast(&self.ctx(), it)); | ||
612 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); | 608 | let initializer = stmt.initializer().map(|e| self.collect_expr(e)); |
613 | Statement::Let { pat, type_ref, initializer } | 609 | Statement::Let { pat, type_ref, initializer } |
614 | } | 610 | } |
@@ -627,53 +623,53 @@ impl ExprCollector<'_> { | |||
627 | .items() | 623 | .items() |
628 | .filter_map(|item| { | 624 | .filter_map(|item| { |
629 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { | 625 | let (def, name): (ModuleDefId, Option<ast::Name>) = match item { |
630 | ast::ModuleItem::FnDef(def) => { | 626 | ast::Item::Fn(def) => { |
631 | let id = self.find_inner_item(&def)?; | 627 | let id = self.find_inner_item(&def)?; |
632 | ( | 628 | ( |
633 | FunctionLoc { container: container.into(), id }.intern(self.db).into(), | 629 | FunctionLoc { container: container.into(), id }.intern(self.db).into(), |
634 | def.name(), | 630 | def.name(), |
635 | ) | 631 | ) |
636 | } | 632 | } |
637 | ast::ModuleItem::TypeAliasDef(def) => { | 633 | ast::Item::TypeAlias(def) => { |
638 | let id = self.find_inner_item(&def)?; | 634 | let id = self.find_inner_item(&def)?; |
639 | ( | 635 | ( |
640 | TypeAliasLoc { container: container.into(), id }.intern(self.db).into(), | 636 | TypeAliasLoc { container: container.into(), id }.intern(self.db).into(), |
641 | def.name(), | 637 | def.name(), |
642 | ) | 638 | ) |
643 | } | 639 | } |
644 | ast::ModuleItem::ConstDef(def) => { | 640 | ast::Item::Const(def) => { |
645 | let id = self.find_inner_item(&def)?; | 641 | let id = self.find_inner_item(&def)?; |
646 | ( | 642 | ( |
647 | ConstLoc { container: container.into(), id }.intern(self.db).into(), | 643 | ConstLoc { container: container.into(), id }.intern(self.db).into(), |
648 | def.name(), | 644 | def.name(), |
649 | ) | 645 | ) |
650 | } | 646 | } |
651 | ast::ModuleItem::StaticDef(def) => { | 647 | ast::Item::Static(def) => { |
652 | let id = self.find_inner_item(&def)?; | 648 | let id = self.find_inner_item(&def)?; |
653 | (StaticLoc { container, id }.intern(self.db).into(), def.name()) | 649 | (StaticLoc { container, id }.intern(self.db).into(), def.name()) |
654 | } | 650 | } |
655 | ast::ModuleItem::StructDef(def) => { | 651 | ast::Item::Struct(def) => { |
656 | let id = self.find_inner_item(&def)?; | 652 | let id = self.find_inner_item(&def)?; |
657 | (StructLoc { container, id }.intern(self.db).into(), def.name()) | 653 | (StructLoc { container, id }.intern(self.db).into(), def.name()) |
658 | } | 654 | } |
659 | ast::ModuleItem::EnumDef(def) => { | 655 | ast::Item::Enum(def) => { |
660 | let id = self.find_inner_item(&def)?; | 656 | let id = self.find_inner_item(&def)?; |
661 | (EnumLoc { container, id }.intern(self.db).into(), def.name()) | 657 | (EnumLoc { container, id }.intern(self.db).into(), def.name()) |
662 | } | 658 | } |
663 | ast::ModuleItem::UnionDef(def) => { | 659 | ast::Item::Union(def) => { |
664 | let id = self.find_inner_item(&def)?; | 660 | let id = self.find_inner_item(&def)?; |
665 | (UnionLoc { container, id }.intern(self.db).into(), def.name()) | 661 | (UnionLoc { container, id }.intern(self.db).into(), def.name()) |
666 | } | 662 | } |
667 | ast::ModuleItem::TraitDef(def) => { | 663 | ast::Item::Trait(def) => { |
668 | let id = self.find_inner_item(&def)?; | 664 | let id = self.find_inner_item(&def)?; |
669 | (TraitLoc { container, id }.intern(self.db).into(), def.name()) | 665 | (TraitLoc { container, id }.intern(self.db).into(), def.name()) |
670 | } | 666 | } |
671 | ast::ModuleItem::ExternBlock(_) => return None, // FIXME: collect from extern blocks | 667 | ast::Item::ExternBlock(_) => return None, // FIXME: collect from extern blocks |
672 | ast::ModuleItem::ImplDef(_) | 668 | ast::Item::Impl(_) |
673 | | ast::ModuleItem::UseItem(_) | 669 | | ast::Item::Use(_) |
674 | | ast::ModuleItem::ExternCrateItem(_) | 670 | | ast::Item::ExternCrate(_) |
675 | | ast::ModuleItem::Module(_) | 671 | | ast::Item::Module(_) |
676 | | ast::ModuleItem::MacroCall(_) => return None, | 672 | | ast::Item::MacroCall(_) => return None, |
677 | }; | 673 | }; |
678 | 674 | ||
679 | Some((def, name)) | 675 | Some((def, name)) |
diff --git a/crates/ra_hir_def/src/child_by_source.rs b/crates/ra_hir_def/src/child_by_source.rs index a885ec96d..dcb00a1d9 100644 --- a/crates/ra_hir_def/src/child_by_source.rs +++ b/crates/ra_hir_def/src/child_by_source.rs | |||
@@ -162,7 +162,7 @@ impl ChildBySource for EnumId { | |||
162 | let arena_map = arena_map.as_ref(); | 162 | let arena_map = arena_map.as_ref(); |
163 | for (local_id, source) in arena_map.value.iter() { | 163 | for (local_id, source) in arena_map.value.iter() { |
164 | let id = EnumVariantId { parent: *self, local_id }; | 164 | let id = EnumVariantId { parent: *self, local_id }; |
165 | res[keys::ENUM_VARIANT].insert(arena_map.with_value(source.clone()), id) | 165 | res[keys::VARIANT].insert(arena_map.with_value(source.clone()), id) |
166 | } | 166 | } |
167 | 167 | ||
168 | res | 168 | res |
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index 6a0f493a7..be0b45af3 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs | |||
@@ -12,7 +12,7 @@ use hir_expand::{ | |||
12 | use ra_arena::{map::ArenaMap, Arena}; | 12 | use ra_arena::{map::ArenaMap, Arena}; |
13 | use ra_db::FileId; | 13 | use ra_db::FileId; |
14 | use ra_prof::profile; | 14 | use ra_prof::profile; |
15 | use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner}; | 15 | use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; |
16 | 16 | ||
17 | use crate::{ | 17 | use crate::{ |
18 | body::LowerCtx, | 18 | body::LowerCtx, |
@@ -66,7 +66,7 @@ pub enum WherePredicateTarget { | |||
66 | TypeParam(LocalTypeParamId), | 66 | TypeParam(LocalTypeParamId), |
67 | } | 67 | } |
68 | 68 | ||
69 | type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>; | 69 | type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::Trait, ast::TypeParam>>; |
70 | 70 | ||
71 | impl GenericParams { | 71 | impl GenericParams { |
72 | pub(crate) fn generic_params_query( | 72 | pub(crate) fn generic_params_query( |
@@ -205,9 +205,9 @@ impl GenericParams { | |||
205 | &mut self, | 205 | &mut self, |
206 | lower_ctx: &LowerCtx, | 206 | lower_ctx: &LowerCtx, |
207 | sm: &mut SourceMap, | 207 | sm: &mut SourceMap, |
208 | node: &dyn TypeParamsOwner, | 208 | node: &dyn GenericParamsOwner, |
209 | ) { | 209 | ) { |
210 | if let Some(params) = node.type_param_list() { | 210 | if let Some(params) = node.generic_param_list() { |
211 | self.fill_params(lower_ctx, sm, params) | 211 | self.fill_params(lower_ctx, sm, params) |
212 | } | 212 | } |
213 | if let Some(where_clause) = node.where_clause() { | 213 | if let Some(where_clause) = node.where_clause() { |
@@ -232,7 +232,7 @@ impl GenericParams { | |||
232 | &mut self, | 232 | &mut self, |
233 | lower_ctx: &LowerCtx, | 233 | lower_ctx: &LowerCtx, |
234 | sm: &mut SourceMap, | 234 | sm: &mut SourceMap, |
235 | params: ast::TypeParamList, | 235 | params: ast::GenericParamList, |
236 | ) { | 236 | ) { |
237 | for type_param in params.type_params() { | 237 | for type_param in params.type_params() { |
238 | let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); | 238 | let name = type_param.name().map_or_else(Name::missing, |it| it.as_name()); |
@@ -253,7 +253,7 @@ impl GenericParams { | |||
253 | 253 | ||
254 | fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) { | 254 | fn fill_where_predicates(&mut self, lower_ctx: &LowerCtx, where_clause: ast::WhereClause) { |
255 | for pred in where_clause.predicates() { | 255 | for pred in where_clause.predicates() { |
256 | let type_ref = match pred.type_ref() { | 256 | let type_ref = match pred.ty() { |
257 | Some(type_ref) => type_ref, | 257 | Some(type_ref) => type_ref, |
258 | None => continue, | 258 | None => continue, |
259 | }; | 259 | }; |
@@ -317,7 +317,7 @@ impl GenericParams { | |||
317 | 317 | ||
318 | impl HasChildSource for GenericDefId { | 318 | impl HasChildSource for GenericDefId { |
319 | type ChildId = LocalTypeParamId; | 319 | type ChildId = LocalTypeParamId; |
320 | type Value = Either<ast::TraitDef, ast::TypeParam>; | 320 | type Value = Either<ast::Trait, ast::TypeParam>; |
321 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<SourceMap> { | 321 | fn child_source(&self, db: &dyn DefDatabase) -> InFile<SourceMap> { |
322 | let (_, sm) = GenericParams::new(db, *self); | 322 | let (_, sm) = GenericParams::new(db, *self); |
323 | sm | 323 | sm |
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index da79d8ffd..a67e75dac 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs | |||
@@ -13,7 +13,7 @@ use std::{ | |||
13 | sync::Arc, | 13 | sync::Arc, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | use ast::{AstNode, AttrsOwner, NameOwner, StructKind, TypeAscriptionOwner}; | 16 | use ast::{AstNode, AttrsOwner, NameOwner, StructKind}; |
17 | use either::Either; |