diff options
-rw-r--r-- | Cargo.lock | 93 | ||||
-rw-r--r-- | bors.toml | 1 | ||||
-rw-r--r-- | crates/assists/src/handlers/merge_imports.rs | 14 | ||||
-rw-r--r-- | crates/assists/src/handlers/replace_qualified_name_with_use.rs | 19 | ||||
-rw-r--r-- | crates/assists/src/utils/insert_use.rs | 59 | ||||
-rw-r--r-- | crates/base_db/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/flycheck/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ide/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/ide/src/doc_links.rs | 25 | ||||
-rw-r--r-- | crates/proc_macro_api/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/vfs-notify/Cargo.toml | 2 | ||||
-rw-r--r-- | docs/dev/lsp-extensions.md | 10 | ||||
-rw-r--r-- | editors/code/src/commands.ts | 4 | ||||
-rw-r--r-- | xtask/tests/tidy.rs | 45 |
16 files changed, 227 insertions, 61 deletions
diff --git a/Cargo.lock b/Cargo.lock index 320f70529..d470d84f2 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -1,6 +1,5 @@ | |||
1 | # This file is automatically @generated by Cargo. | 1 | # This file is automatically @generated by Cargo. |
2 | # It is not intended for manual editing. | 2 | # It is not intended for manual editing. |
3 | # asdasdasdasd | ||
4 | [[package]] | 3 | [[package]] |
5 | name = "addr2line" | 4 | name = "addr2line" |
6 | version = "0.13.0" | 5 | version = "0.13.0" |
@@ -130,9 +129,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" | |||
130 | 129 | ||
131 | [[package]] | 130 | [[package]] |
132 | name = "cargo_metadata" | 131 | name = "cargo_metadata" |
133 | version = "0.11.3" | 132 | version = "0.11.4" |
134 | source = "registry+https://github.com/rust-lang/crates.io-index" | 133 | source = "registry+https://github.com/rust-lang/crates.io-index" |
135 | checksum = "e708746e51dfaeff27c6c3979a4005a7faddabe40144204a0b1ce5ad34a1d0a5" | 134 | checksum = "a3a567c24b86754d629addc2db89e340ac9398d07b5875efcff837e3878e17ec" |
136 | dependencies = [ | 135 | dependencies = [ |
137 | "semver", | 136 | "semver", |
138 | "serde", | 137 | "serde", |
@@ -251,6 +250,12 @@ dependencies = [ | |||
251 | ] | 250 | ] |
252 | 251 | ||
253 | [[package]] | 252 | [[package]] |
253 | name = "const_fn" | ||
254 | version = "0.4.2" | ||
255 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
256 | checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2" | ||
257 | |||
258 | [[package]] | ||
254 | name = "crc32fast" | 259 | name = "crc32fast" |
255 | version = "1.2.0" | 260 | version = "1.2.0" |
256 | source = "registry+https://github.com/rust-lang/crates.io-index" | 261 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -265,18 +270,28 @@ version = "0.4.4" | |||
265 | source = "registry+https://github.com/rust-lang/crates.io-index" | 270 | source = "registry+https://github.com/rust-lang/crates.io-index" |
266 | checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" | 271 | checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" |
267 | dependencies = [ | 272 | dependencies = [ |
268 | "crossbeam-utils", | 273 | "crossbeam-utils 0.7.2", |
269 | "maybe-uninit", | 274 | "maybe-uninit", |
270 | ] | 275 | ] |
271 | 276 | ||
272 | [[package]] | 277 | [[package]] |
278 | name = "crossbeam-channel" | ||
279 | version = "0.5.0" | ||
280 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
281 | checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" | ||
282 | dependencies = [ | ||
283 | "cfg-if 1.0.0", | ||
284 | "crossbeam-utils 0.8.0", | ||
285 | ] | ||
286 | |||
287 | [[package]] | ||
273 | name = "crossbeam-deque" | 288 | name = "crossbeam-deque" |
274 | version = "0.7.3" | 289 | version = "0.7.3" |
275 | source = "registry+https://github.com/rust-lang/crates.io-index" | 290 | source = "registry+https://github.com/rust-lang/crates.io-index" |
276 | checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" | 291 | checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" |
277 | dependencies = [ | 292 | dependencies = [ |
278 | "crossbeam-epoch", | 293 | "crossbeam-epoch", |
279 | "crossbeam-utils", | 294 | "crossbeam-utils 0.7.2", |
280 | "maybe-uninit", | 295 | "maybe-uninit", |
281 | ] | 296 | ] |
282 | 297 | ||
@@ -288,7 +303,7 @@ checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" | |||
288 | dependencies = [ | 303 | dependencies = [ |
289 | "autocfg", | 304 | "autocfg", |
290 | "cfg-if 0.1.10", | 305 | "cfg-if 0.1.10", |
291 | "crossbeam-utils", | 306 | "crossbeam-utils 0.7.2", |
292 | "lazy_static", | 307 | "lazy_static", |
293 | "maybe-uninit", | 308 | "maybe-uninit", |
294 | "memoffset", | 309 | "memoffset", |
@@ -307,6 +322,18 @@ dependencies = [ | |||
307 | ] | 322 | ] |
308 | 323 | ||
309 | [[package]] | 324 | [[package]] |
325 | name = "crossbeam-utils" | ||
326 | version = "0.8.0" | ||
327 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
328 | checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" | ||
329 | dependencies = [ | ||
330 | "autocfg", | ||
331 | "cfg-if 1.0.0", | ||
332 | "const_fn", | ||
333 | "lazy_static", | ||
334 | ] | ||
335 | |||
336 | [[package]] | ||
310 | name = "difference" | 337 | name = "difference" |
311 | version = "2.0.0" | 338 | version = "2.0.0" |
312 | source = "registry+https://github.com/rust-lang/crates.io-index" | 339 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -387,7 +414,7 @@ name = "flycheck" | |||
387 | version = "0.0.0" | 414 | version = "0.0.0" |
388 | dependencies = [ | 415 | dependencies = [ |
389 | "cargo_metadata", | 416 | "cargo_metadata", |
390 | "crossbeam-channel", | 417 | "crossbeam-channel 0.5.0", |
391 | "jod-thread", | 418 | "jod-thread", |
392 | "log", | 419 | "log", |
393 | "serde_json", | 420 | "serde_json", |
@@ -775,11 +802,11 @@ dependencies = [ | |||
775 | 802 | ||
776 | [[package]] | 803 | [[package]] |
777 | name = "lsp-server" | 804 | name = "lsp-server" |
778 | version = "0.3.4" | 805 | version = "0.4.0" |
779 | source = "registry+https://github.com/rust-lang/crates.io-index" | 806 | source = "registry+https://github.com/rust-lang/crates.io-index" |
780 | checksum = "87fce8851309a325974ec76efe7c9d954d152c9ff4fded6520eb3c96d0aa3a96" | 807 | checksum = "ff7452ee21b8de64f10ceb4e9fee1212e1a9579cd717226613333e751676c86a" |
781 | dependencies = [ | 808 | dependencies = [ |
782 | "crossbeam-channel", | 809 | "crossbeam-channel 0.5.0", |
783 | "log", | 810 | "log", |
784 | "serde", | 811 | "serde", |
785 | "serde_json", | 812 | "serde_json", |
@@ -939,7 +966,7 @@ checksum = "77d03607cf88b4b160ba0e9ed425fff3cee3b55ac813f0c685b3a3772da37d0e" | |||
939 | dependencies = [ | 966 | dependencies = [ |
940 | "anymap", | 967 | "anymap", |
941 | "bitflags", | 968 | "bitflags", |
942 | "crossbeam-channel", | 969 | "crossbeam-channel 0.4.4", |
943 | "filetime", | 970 | "filetime", |
944 | "fsevent", | 971 | "fsevent", |
945 | "fsevent-sys", | 972 | "fsevent-sys", |
@@ -1101,7 +1128,7 @@ dependencies = [ | |||
1101 | name = "proc_macro_api" | 1128 | name = "proc_macro_api" |
1102 | version = "0.0.0" | 1129 | version = "0.0.0" |
1103 | dependencies = [ | 1130 | dependencies = [ |
1104 | "crossbeam-channel", | 1131 | "crossbeam-channel 0.5.0", |
1105 | "jod-thread", | 1132 | "jod-thread", |
1106 | "log", | 1133 | "log", |
1107 | "serde", | 1134 | "serde", |
@@ -1164,9 +1191,9 @@ dependencies = [ | |||
1164 | 1191 | ||
1165 | [[package]] | 1192 | [[package]] |
1166 | name = "pulldown-cmark" | 1193 | name = "pulldown-cmark" |
1167 | version = "0.7.2" | 1194 | version = "0.8.0" |
1168 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1169 | checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55" | 1196 | checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" |
1170 | dependencies = [ | 1197 | dependencies = [ |
1171 | "bitflags", | 1198 | "bitflags", |
1172 | "memchr", | 1199 | "memchr", |
@@ -1175,9 +1202,9 @@ dependencies = [ | |||
1175 | 1202 | ||
1176 | [[package]] | 1203 | [[package]] |
1177 | name = "pulldown-cmark-to-cmark" | 1204 | name = "pulldown-cmark-to-cmark" |
1178 | version = "5.0.0" | 1205 | version = "6.0.0" |
1179 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1206 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1180 | checksum = "32accf4473121d8c0b508ca5673363703762d6cc59cf25af1df48f653346f736" | 1207 | checksum = "e8f2b9878102358ec65434fdd1a9a161f8648bb2f531acc9260e4d094c96de23" |
1181 | dependencies = [ | 1208 | dependencies = [ |
1182 | "pulldown-cmark", | 1209 | "pulldown-cmark", |
1183 | ] | 1210 | ] |
@@ -1209,9 +1236,9 @@ version = "1.8.1" | |||
1209 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1236 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1210 | checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf" | 1237 | checksum = "e8c4fec834fb6e6d2dd5eece3c7b432a52f0ba887cf40e595190c4107edc08bf" |
1211 | dependencies = [ | 1238 | dependencies = [ |
1212 | "crossbeam-channel", | 1239 | "crossbeam-channel 0.4.4", |
1213 | "crossbeam-deque", | 1240 | "crossbeam-deque", |
1214 | "crossbeam-utils", | 1241 | "crossbeam-utils 0.7.2", |
1215 | "lazy_static", | 1242 | "lazy_static", |
1216 | "num_cpus", | 1243 | "num_cpus", |
1217 | ] | 1244 | ] |
@@ -1224,9 +1251,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" | |||
1224 | 1251 | ||
1225 | [[package]] | 1252 | [[package]] |
1226 | name = "regex" | 1253 | name = "regex" |
1227 | version = "1.3.9" | 1254 | version = "1.4.1" |
1228 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1255 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1229 | checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" | 1256 | checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" |
1230 | dependencies = [ | 1257 | dependencies = [ |
1231 | "regex-syntax", | 1258 | "regex-syntax", |
1232 | ] | 1259 | ] |
@@ -1243,9 +1270,9 @@ dependencies = [ | |||
1243 | 1270 | ||
1244 | [[package]] | 1271 | [[package]] |
1245 | name = "regex-syntax" | 1272 | name = "regex-syntax" |
1246 | version = "0.6.18" | 1273 | version = "0.6.20" |
1247 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1248 | checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" | 1275 | checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" |
1249 | 1276 | ||
1250 | [[package]] | 1277 | [[package]] |
1251 | name = "rowan" | 1278 | name = "rowan" |
@@ -1266,7 +1293,7 @@ dependencies = [ | |||
1266 | "anyhow", | 1293 | "anyhow", |
1267 | "base_db", | 1294 | "base_db", |
1268 | "cfg", | 1295 | "cfg", |
1269 | "crossbeam-channel", | 1296 | "crossbeam-channel 0.5.0", |
1270 | "env_logger", | 1297 | "env_logger", |
1271 | "expect-test", | 1298 | "expect-test", |
1272 | "flycheck", | 1299 | "flycheck", |
@@ -1307,9 +1334,9 @@ dependencies = [ | |||
1307 | 1334 | ||
1308 | [[package]] | 1335 | [[package]] |
1309 | name = "rustc-ap-rustc_lexer" | 1336 | name = "rustc-ap-rustc_lexer" |
1310 | version = "682.0.0" | 1337 | version = "683.0.0" |
1311 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1338 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1312 | checksum = "5fea544ba13e72077e363981b0a4a87997b97f772b25a0aa7ec3df35a6adfe82" | 1339 | checksum = "c0c9a47e24d4b7d74ec583d8813803b36985ee082fe7debe55f257df92d5fe50" |
1313 | dependencies = [ | 1340 | dependencies = [ |
1314 | "unicode-xid", | 1341 | "unicode-xid", |
1315 | ] | 1342 | ] |
@@ -1334,11 +1361,11 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" | |||
1334 | 1361 | ||
1335 | [[package]] | 1362 | [[package]] |
1336 | name = "salsa" | 1363 | name = "salsa" |
1337 | version = "0.15.2" | 1364 | version = "0.16.0" |
1338 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1365 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1339 | checksum = "9ab29056d4fb4048a5f0d169c9b6e5526160c9ec37aded5a6879c2c9c445a8e4" | 1366 | checksum = "d8fadca2ab5de17acf66d744f4888049ca8f1bb9b8a1ab8afd9d032cc959c5dc" |
1340 | dependencies = [ | 1367 | dependencies = [ |
1341 | "crossbeam-utils", | 1368 | "crossbeam-utils 0.8.0", |
1342 | "indexmap", | 1369 | "indexmap", |
1343 | "lock_api", | 1370 | "lock_api", |
1344 | "log", | 1371 | "log", |
@@ -1351,9 +1378,9 @@ dependencies = [ | |||
1351 | 1378 | ||
1352 | [[package]] | 1379 | [[package]] |
1353 | name = "salsa-macros" | 1380 | name = "salsa-macros" |
1354 | version = "0.15.2" | 1381 | version = "0.16.0" |
1355 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1382 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1356 | checksum = "a1c3aec007c63c4ed4cd7a018529fb0b5575c4562575fc6a40d6cd2ae0b792ef" | 1383 | checksum = "cd3904a4ba0a9d0211816177fd34b04c7095443f8cdacd11175064fe541c8fe2" |
1357 | dependencies = [ | 1384 | dependencies = [ |
1358 | "heck", | 1385 | "heck", |
1359 | "proc-macro2", | 1386 | "proc-macro2", |
@@ -1440,9 +1467,9 @@ dependencies = [ | |||
1440 | 1467 | ||
1441 | [[package]] | 1468 | [[package]] |
1442 | name = "serde_json" | 1469 | name = "serde_json" |
1443 | version = "1.0.58" | 1470 | version = "1.0.59" |
1444 | source = "registry+https://github.com/rust-lang/crates.io-index" | 1471 | source = "registry+https://github.com/rust-lang/crates.io-index" |
1445 | checksum = "a230ea9107ca2220eea9d46de97eddcb04cd00e92d13dda78e478dd33fa82bd4" | 1472 | checksum = "dcac07dbffa1c65e7f816ab9eba78eb142c6d44410f4eeba1e26e4f5dfa56b95" |
1446 | dependencies = [ | 1473 | dependencies = [ |
1447 | "itoa", | 1474 | "itoa", |
1448 | "ryu", | 1475 | "ryu", |
@@ -1807,7 +1834,7 @@ dependencies = [ | |||
1807 | name = "vfs-notify" | 1834 | name = "vfs-notify" |
1808 | version = "0.0.0" | 1835 | version = "0.0.0" |
1809 | dependencies = [ | 1836 | dependencies = [ |
1810 | "crossbeam-channel", | 1837 | "crossbeam-channel 0.5.0", |
1811 | "jod-thread", | 1838 | "jod-thread", |
1812 | "log", | 1839 | "log", |
1813 | "notify", | 1840 | "notify", |
@@ -6,3 +6,4 @@ status = [ | |||
6 | "TypeScript (windows-latest)", | 6 | "TypeScript (windows-latest)", |
7 | ] | 7 | ] |
8 | delete_merged_branches = true | 8 | delete_merged_branches = true |
9 | timeout_sec = 1200 # 20 min | ||
diff --git a/crates/assists/src/handlers/merge_imports.rs b/crates/assists/src/handlers/merge_imports.rs index fe33cee53..fd9c9e03c 100644 --- a/crates/assists/src/handlers/merge_imports.rs +++ b/crates/assists/src/handlers/merge_imports.rs | |||
@@ -73,6 +73,20 @@ mod tests { | |||
73 | use super::*; | 73 | use super::*; |
74 | 74 | ||
75 | #[test] | 75 | #[test] |
76 | fn test_merge_equal() { | ||
77 | check_assist( | ||
78 | merge_imports, | ||
79 | r" | ||
80 | use std::fmt<|>::{Display, Debug}; | ||
81 | use std::fmt::{Display, Debug}; | ||
82 | ", | ||
83 | r" | ||
84 | use std::fmt::{Debug, Display}; | ||
85 | ", | ||
86 | ) | ||
87 | } | ||
88 | |||
89 | #[test] | ||
76 | fn test_merge_first() { | 90 | fn test_merge_first() { |
77 | check_assist( | 91 | check_assist( |
78 | merge_imports, | 92 | merge_imports, |
diff --git a/crates/assists/src/handlers/replace_qualified_name_with_use.rs b/crates/assists/src/handlers/replace_qualified_name_with_use.rs index 74afc123b..c50bc7604 100644 --- a/crates/assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -124,6 +124,23 @@ mod tests { | |||
124 | use super::*; | 124 | use super::*; |
125 | 125 | ||
126 | #[test] | 126 | #[test] |
127 | fn test_replace_already_imported() { | ||
128 | check_assist( | ||
129 | replace_qualified_name_with_use, | ||
130 | r"use std::fs; | ||
131 | |||
132 | fn main() { | ||
133 | std::f<|>s::Path | ||
134 | }", | ||
135 | r"use std::fs; | ||
136 | |||
137 | fn main() { | ||
138 | fs::Path | ||
139 | }", | ||
140 | ) | ||
141 | } | ||
142 | |||
143 | #[test] | ||
127 | fn test_replace_add_use_no_anchor() { | 144 | fn test_replace_add_use_no_anchor() { |
128 | check_assist( | 145 | check_assist( |
129 | replace_qualified_name_with_use, | 146 | replace_qualified_name_with_use, |
@@ -393,7 +410,7 @@ impl std::fmt::Display<|> for Foo { | |||
393 | } | 410 | } |
394 | ", | 411 | ", |
395 | r" | 412 | r" |
396 | use std::fmt::{Display, nested::Debug}; | 413 | use std::fmt::{nested::Debug, Display}; |
397 | 414 | ||
398 | impl Display for Foo { | 415 | impl Display for Foo { |
399 | } | 416 | } |
diff --git a/crates/assists/src/utils/insert_use.rs b/crates/assists/src/utils/insert_use.rs index f6025c99a..409985b3b 100644 --- a/crates/assists/src/utils/insert_use.rs +++ b/crates/assists/src/utils/insert_use.rs | |||
@@ -173,8 +173,15 @@ pub(crate) fn try_merge_trees( | |||
173 | let rhs_path = rhs.path()?; | 173 | let rhs_path = rhs.path()?; |
174 | 174 | ||
175 | let (lhs_prefix, rhs_prefix) = common_prefix(&lhs_path, &rhs_path)?; | 175 | let (lhs_prefix, rhs_prefix) = common_prefix(&lhs_path, &rhs_path)?; |
176 | let lhs = lhs.split_prefix(&lhs_prefix); | 176 | let (lhs, rhs) = if is_simple_path(lhs) |
177 | let rhs = rhs.split_prefix(&rhs_prefix); | 177 | && is_simple_path(rhs) |
178 | && lhs_path == lhs_prefix | ||
179 | && rhs_path == rhs_prefix | ||
180 | { | ||
181 | (lhs.clone(), rhs.clone()) | ||
182 | } else { | ||
183 | (lhs.split_prefix(&lhs_prefix), rhs.split_prefix(&rhs_prefix)) | ||
184 | }; | ||
178 | recursive_merge(&lhs, &rhs, merge) | 185 | recursive_merge(&lhs, &rhs, merge) |
179 | } | 186 | } |
180 | 187 | ||
@@ -200,7 +207,18 @@ fn recursive_merge( | |||
200 | return None; | 207 | return None; |
201 | } | 208 | } |
202 | let rhs_path = rhs_t.path(); | 209 | let rhs_path = rhs_t.path(); |
203 | match use_trees.binary_search_by(|p| path_cmp_bin_search(p.path(), rhs_path.clone())) { | 210 | match use_trees.binary_search_by(|lhs_t| { |
211 | let (lhs_t, rhs_t) = match lhs_t | ||
212 | .path() | ||
213 | .zip(rhs_path.clone()) | ||
214 | .and_then(|(lhs, rhs)| common_prefix(&lhs, &rhs)) | ||
215 | { | ||
216 | Some((lhs_p, rhs_p)) => (lhs_t.split_prefix(&lhs_p), rhs_t.split_prefix(&rhs_p)), | ||
217 | None => (lhs_t.clone(), rhs_t.clone()), | ||
218 | }; | ||
219 | |||
220 | path_cmp_bin_search(lhs_t.path(), rhs_t.path()) | ||
221 | }) { | ||
204 | Ok(idx) => { | 222 | Ok(idx) => { |
205 | let lhs_t = &mut use_trees[idx]; | 223 | let lhs_t = &mut use_trees[idx]; |
206 | let lhs_path = lhs_t.path()?; | 224 | let lhs_path = lhs_t.path()?; |
@@ -239,6 +257,10 @@ fn recursive_merge( | |||
239 | use_trees.insert(idx, make::glob_use_tree()); | 257 | use_trees.insert(idx, make::glob_use_tree()); |
240 | continue; | 258 | continue; |
241 | } | 259 | } |
260 | |||
261 | if lhs_t.use_tree_list().is_none() && rhs_t.use_tree_list().is_none() { | ||
262 | continue; | ||
263 | } | ||
242 | } | 264 | } |
243 | let lhs = lhs_t.split_prefix(&lhs_prefix); | 265 | let lhs = lhs_t.split_prefix(&lhs_prefix); |
244 | let rhs = rhs_t.split_prefix(&rhs_prefix); | 266 | let rhs = rhs_t.split_prefix(&rhs_prefix); |
@@ -284,6 +306,10 @@ fn common_prefix(lhs: &ast::Path, rhs: &ast::Path) -> Option<(ast::Path, ast::Pa | |||
284 | } | 306 | } |
285 | } | 307 | } |
286 | 308 | ||
309 | fn is_simple_path(use_tree: &ast::UseTree) -> bool { | ||
310 | use_tree.use_tree_list().is_none() && use_tree.star_token().is_none() | ||
311 | } | ||
312 | |||
287 | fn path_is_self(path: &ast::Path) -> bool { | 313 | fn path_is_self(path: &ast::Path) -> bool { |
288 | path.segment().and_then(|seg| seg.self_token()).is_some() && path.qualifier().is_none() | 314 | path.segment().and_then(|seg| seg.self_token()).is_some() && path.qualifier().is_none() |
289 | } | 315 | } |
@@ -327,11 +353,11 @@ fn path_cmp_for_sort(a: Option<ast::Path>, b: Option<ast::Path>) -> Ordering { | |||
327 | 353 | ||
328 | /// Path comparison func for binary searching for merging. | 354 | /// Path comparison func for binary searching for merging. |
329 | fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering { | 355 | fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering { |
330 | match (lhs, rhs) { | 356 | match (lhs.and_then(|path| path.segment()), rhs.and_then(|path| path.segment())) { |
331 | (None, None) => Ordering::Equal, | 357 | (None, None) => Ordering::Equal, |
332 | (None, Some(_)) => Ordering::Less, | 358 | (None, Some(_)) => Ordering::Less, |
333 | (Some(_), None) => Ordering::Greater, | 359 | (Some(_), None) => Ordering::Greater, |
334 | (Some(ref a), Some(ref b)) => path_cmp_short(a, b), | 360 | (Some(ref a), Some(ref b)) => path_segment_cmp(a, b), |
335 | } | 361 | } |
336 | } | 362 | } |
337 | 363 | ||
@@ -513,6 +539,11 @@ mod tests { | |||
513 | use test_utils::assert_eq_text; | 539 | use test_utils::assert_eq_text; |
514 | 540 | ||
515 | #[test] | 541 | #[test] |
542 | fn insert_existing() { | ||
543 | check_full("std::fs", "use std::fs;", "use std::fs;") | ||
544 | } | ||
545 | |||
546 | #[test] | ||
516 | fn insert_start() { | 547 | fn insert_start() { |
517 | check_none( | 548 | check_none( |
518 | "std::bar::AA", | 549 | "std::bar::AA", |
@@ -802,6 +833,24 @@ use std::foo::bar::{Qux, quux::{Fez, Fizz}};", | |||
802 | } | 833 | } |
803 | 834 | ||
804 | #[test] | 835 | #[test] |
836 | fn merge_groups_full_nested_long() { | ||
837 | check_full( | ||
838 | "std::foo::bar::Baz", | ||
839 | r"use std::{foo::bar::Qux};", | ||
840 | r"use std::{foo::bar::{Baz, Qux}};", | ||
841 | ); | ||
842 | } | ||
843 | |||
844 | #[test] | ||
845 | fn merge_groups_last_nested_long() { | ||
846 | check_full( | ||
847 | "std::foo::bar::Baz", | ||
848 | r"use std::{foo::bar::Qux};", | ||
849 | r"use std::{foo::bar::{Baz, Qux}};", | ||
850 | ); | ||
851 | } | ||
852 | |||
853 | #[test] | ||
805 | fn merge_groups_skip_pub() { | 854 | fn merge_groups_skip_pub() { |
806 | check_full( | 855 | check_full( |
807 | "std::io", | 856 | "std::io", |
diff --git a/crates/base_db/Cargo.toml b/crates/base_db/Cargo.toml index f7bfcb0d7..1724d2f85 100644 --- a/crates/base_db/Cargo.toml +++ b/crates/base_db/Cargo.toml | |||
@@ -10,7 +10,7 @@ edition = "2018" | |||
10 | doctest = false | 10 | doctest = false |
11 | 11 | ||
12 | [dependencies] | 12 | [dependencies] |
13 | salsa = "0.15.2" | 13 | salsa = "0.16.0" |
14 | rustc-hash = "1.1.0" | 14 | rustc-hash = "1.1.0" |
15 | 15 | ||
16 | syntax = { path = "../syntax", version = "0.0.0" } | 16 | syntax = { path = "../syntax", version = "0.0.0" } |
diff --git a/crates/flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index c230fc1e2..4e2b60b73 100644 --- a/crates/flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml | |||
@@ -10,7 +10,7 @@ edition = "2018" | |||
10 | doctest = false | 10 | doctest = false |
11 | 11 | ||
12 | [dependencies] | 12 | [dependencies] |
13 | crossbeam-channel = "0.4.0" | 13 | crossbeam-channel = "0.5.0" |
14 | log = "0.4.8" | 14 | log = "0.4.8" |
15 | cargo_metadata = "0.11.1" | 15 | cargo_metadata = "0.11.1" |
16 | serde_json = "1.0.48" | 16 | serde_json = "1.0.48" |
diff --git a/crates/ide/Cargo.toml b/crates/ide/Cargo.toml index f0257403d..29dc9a6a8 100644 --- a/crates/ide/Cargo.toml +++ b/crates/ide/Cargo.toml | |||
@@ -16,8 +16,8 @@ itertools = "0.9.0" | |||
16 | log = "0.4.8" | 16 | log = "0.4.8" |
17 | rustc-hash = "1.1.0" | 17 | rustc-hash = "1.1.0" |
18 | oorandom = "11.1.2" | 18 | oorandom = "11.1.2" |
19 | pulldown-cmark-to-cmark = "5.0.0" | 19 | pulldown-cmark-to-cmark = "6.0.0" |
20 | pulldown-cmark = {version = "0.7.2", default-features = false} | 20 | pulldown-cmark = { version = "0.8.0", default-features = false } |
21 | url = "2.1.1" | 21 | url = "2.1.1" |
22 | 22 | ||
23 | stdx = { path = "../stdx", version = "0.0.0" } | 23 | stdx = { path = "../stdx", version = "0.0.0" } |
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index 06af36b73..db3f911c8 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs | |||
@@ -1,9 +1,10 @@ | |||
1 | //! Resolves and rewrites links in markdown documentation. | 1 | //! Resolves and rewrites links in markdown documentation. |
2 | 2 | ||
3 | use std::convert::TryFrom; | ||
3 | use std::iter::once; | 4 | use std::iter::once; |
4 | 5 | ||
5 | use itertools::Itertools; | 6 | use itertools::Itertools; |
6 | use pulldown_cmark::{CowStr, Event, LinkType, Options, Parser, Tag}; | 7 | use pulldown_cmark::{BrokenLink, CowStr, Event, InlineStr, LinkType, Options, Parser, Tag}; |
7 | use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions}; | 8 | use pulldown_cmark_to_cmark::{cmark_with_options, Options as CmarkOptions}; |
8 | use url::Url; | 9 | use url::Url; |
9 | 10 | ||
@@ -24,11 +25,13 @@ pub type DocumentationLink = String; | |||
24 | 25 | ||
25 | /// Rewrite documentation links in markdown to point to an online host (e.g. docs.rs) | 26 | /// Rewrite documentation links in markdown to point to an online host (e.g. docs.rs) |
26 | pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) -> String { | 27 | pub fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) -> String { |
27 | let doc = Parser::new_with_broken_link_callback( | 28 | let mut cb = |link: BrokenLink| { |
28 | markdown, | 29 | Some(( |
29 | Options::empty(), | 30 | /*url*/ link.reference.to_owned().into(), |
30 | Some(&|label, _| Some((/*url*/ label.to_string(), /*title*/ label.to_string()))), | 31 | /*title*/ link.reference.to_owned().into(), |
31 | ); | 32 | )) |
33 | }; | ||
34 | let doc = Parser::new_with_broken_link_callback(markdown, Options::empty(), Some(&mut cb)); | ||
32 | 35 | ||
33 | let doc = map_links(doc, |target, title: &str| { | 36 | let doc = map_links(doc, |target, title: &str| { |
34 | // This check is imperfect, there's some overlap between valid intra-doc links | 37 | // This check is imperfect, there's some overlap between valid intra-doc links |
@@ -66,11 +69,11 @@ pub fn remove_links(markdown: &str) -> String { | |||
66 | let mut opts = Options::empty(); | 69 | let mut opts = Options::empty(); |
67 | opts.insert(Options::ENABLE_FOOTNOTES); | 70 | opts.insert(Options::ENABLE_FOOTNOTES); |
68 | 71 | ||
69 | let doc = Parser::new_with_broken_link_callback( | 72 | let mut cb = |_: BrokenLink| { |
70 | markdown, | 73 | let empty = InlineStr::try_from("").unwrap(); |
71 | opts, | 74 | Some((CowStr::Inlined(empty.clone()), CowStr::Inlined(empty))) |
72 | Some(&|_, _| Some((String::new(), String::new()))), | 75 | }; |
73 | ); | 76 | let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb)); |
74 | let doc = doc.filter_map(move |evt| match evt { | 77 | let doc = doc.filter_map(move |evt| match evt { |
75 | Event::Start(Tag::Link(link_type, ref target, ref title)) => { | 78 | Event::Start(Tag::Link(link_type, ref target, ref title)) => { |
76 | if link_type == LinkType::Inline && target.contains("://") { | 79 | if link_type == LinkType::Inline && target.contains("://") { |
diff --git a/crates/proc_macro_api/Cargo.toml b/crates/proc_macro_api/Cargo.toml index 75f67a22e..3863e5189 100644 --- a/crates/proc_macro_api/Cargo.toml +++ b/crates/proc_macro_api/Cargo.toml | |||
@@ -13,7 +13,7 @@ doctest = false | |||
13 | serde = { version = "1.0", features = ["derive"] } | 13 | serde = { version = "1.0", features = ["derive"] } |
14 | serde_json = "1.0" | 14 | serde_json = "1.0" |
15 | log = "0.4.8" | 15 | log = "0.4.8" |
16 | crossbeam-channel = "0.4.0" | 16 | crossbeam-channel = "0.5.0" |
17 | jod-thread = "0.1.1" | 17 | jod-thread = "0.1.1" |
18 | 18 | ||
19 | tt = { path = "../tt", version = "0.0.0" } | 19 | tt = { path = "../tt", version = "0.0.0" } |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 631ffc4a7..df2ea6f85 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -16,7 +16,7 @@ path = "src/bin/main.rs" | |||
16 | 16 | ||
17 | [dependencies] | 17 | [dependencies] |
18 | anyhow = "1.0.26" | 18 | anyhow = "1.0.26" |
19 | crossbeam-channel = "0.4.0" | 19 | crossbeam-channel = "0.5.0" |
20 | env_logger = { version = "0.7.1", default-features = false } | 20 | env_logger = { version = "0.7.1", default-features = false } |
21 | itertools = "0.9.0" | 21 | itertools = "0.9.0" |
22 | jod-thread = "0.1.0" | 22 | jod-thread = "0.1.0" |
@@ -31,7 +31,7 @@ serde_json = "1.0.48" | |||
31 | threadpool = "1.7.1" | 31 | threadpool = "1.7.1" |
32 | rayon = "1.3.1" | 32 | rayon = "1.3.1" |
33 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | 33 | mimalloc = { version = "0.1.19", default-features = false, optional = true } |
34 | lsp-server = "0.3.3" | 34 | lsp-server = "0.4.0" |
35 | 35 | ||
36 | stdx = { path = "../stdx", version = "0.0.0" } | 36 | stdx = { path = "../stdx", version = "0.0.0" } |
37 | flycheck = { path = "../flycheck", version = "0.0.0" } | 37 | flycheck = { path = "../flycheck", version = "0.0.0" } |
diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 547fe9f47..c343f2f70 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml | |||
@@ -13,7 +13,7 @@ doctest = false | |||
13 | [dependencies] | 13 | [dependencies] |
14 | itertools = "0.9.0" | 14 | itertools = "0.9.0" |
15 | rowan = "0.10.0" | 15 | rowan = "0.10.0" |
16 | rustc_lexer = { version = "682.0.0", package = "rustc-ap-rustc_lexer" } | 16 | rustc_lexer = { version = "683.0.0", package = "rustc-ap-rustc_lexer" } |
17 | rustc-hash = "1.1.0" | 17 | rustc-hash = "1.1.0" |
18 | arrayvec = "0.5.1" | 18 | arrayvec = "0.5.1" |
19 | once_cell = "1.3.1" | 19 | once_cell = "1.3.1" |
diff --git a/crates/vfs-notify/Cargo.toml b/crates/vfs-notify/Cargo.toml index 54b51faab..5b7c33b01 100644 --- a/crates/vfs-notify/Cargo.toml +++ b/crates/vfs-notify/Cargo.toml | |||
@@ -14,7 +14,7 @@ log = "0.4.8" | |||
14 | rustc-hash = "1.0" | 14 | rustc-hash = "1.0" |
15 | jod-thread = "0.1.0" | 15 | jod-thread = "0.1.0" |
16 | walkdir = "2.3.1" | 16 | walkdir = "2.3.1" |
17 | crossbeam-channel = "0.4.0" | 17 | crossbeam-channel = "0.5.0" |
18 | notify = "5.0.0-pre.3" | 18 | notify = "5.0.0-pre.3" |
19 | 19 | ||
20 | vfs = { path = "../vfs", version = "0.0.0" } | 20 | vfs = { path = "../vfs", version = "0.0.0" } |
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md index 3f861f3e0..43a69d6ce 100644 --- a/docs/dev/lsp-extensions.md +++ b/docs/dev/lsp-extensions.md | |||
@@ -1,3 +1,13 @@ | |||
1 | <!--- | ||
2 | lsp_ext.rs hash: 286f8bbac885531a | ||
3 | |||
4 | If you need to change the above hash to make the test pass, please check if you | ||
5 | need to adjust this doc as well and ping this issue: | ||
6 | |||
7 | https://github.com/rust-analyzer/rust-analyzer/issues/4604 | ||
8 | |||
9 | ---> | ||
10 | |||
1 | # LSP Extensions | 11 | # LSP Extensions |
2 | 12 | ||
3 | This document describes LSP extensions used by rust-analyzer. | 13 | This document describes LSP extensions used by rust-analyzer. |
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index 1445e41d3..22509e874 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts | |||
@@ -442,8 +442,8 @@ export function openDocs(ctx: Ctx): Cmd { | |||
442 | 442 | ||
443 | export function resolveCodeAction(ctx: Ctx): Cmd { | 443 | export function resolveCodeAction(ctx: Ctx): Cmd { |
444 | const client = ctx.client; | 444 | const client = ctx.client; |
445 | return async () => { | 445 | return async (params: ra.ResolveCodeActionParams) => { |
446 | const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, null); | 446 | const item: lc.WorkspaceEdit = await client.sendRequest(ra.resolveCodeAction, params); |
447 | if (!item) { | 447 | if (!item) { |
448 | return; | 448 | return; |
449 | } | 449 | } |
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 0c233f87d..b3bb9d543 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -45,6 +45,41 @@ fn smoke_test_docs_generation() { | |||
45 | } | 45 | } |
46 | 46 | ||
47 | #[test] | 47 | #[test] |
48 | fn check_lsp_extensions_docs() { | ||
49 | let expected_hash = { | ||
50 | let lsp_ext_rs = | ||
51 | fs2::read_to_string(project_root().join("crates/rust-analyzer/src/lsp_ext.rs")) | ||
52 | .unwrap(); | ||
53 | stable_hash(lsp_ext_rs.as_str()) | ||
54 | }; | ||
55 | |||
56 | let actual_hash = { | ||
57 | let lsp_extensions_md = | ||
58 | fs2::read_to_string(project_root().join("docs/dev/lsp-extensions.md")).unwrap(); | ||
59 | let text = lsp_extensions_md | ||
60 | .lines() | ||
61 | .find_map(|line| line.strip_prefix("lsp_ext.rs hash:")) | ||
62 | .unwrap() | ||
63 | .trim(); | ||
64 | u64::from_str_radix(text, 16).unwrap() | ||
65 | }; | ||
66 | |||
67 | if actual_hash != expected_hash { | ||
68 | panic!( | ||
69 | " | ||
70 | lsp_ext.rs was changed without touching lsp-extensions.md. | ||
71 | |||
72 | Expected hash: {:x} | ||
73 | Actual hash: {:x} | ||
74 | |||
75 | Please adjust docs/dev/lsp-extensions.md. | ||
76 | ", | ||
77 | expected_hash, actual_hash | ||
78 | ) | ||
79 | } | ||
80 | } | ||
81 | |||
82 | #[test] | ||
48 | fn rust_files_are_tidy() { | 83 | fn rust_files_are_tidy() { |
49 | let mut tidy_docs = TidyDocs::default(); | 84 | let mut tidy_docs = TidyDocs::default(); |
50 | for path in rust_files(&project_root().join("crates")) { | 85 | for path in rust_files(&project_root().join("crates")) { |
@@ -280,3 +315,13 @@ fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool { | |||
280 | .filter_map(|it| it.as_os_str().to_str()) | 315 | .filter_map(|it| it.as_os_str().to_str()) |
281 | .any(|it| dirs_to_exclude.contains(&it)) | 316 | .any(|it| dirs_to_exclude.contains(&it)) |
282 | } | 317 | } |
318 | |||
319 | #[allow(deprecated)] | ||
320 | fn stable_hash(text: &str) -> u64 { | ||
321 | use std::hash::{Hash, Hasher, SipHasher}; | ||
322 | |||
323 | let text = text.replace('\r', ""); | ||
324 | let mut hasher = SipHasher::default(); | ||
325 | text.hash(&mut hasher); | ||
326 | hasher.finish() | ||
327 | } | ||