aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-11-13 23:07:03 +0000
committerKirill Bulatov <[email protected]>2020-11-16 19:19:06 +0000
commit3b0fc4d7f2b922a1b7d8d32fc0b065e4023d749b (patch)
tree316856a272dc85450c1d95725dbbd8a0150de2c1
parent46514448b740b82e4f5f9cf742c6f8c6caec1d38 (diff)
Omit modules during autocompletion
-rw-r--r--Cargo.lock159
-rw-r--r--crates/completion/src/completions/magic.rs26
2 files changed, 118 insertions, 67 deletions
diff --git a/Cargo.lock b/Cargo.lock
index eb4e43ad9..d51610e4c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,9 +2,9 @@
2# It is not intended for manual editing. 2# It is not intended for manual editing.
3[[package]] 3[[package]]
4name = "addr2line" 4name = "addr2line"
5version = "0.13.0" 5version = "0.14.0"
6source = "registry+https://github.com/rust-lang/crates.io-index" 6source = "registry+https://github.com/rust-lang/crates.io-index"
7checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" 7checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423"
8dependencies = [ 8dependencies = [
9 "gimli", 9 "gimli",
10] 10]
@@ -26,9 +26,9 @@ dependencies = [
26 26
27[[package]] 27[[package]]
28name = "anyhow" 28name = "anyhow"
29version = "1.0.33" 29version = "1.0.34"
30source = "registry+https://github.com/rust-lang/crates.io-index" 30source = "registry+https://github.com/rust-lang/crates.io-index"
31checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" 31checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7"
32 32
33[[package]] 33[[package]]
34name = "anymap" 34name = "anymap"
@@ -42,9 +42,9 @@ version = "0.0.0"
42 42
43[[package]] 43[[package]]
44name = "arrayvec" 44name = "arrayvec"
45version = "0.5.1" 45version = "0.5.2"
46source = "registry+https://github.com/rust-lang/crates.io-index" 46source = "registry+https://github.com/rust-lang/crates.io-index"
47checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" 47checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
48 48
49[[package]] 49[[package]]
50name = "assists" 50name = "assists"
@@ -81,9 +81,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
81 81
82[[package]] 82[[package]]
83name = "backtrace" 83name = "backtrace"
84version = "0.3.53" 84version = "0.3.54"
85source = "registry+https://github.com/rust-lang/crates.io-index" 85source = "registry+https://github.com/rust-lang/crates.io-index"
86checksum = "707b586e0e2f247cbde68cdd2c3ce69ea7b7be43e1c5b426e37c9319c4b9838e" 86checksum = "2baad346b2d4e94a24347adeee9c7a93f412ee94b9cc26e5b59dea23848e9f28"
87dependencies = [ 87dependencies = [
88 "addr2line", 88 "addr2line",
89 "cfg-if 1.0.0", 89 "cfg-if 1.0.0",
@@ -132,7 +132,7 @@ version = "0.12.0"
132source = "registry+https://github.com/rust-lang/crates.io-index" 132source = "registry+https://github.com/rust-lang/crates.io-index"
133checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345" 133checksum = "d5a5f7b42f606b7f23674f6f4d877628350682bc40687d3fae65679a58d55345"
134dependencies = [ 134dependencies = [
135 "semver", 135 "semver 0.11.0",
136 "serde", 136 "serde",
137 "serde_json", 137 "serde_json",
138] 138]
@@ -271,17 +271,17 @@ dependencies = [
271 271
272[[package]] 272[[package]]
273name = "const_fn" 273name = "const_fn"
274version = "0.4.2" 274version = "0.4.3"
275source = "registry+https://github.com/rust-lang/crates.io-index" 275source = "registry+https://github.com/rust-lang/crates.io-index"
276checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2" 276checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
277 277
278[[package]] 278[[package]]
279name = "crc32fast" 279name = "crc32fast"
280version = "1.2.0" 280version = "1.2.1"
281source = "registry+https://github.com/rust-lang/crates.io-index" 281source = "registry+https://github.com/rust-lang/crates.io-index"
282checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" 282checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
283dependencies = [ 283dependencies = [
284 "cfg-if 0.1.10", 284 "cfg-if 1.0.0",
285] 285]
286 286
287[[package]] 287[[package]]
@@ -418,11 +418,11 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
418 418
419[[package]] 419[[package]]
420name = "flate2" 420name = "flate2"
421version = "1.0.18" 421version = "1.0.19"
422source = "registry+https://github.com/rust-lang/crates.io-index" 422source = "registry+https://github.com/rust-lang/crates.io-index"
423checksum = "da80be589a72651dcda34d8b35bcdc9b7254ad06325611074d9cc0fbb19f60ee" 423checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129"
424dependencies = [ 424dependencies = [
425 "cfg-if 0.1.10", 425 "cfg-if 1.0.0",
426 "crc32fast", 426 "crc32fast",
427 "libc", 427 "libc",
428 "miniz_oxide", 428 "miniz_oxide",
@@ -471,9 +471,9 @@ dependencies = [
471 471
472[[package]] 472[[package]]
473name = "fst" 473name = "fst"
474version = "0.4.4" 474version = "0.4.5"
475source = "registry+https://github.com/rust-lang/crates.io-index" 475source = "registry+https://github.com/rust-lang/crates.io-index"
476checksum = "a7293de202dbfe786c0b3fe6110a027836c5438ed06db7b715c9955ff4bfea51" 476checksum = "d79238883cf0307100b90aba4a755d8051a3182305dfe7f649a1e9dc0517006f"
477 477
478[[package]] 478[[package]]
479name = "fuchsia-zircon" 479name = "fuchsia-zircon"
@@ -492,10 +492,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
492checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 492checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
493 493
494[[package]] 494[[package]]
495name = "generator"
496version = "0.6.23"
497source = "registry+https://github.com/rust-lang/crates.io-index"
498checksum = "8cdc09201b2e8ca1b19290cf7e65de2246b8e91fb6874279722189c4de7b94dc"
499dependencies = [
500 "cc",
501 "libc",
502 "log",
503 "rustc_version",
504 "winapi 0.3.9",
505]
506
507[[package]]
495name = "gimli" 508name = "gimli"
496version = "0.22.0" 509version = "0.23.0"
497source = "registry+https://github.com/rust-lang/crates.io-index" 510source = "registry+https://github.com/rust-lang/crates.io-index"
498checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" 511checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
499 512
500[[package]] 513[[package]]
501name = "goblin" 514name = "goblin"
@@ -723,11 +736,11 @@ dependencies = [
723 736
724[[package]] 737[[package]]
725name = "instant" 738name = "instant"
726version = "0.1.7" 739version = "0.1.8"
727source = "registry+https://github.com/rust-lang/crates.io-index" 740source = "registry+https://github.com/rust-lang/crates.io-index"
728checksum = "63312a18f7ea8760cdd0a7c5aac1a619752a246b833545e3e36d1f81f7cd9e66" 741checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613"
729dependencies = [ 742dependencies = [
730 "cfg-if 0.1.10", 743 "cfg-if 1.0.0",
731] 744]
732 745
733[[package]] 746[[package]]
@@ -784,17 +797,17 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
784 797
785[[package]] 798[[package]]
786name = "libc" 799name = "libc"
787version = "0.2.79" 800version = "0.2.80"
788source = "registry+https://github.com/rust-lang/crates.io-index" 801source = "registry+https://github.com/rust-lang/crates.io-index"
789checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" 802checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
790 803
791[[package]] 804[[package]]
792name = "libloading" 805name = "libloading"
793version = "0.6.4" 806version = "0.6.5"
794source = "registry+https://github.com/rust-lang/crates.io-index" 807source = "registry+https://github.com/rust-lang/crates.io-index"
795checksum = "3557c9384f7f757f6d139cd3a4c62ef4e850696c16bf27924a5538c8a09717a1" 808checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0"
796dependencies = [ 809dependencies = [
797 "cfg-if 0.1.10", 810 "cfg-if 1.0.0",
798 "winapi 0.3.9", 811 "winapi 0.3.9",
799] 812]
800 813
@@ -826,6 +839,19 @@ dependencies = [
826] 839]
827 840
828[[package]] 841[[package]]
842name = "loom"
843version = "0.3.6"
844source = "registry+https://github.com/rust-lang/crates.io-index"
845checksum = "a0e8460f2f2121162705187214720353c517b97bdfb3494c0b1e33d83ebe4bed"
846dependencies = [
847 "cfg-if 0.1.10",
848 "generator",
849 "scoped-tls",
850 "serde",
851 "serde_json",
852]
853
854[[package]]
829name = "lsp-server" 855name = "lsp-server"
830version = "0.4.1" 856version = "0.4.1"
831source = "registry+https://github.com/rust-lang/crates.io-index" 857source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -887,9 +913,9 @@ dependencies = [
887 913
888[[package]] 914[[package]]
889name = "memchr" 915name = "memchr"
890version = "2.3.3" 916version = "2.3.4"
891source = "registry+https://github.com/rust-lang/crates.io-index" 917source = "registry+https://github.com/rust-lang/crates.io-index"
892checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" 918checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
893 919
894[[package]] 920[[package]]
895name = "memmap" 921name = "memmap"
@@ -985,9 +1011,9 @@ dependencies = [
985 1011
986[[package]] 1012[[package]]
987name = "notify" 1013name = "notify"
988version = "5.0.0-pre.3" 1014version = "5.0.0-pre.4"
989source = "registry+https://github.com/rust-lang/crates.io-index" 1015source = "registry+https://github.com/rust-lang/crates.io-index"
990checksum = "77d03607cf88b4b160ba0e9ed425fff3cee3b55ac813f0c685b3a3772da37d0e" 1016checksum = "a8b946889dfdad884379cd56367d93b6d0ce8889cc027d26a69a3a31c0a03bb5"
991dependencies = [ 1017dependencies = [
992 "anymap", 1018 "anymap",
993 "bitflags", 1019 "bitflags",
@@ -1005,9 +1031,9 @@ dependencies = [
1005 1031
1006[[package]] 1032[[package]]
1007name = "num-integer" 1033name = "num-integer"
1008version = "0.1.43" 1034version = "0.1.44"
1009source = "registry+https://github.com/rust-lang/crates.io-index" 1035source = "registry+https://github.com/rust-lang/crates.io-index"
1010checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" 1036checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
1011dependencies = [ 1037dependencies = [
1012 "autocfg", 1038 "autocfg",
1013 "num-traits", 1039 "num-traits",
@@ -1015,9 +1041,9 @@ dependencies = [
1015 1041
1016[[package]] 1042[[package]]
1017name = "num-traits" 1043name = "num-traits"
1018version = "0.2.12" 1044version = "0.2.14"
1019source = "registry+https://github.com/rust-lang/crates.io-index" 1045source = "registry+https://github.com/rust-lang/crates.io-index"
1020checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" 1046checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
1021dependencies = [ 1047dependencies = [
1022 "autocfg", 1048 "autocfg",
1023] 1049]
@@ -1034,9 +1060,9 @@ dependencies = [
1034 1060
1035[[package]] 1061[[package]]
1036name = "object" 1062name = "object"
1037version = "0.21.1" 1063version = "0.22.0"
1038source = "registry+https://github.com/rust-lang/crates.io-index" 1064source = "registry+https://github.com/rust-lang/crates.io-index"
1039checksum = "37fd5004feb2ce328a52b0b3d01dbf4ffff72583493900ed15f22d4111c51693" 1065checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
1040 1066
1041[[package]] 1067[[package]]
1042name = "once_cell" 1068name = "once_cell"
@@ -1285,9 +1311,9 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
1285 1311
1286[[package]] 1312[[package]]
1287name = "regex" 1313name = "regex"
1288version = "1.4.1" 1314version = "1.4.2"
1289source = "registry+https://github.com/rust-lang/crates.io-index" 1315source = "registry+https://github.com/rust-lang/crates.io-index"
1290checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" 1316checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
1291dependencies = [ 1317dependencies = [
1292 "regex-syntax", 1318 "regex-syntax",
1293] 1319]
@@ -1304,9 +1330,9 @@ dependencies = [
1304 1330
1305[[package]] 1331[[package]]
1306name = "regex-syntax" 1332name = "regex-syntax"
1307version = "0.6.20" 1333version = "0.6.21"
1308source = "registry+https://github.com/rust-lang/crates.io-index" 1334source = "registry+https://github.com/rust-lang/crates.io-index"
1309checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c" 1335checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
1310 1336
1311[[package]] 1337[[package]]
1312name = "rowan" 1338name = "rowan"
@@ -1379,9 +1405,9 @@ dependencies = [
1379 1405
1380[[package]] 1406[[package]]
1381name = "rustc-demangle" 1407name = "rustc-demangle"
1382version = "0.1.17" 1408version = "0.1.18"
1383source = "registry+https://github.com/rust-lang/crates.io-index" 1409source = "registry+https://github.com/rust-lang/crates.io-index"
1384checksum = "b2610b7f643d18c87dff3b489950269617e6601a51f1f05aa5daefee36f64f0b" 1410checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232"
1385 1411
1386[[package]] 1412[[package]]
1387name = "rustc-hash" 1413name = "rustc-hash"
@@ -1390,6 +1416,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1390checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 1416checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
1391 1417
1392[[package]] 1418[[package]]
1419name = "rustc_version"
1420version = "0.2.3"
1421source = "registry+https://github.com/rust-lang/crates.io-index"
1422checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
1423dependencies = [
1424 "semver 0.9.0",
1425]
1426
1427[[package]]
1393name = "ryu" 1428name = "ryu"
1394version = "1.0.5" 1429version = "1.0.5"
1395source = "registry+https://github.com/rust-lang/crates.io-index" 1430source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1456,9 +1491,9 @@ dependencies = [
1456 1491
1457[[package]] 1492[[package]]
1458name = "scroll_derive" 1493name = "scroll_derive"
1459version = "0.10.3" 1494version = "0.10.4"
1460source = "registry+https://github.com/rust-lang/crates.io-index" 1495source = "registry+https://github.com/rust-lang/crates.io-index"
1461checksum = "6dfde5d1531034db129e95c76ac857e2baecea3443579d493d02224950b0fb6d" 1496checksum = "b12bd20b94c7cdfda8c7ba9b92ad0d9a56e3fa018c25fca83b51aa664c9b4c0d"
1462dependencies = [ 1497dependencies = [
1463 "proc-macro2", 1498 "proc-macro2",
1464 "quote", 1499 "quote",
@@ -1467,16 +1502,31 @@ dependencies = [
1467 1502
1468[[package]] 1503[[package]]
1469name = "semver" 1504name = "semver"
1505version = "0.9.0"
1506source = "registry+https://github.com/rust-lang/crates.io-index"
1507checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
1508dependencies = [
1509 "semver-parser 0.7.0",
1510]
1511
1512[[package]]
1513name = "semver"
1470version = "0.11.0" 1514version = "0.11.0"
1471source = "registry+https://github.com/rust-lang/crates.io-index" 1515source = "registry+https://github.com/rust-lang/crates.io-index"
1472checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 1516checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
1473dependencies = [ 1517dependencies = [
1474 "semver-parser", 1518 "semver-parser 0.10.1",
1475 "serde", 1519 "serde",
1476] 1520]
1477 1521
1478[[package]] 1522[[package]]
1479name = "semver-parser" 1523name = "semver-parser"
1524version = "0.7.0"
1525source = "registry+https://github.com/rust-lang/crates.io-index"
1526checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
1527
1528[[package]]
1529name = "semver-parser"
1480version = "0.10.1" 1530version = "0.10.1"
1481source = "registry+https://github.com/rust-lang/crates.io-index" 1531source = "registry+https://github.com/rust-lang/crates.io-index"
1482checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428" 1532checksum = "42ef146c2ad5e5f4b037cd6ce2ebb775401729b19a82040c1beac9d36c7d1428"
@@ -1528,11 +1578,12 @@ dependencies = [
1528 1578
1529[[package]] 1579[[package]]
1530name = "sharded-slab" 1580name = "sharded-slab"
1531version = "0.0.9" 1581version = "0.1.0"
1532source = "registry+https://github.com/rust-lang/crates.io-index" 1582source = "registry+https://github.com/rust-lang/crates.io-index"
1533checksum = "06d5a3f5166fb5b42a5439f2eee8b9de149e235961e3eb21c5808fc3ea17ff3e" 1583checksum = "7b4921be914e16899a80adefb821f8ddb7974e3f1250223575a44ed994882127"
1534dependencies = [ 1584dependencies = [
1535 "lazy_static", 1585 "lazy_static",
1586 "loom",
1536] 1587]
1537 1588
1538[[package]] 1589[[package]]
@@ -1576,9 +1627,9 @@ version = "0.0.0"
1576 1627
1577[[package]] 1628[[package]]
1578name = "syn" 1629name = "syn"
1579version = "1.0.45" 1630version = "1.0.48"
1580source = "registry+https://github.com/rust-lang/crates.io-index" 1631source = "registry+https://github.com/rust-lang/crates.io-index"
1581checksum = "ea9c5432ff16d6152371f808fb5a871cd67368171b09bb21b43df8e4a47a3556" 1632checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
1582dependencies = [ 1633dependencies = [
1583 "proc-macro2", 1634 "proc-macro2",
1584 "quote", 1635 "quote",
@@ -1755,9 +1806,9 @@ dependencies = [
1755 1806
1756[[package]] 1807[[package]]
1757name = "tracing-subscriber" 1808name = "tracing-subscriber"
1758version = "0.2.13" 1809version = "0.2.15"
1759source = "registry+https://github.com/rust-lang/crates.io-index" 1810source = "registry+https://github.com/rust-lang/crates.io-index"
1760checksum = "4ef0a5e15477aa303afbfac3a44cba9b6430fdaad52423b1e6c0dbbe28c3eedd" 1811checksum = "a1fa8f0c8f4c594e4fc9debc1990deab13238077271ba84dd853d54902ee3401"
1761dependencies = [ 1812dependencies = [
1762 "ansi_term", 1813 "ansi_term",
1763 "chrono", 1814 "chrono",
diff --git a/crates/completion/src/completions/magic.rs b/crates/completion/src/completions/magic.rs
index 2ac6f94a9..0c4db0199 100644
--- a/crates/completion/src/completions/magic.rs
+++ b/crates/completion/src/completions/magic.rs
@@ -2,7 +2,7 @@
2 2
3use assists::utils::{insert_use, mod_path_to_ast, ImportScope}; 3use assists::utils::{insert_use, mod_path_to_ast, ImportScope};
4use either::Either; 4use either::Either;
5use hir::ScopeDef; 5use hir::{ModuleDef, ScopeDef};
6use ide_db::imports_locator; 6use ide_db::imports_locator;
7use syntax::{algo, AstNode}; 7use syntax::{algo, AstNode};
8 8
@@ -13,7 +13,6 @@ use crate::{
13 13
14use super::Completions; 14use super::Completions;
15 15
16// TODO kb reuse auto_import assist approach to add trait completion
17// TODO kb add a setting toggle for this feature? 16// TODO kb add a setting toggle for this feature?
18pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> { 17pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
19 if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) { 18 if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
@@ -28,17 +27,18 @@ pub(crate) fn complete_magic(acc: &mut Completions, ctx: &CompletionContext) ->
28 27
29 let possible_imports = 28 let possible_imports =
30 imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400) 29 imports_locator::find_similar_imports(&ctx.sema, ctx.krate?, &potential_import_name, 400)
31 .filter_map(|import_candidate| { 30 .filter_map(|import_candidate| match import_candidate {
32 Some(match import_candidate { 31 // when completing outside the use declaration, modules are pretty useless
33 Either::Left(module_def) => ( 32 // and tend to bloat the completion suggestions a lot
34 current_module.find_use_path(ctx.db, module_def)?, 33 Either::Left(ModuleDef::Module(_)) => None,
35 ScopeDef::ModuleDef(module_def), 34 Either::Left(module_def) => Some((
36 ), 35 current_module.find_use_path(ctx.db, module_def)?,
37 Either::Right(macro_def) => ( 36 ScopeDef::ModuleDef(module_def),
38 current_module.find_use_path(ctx.db, macro_def)?, 37 )),
39 ScopeDef::MacroDef(macro_def), 38 Either::Right(macro_def) => Some((
40 ), 39 current_module.find_use_path(ctx.db, macro_def)?,
41 }) 40 ScopeDef::MacroDef(macro_def),
41 )),
42 }) 42 })
43 .filter_map(|(mod_path, definition)| { 43 .filter_map(|(mod_path, definition)| {
44 let mut resolution_with_missing_import = render_resolution( 44 let mut resolution_with_missing_import = render_resolution(