diff --git a/Cargo.lock b/Cargo.lock index 73fc7a9e000..2ed18a55759 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,12 +45,6 @@ version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" -[[package]] -name = "arc-swap" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62" - [[package]] name = "arrayref" version = "0.3.6" @@ -80,28 +74,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" -[[package]] -name = "backtrace" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1e692897359247cc6bb902933361652380af0f1b7651ae5c5013407f30e109e" -dependencies = [ - "backtrace-sys", - "cfg-if 0.1.10", - "libc", - "rustc-demangle", -] - -[[package]] -name = "backtrace-sys" -version = "0.1.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "base64" version = "0.11.0" @@ -166,13 +138,9 @@ checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" [[package]] name = "bytes" -version = "0.4.12" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "bytesize" @@ -322,7 +290,7 @@ dependencies = [ "regex-syntax", "semver 0.9.0", "serde", - "smallvec 1.4.0", + "smallvec", "syn", "toml", "unicode-normalization", @@ -343,21 +311,12 @@ dependencies = [ "regex-syntax", "semver 0.9.0", "serde", - "smallvec 1.4.0", + "smallvec", "toml", "unicode-normalization", "url 2.1.1", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "cloudabi" version = "0.1.0" @@ -684,28 +643,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "failure" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" -dependencies = [ - "backtrace", - "failure_derive", -] - -[[package]] -name = "failure_derive" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", -] - [[package]] name = "filetime" version = "0.2.9" @@ -783,6 +720,103 @@ version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +[[package]] +name = "futures" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" + +[[package]] +name = "futures-executor" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" + +[[package]] +name = "futures-macro" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" + +[[package]] +name = "futures-task" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" +dependencies = [ + "futures 0.1.29", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite 0.2.4", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + [[package]] name = "fwdansi" version = "1.1.0" @@ -1062,12 +1096,12 @@ checksum = "92c245af8786f6ac35f95ca14feca9119e71339aaab41e878e7cdd655c97e9e5" [[package]] name = "jsonrpc-client-transports" -version = "14.1.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2307a7e78cf969759e390a8a2151ea12e783849a45bb00aa871b468ba58ea79e" +checksum = "15b6c6ad01c7354d60de493148c30ac8a82b759e22ae678c8705e9b8e0c566a4" dependencies = [ - "failure", - "futures", + "derive_more", + "futures 0.3.12", "jsonrpc-core", "jsonrpc-pubsub", "jsonrpc-server-utils", @@ -1081,11 +1115,11 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "14.1.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25525f6002338fb4debb5167a89a0b47f727a5a48418417545ad3429758b7fec" +checksum = "07569945133257ff557eb37b015497104cea61a2c9edaf126c1cbd6e8332397f" dependencies = [ - "futures", + "futures 0.3.12", "log", "serde", "serde_derive", @@ -1094,18 +1128,19 @@ dependencies = [ [[package]] name = "jsonrpc-core-client" -version = "14.1.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f9382e831a6d630c658df103aac3f971da096deb57c136ea2b760d3b4e3f9f" +checksum = "7ac9d56dc729912796637c30f475bbf834594607b27740dfea6e5fa7ba40d1f1" dependencies = [ + "futures 0.3.12", "jsonrpc-client-transports", ] [[package]] name = "jsonrpc-derive" -version = "14.0.5" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8609af8f63b626e8e211f52441fcdb6ec54f1a446606b10d5c89ae9bf8a20058" +checksum = "b68ba7e76e5c7796cfa4d2a30e83986550c34404c6d40551c902ca6f7bd4a137" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1115,43 +1150,48 @@ dependencies = [ [[package]] name = "jsonrpc-ipc-server" -version = "14.0.3" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b579cd0840d7db3ebaadf52f6f31ec601a260e78d610e44f68634f919e34497a" +checksum = "2c4f73afac937f899d1603bb8ce19c048e22d87fd83a654126f93e3d238c027b" dependencies = [ + "futures 0.3.12", "jsonrpc-core", "jsonrpc-server-utils", "log", "parity-tokio-ipc", - "parking_lot 0.9.0", - "tokio-service", + "parking_lot", + "tower-service", ] [[package]] name = "jsonrpc-pubsub" -version = "14.1.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4ca5e391d6c6a2261d4adca029f427fe63ea546ad6cef2957c654c08495ec16" +checksum = "0c48dbebce7a9c88ab272a4db7d6478aa4c6d9596e6c086366e89efc4e9ed89e" dependencies = [ + "futures 0.3.12", "jsonrpc-core", + "lazy_static", "log", - "parking_lot 0.10.2", + "parking_lot", + "rand", "serde", ] [[package]] name = "jsonrpc-server-utils" -version = "14.1.0" +version = "17.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f06add502b48351e05dd95814835327fb115e4e9f834ca42fd522d3b769d4d2" +checksum = "f4207cce738bf713a82525065b750a008f28351324f438f56b33d698ada95bb4" dependencies = [ "bytes", + "futures 0.3.12", "globset", "jsonrpc-core", "lazy_static", "log", "tokio", - "tokio-codec", + "tokio-util", "unicase", ] @@ -1233,15 +1273,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "lock_api" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] - [[package]] name = "lock_api" version = "0.4.1" @@ -1262,13 +1293,13 @@ dependencies = [ [[package]] name = "lsp-codec" -version = "0.1.2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "169d737ad89cf8ddd82d1804d9122f54568c49377665157277cc90d747b1d31a" +checksum = "d33c83e320715a1e7e0466a53db2238becb2e5c446deff5506abc81aeacc5ec4" dependencies = [ "bytes", "serde_json", - "tokio-codec", + "tokio-util", ] [[package]] @@ -1313,9 +1344,9 @@ version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22bf8d885d073610aee20e7fa205c4341ed32a761dbde96da5fd96301a8d3e82" dependencies = [ - "parking_lot 0.11.0", + "parking_lot", "rustc-hash", - "smallvec 1.4.0", + "smallvec", ] [[package]] @@ -1427,6 +1458,12 @@ dependencies = [ "libc", ] +[[package]] +name = "once_cell" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" + [[package]] name = "opaque-debug" version = "0.3.0" @@ -1483,43 +1520,20 @@ checksum = "dd20eec3dbe4376829cb7d80ae6ac45e0a766831dca50202ff2d40db46a8a024" [[package]] name = "parity-tokio-ipc" -version = "0.2.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8281bf4f1d6429573f89589bf68d89451c46750977a8264f8ea3edbabeba7947" +checksum = "fd7f6c69d7687501b2205fe51ade1d7b8797bb3aa141fe5bf13dd78c0483bc89" dependencies = [ - "bytes", - "futures", + "futures 0.3.12", + "libc", "log", "mio-named-pipes", "miow 0.3.6", "rand", "tokio", - "tokio-named-pipes", - "tokio-uds", "winapi 0.3.8", ] -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.7.2", -] - [[package]] name = "parking_lot" version = "0.11.0" @@ -1527,37 +1541,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" dependencies = [ "instant", - "lock_api 0.4.1", - "parking_lot_core 0.8.0", -] - -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.0.3", - "libc", - "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi 0.0.3", - "libc", - "redox_syscall", - "smallvec 1.4.0", - "winapi 0.3.8", + "lock_api", + "parking_lot_core", ] [[package]] @@ -1567,11 +1552,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" dependencies = [ "cfg-if 0.1.10", - "cloudabi 0.1.0", + "cloudabi", "instant", "libc", "redox_syscall", - "smallvec 1.4.0", + "smallvec", "winapi 0.3.8", ] @@ -1587,6 +1572,24 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pin-project-lite" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" + +[[package]] +name = "pin-project-lite" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "pkg-config" version = "0.3.17" @@ -1634,6 +1637,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.24" @@ -1677,9 +1692,9 @@ checksum = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" [[package]] name = "quote" -version = "1.0.4" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c1f4b0efa5fc5e8ceb705136bfee52cfdb6a4e3509f770b478cd6ed434232a7" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" dependencies = [ "proc-macro2", ] @@ -1836,7 +1851,7 @@ dependencies = [ "crossbeam-channel", "difference", "env_logger 0.7.1", - "futures", + "futures 0.3.12", "heck", "home", "itertools 0.8.2", @@ -1866,8 +1881,7 @@ dependencies = [ "serde_json", "tempfile", "tokio", - "tokio-process", - "tokio-timer", + "tokio-util", "toml", "url 2.1.1", "walkdir", @@ -1918,7 +1932,7 @@ version = "0.6.0" dependencies = [ "clippy_lints 0.0.212 (git+https://github.com/rust-lang/rust-clippy?rev=d236b30a1d638340aad8345fa2946cfe9543dcf0)", "env_logger 0.7.1", - "futures", + "futures 0.3.12", "log", "rand", "rls-data", @@ -1964,7 +1978,7 @@ version = "697.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb953bea2006184c8f01a6fd3ed51658c73380992a9aefc113e8d32ece6b7516" dependencies = [ - "smallvec 1.4.0", + "smallvec", ] [[package]] @@ -1980,7 +1994,7 @@ dependencies = [ "rustc-ap-rustc_macros", "rustc-ap-rustc_serialize", "rustc-ap-rustc_span", - "smallvec 1.4.0", + "smallvec", "tracing", ] @@ -2049,7 +2063,7 @@ dependencies = [ "jobserver", "libc", "measureme", - "parking_lot 0.11.0", + "parking_lot", "rustc-ap-rustc_graphviz", "rustc-ap-rustc_index", "rustc-ap-rustc_macros", @@ -2057,7 +2071,7 @@ dependencies = [ "rustc-hash", "rustc-rayon", "rustc-rayon-core", - "smallvec 1.4.0", + "smallvec", "stable_deref_trait", "stacker", "tempfile", @@ -2104,7 +2118,7 @@ dependencies = [ "rustc-ap-rustc_serialize", "rustc-ap-rustc_session", "rustc-ap-rustc_span", - "smallvec 1.4.0", + "smallvec", "tracing", ] @@ -2191,7 +2205,7 @@ dependencies = [ "rustc-ap-rustc_lexer", "rustc-ap-rustc_session", "rustc-ap-rustc_span", - "smallvec 1.4.0", + "smallvec", "tracing", "unicode-normalization", ] @@ -2203,7 +2217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7ed5df71bd37d1e179b4bbedf77db76c9e0eb2e03159c58a691adbf29f74682" dependencies = [ "indexmap", - "smallvec 1.4.0", + "smallvec", ] [[package]] @@ -2263,12 +2277,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "rustc-demangle" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -2311,15 +2319,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b725dadae9fabc488df69a287f5a99c5eaf5d10853842a8a3dfac52476f544ee" -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustfix" version = "0.5.1" @@ -2531,11 +2530,10 @@ checksum = "170a13e64f2a51b77a45702ba77287f5c6829375b04a69cf2222acd17d0cfab9" [[package]] name = "signal-hook-registry" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ - "arc-swap", "libc", ] @@ -2555,15 +2553,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -[[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.4.0" @@ -2767,242 +2756,50 @@ dependencies = [ [[package]] name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes", - "futures", - "mio", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes", - "futures", - "tokio-io", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -dependencies = [ - "futures", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes", - "futures", - "log", -] - -[[package]] -name = "tokio-named-pipes" -version = "0.1.0" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d282d483052288b2308ba5ee795f5673b159c9bdf63c385a05609da782a5eae" +checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48" dependencies = [ "bytes", - "futures", - "mio", - "mio-named-pipes", - "tokio", -] - -[[package]] -name = "tokio-process" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382d90f43fa31caebe5d3bc6cfd854963394fff3b8cb59d5146607aaae7e7e43" -dependencies = [ - "crossbeam-queue 0.1.2", - "futures", + "futures-core", + "iovec", "lazy_static", "libc", - "log", + "memchr", "mio", "mio-named-pipes", - "tokio-io", - "tokio-reactor", - "tokio-signal", - "winapi 0.3.8", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-service" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24da22d077e0f15f55162bdbdc661228c1581892f52074fb242678d015b45162" -dependencies = [ - "futures", -] - -[[package]] -name = "tokio-signal" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c34c6e548f101053321cba3da7cbb87a610b85555884c41b07da2eb91aff12" -dependencies = [ - "futures", - "libc", - "mio", "mio-uds", - "signal-hook-registry", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "winapi 0.3.8", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes", - "futures", - "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue 0.2.1", - "crossbeam-utils 0.7.2", - "futures", - "lazy_static", - "log", "num_cpus", + "pin-project-lite 0.1.11", + "signal-hook-registry", "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures", - "slab", - "tokio-executor", + "tokio-macros", + "winapi 0.3.8", ] [[package]] -name = "tokio-udp" -version = "0.1.6" +name = "tokio-macros" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" dependencies = [ - "bytes", - "futures", - "log", - "mio", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "tokio-uds" -version = "0.2.6" +name = "tokio-util" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5076db410d6fdc6523df7595447629099a1fdc47b3d9f896220780fa48faf798" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ "bytes", - "futures", - "iovec", - "libc", + "futures-core", + "futures-sink", "log", - "mio", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "pin-project-lite 0.1.11", + "tokio", ] [[package]] @@ -3014,6 +2811,12 @@ dependencies = [ "serde", ] +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + [[package]] name = "tracing" version = "0.1.19" @@ -3075,7 +2878,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" dependencies = [ - "smallvec 1.4.0", + "smallvec", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 716eff76483..47b55cd111c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,10 +34,9 @@ cargo = { git = "https://github.com/rust-lang/cargo", rev = "329895f5b52a358e5d9 cargo_metadata = "0.8" clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", rev = "7ea7cd165ad6705603852771bf82cc2fd6560db5", optional = true } env_logger = "0.7" -futures = { version = "0.1", optional = true } home = "0.5.1" itertools = "0.8" -jsonrpc-core = "14" +jsonrpc-core = "17" lsp-types = { version = "0.60", features = ["proposed"] } lazy_static = "1" log = "0.4" @@ -51,7 +50,6 @@ serde = "1.0" serde_json = "1.0" serde_derive = "1.0" serde_ignored = "0.1" -tokio = { version = "0.1", optional = true } url = "2" walkdir = "2" regex = "1" @@ -68,16 +66,15 @@ rustc-workspace-hack = "1.0.0" [dev-dependencies] difference = "2" tempfile = "3" -lsp-codec = "0.1.2" -tokio = "0.1" -futures = "0.1" -tokio-process = "0.2" -tokio-timer = "0.2" +lsp-codec = "0.2" +tokio = { version = "0.2", default-features = false, features = ["rt-core", "time", "io-util", "process", "rt-util"] } +tokio-util = { version = "0.3", default-features = false, features = ["codec"] } +futures = "0.3" [build-dependencies] rustc_tools_util = "0.2" [features] clippy = ["clippy_lints", "rls-rustc/clippy"] -ipc = ["tokio", "futures", "rls-rustc/ipc", "rls-ipc/server"] +ipc = ["rls-rustc/ipc", "rls-ipc/server"] default = ["ipc"] diff --git a/rls-ipc/Cargo.toml b/rls-ipc/Cargo.toml index 940d8b10528..5b711c7c33b 100644 --- a/rls-ipc/Cargo.toml +++ b/rls-ipc/Cargo.toml @@ -9,11 +9,10 @@ repository = "https://github.com/rust-lang/rls" categories = ["development-tools"] [dependencies] -jsonrpc-core = "14" -jsonrpc-core-client = "14" -jsonrpc-derive = "14" -# Pin 14.0.3 to use single parity-tokio-ipc version (0.2) -jsonrpc-ipc-server = { version = "=14.0.3", optional = true } +jsonrpc-core = "17" +jsonrpc-core-client = "17" +jsonrpc-derive = "17" +jsonrpc-ipc-server = { version = "17", optional = true } rls-data = "0.19" serde = { version = "1.0", features = ["derive"] } diff --git a/rls-rustc/Cargo.toml b/rls-rustc/Cargo.toml index f7a8f1eb000..2f940dc5eaf 100644 --- a/rls-rustc/Cargo.toml +++ b/rls-rustc/Cargo.toml @@ -13,8 +13,8 @@ env_logger = "0.7" log = "0.4" rand = "0.7" clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", rev = "d236b30a1d638340aad8345fa2946cfe9543dcf0", optional = true } -tokio = { version = "0.1", optional = true } -futures = { version = "0.1", optional = true } +tokio = { version = "0.2", optional = true } +futures = { version = "0.3", optional = true } serde = { version = "1", features = ["derive"], optional = true } rls-data = { version = "0.19", optional = true } rls-ipc = { path = "../rls-ipc", optional = true } diff --git a/rls-rustc/src/ipc.rs b/rls-rustc/src/ipc.rs index 394d9f0c29f..deff415abf6 100644 --- a/rls-rustc/src/ipc.rs +++ b/rls-rustc/src/ipc.rs @@ -1,9 +1,8 @@ use std::collections::{HashMap, HashSet}; +use std::future::Future; use std::io; use std::path::{Path, PathBuf}; -use futures::Future; - use rls_ipc::client::{Client as JointClient, RpcChannel, RpcError}; use rls_ipc::rpc::callbacks::Client as CallbacksClient; use rls_ipc::rpc::file_loader::Client as FileLoaderClient; @@ -30,13 +29,11 @@ impl IpcFileLoader { impl rustc_span::source_map::FileLoader for IpcFileLoader { fn file_exists(&self, path: &Path) -> bool { - self.0.file_exists(path.to_owned()).wait().unwrap() + futures::executor::block_on(self.0.file_exists(path.to_owned())).unwrap() } fn read_file(&self, path: &Path) -> io::Result { - self.0 - .read_file(path.to_owned()) - .wait() + futures::executor::block_on(self.0.read_file(path.to_owned())) .map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e))) } } @@ -48,14 +45,14 @@ impl IpcCallbacks { pub fn complete_analysis( &self, analysis: rls_data::Analysis, - ) -> impl Future { + ) -> impl Future> { self.0.complete_analysis(analysis) } pub fn input_files( &self, input_files: HashMap>, - ) -> impl Future { + ) -> impl Future> { self.0.input_files(input_files) } } diff --git a/rls-rustc/src/lib.rs b/rls-rustc/src/lib.rs index 287ccc1090d..9dd21175cf3 100644 --- a/rls-rustc/src/lib.rs +++ b/rls-rustc/src/lib.rs @@ -34,12 +34,9 @@ pub fn run() -> Result<(), ()> { #[cfg(feature = "ipc")] let (mut shim_calls, file_loader) = match std::env::var("RLS_IPC_ENDPOINT").ok() { Some(endpoint) => { - #[allow(deprecated)] // Windows doesn't work with lazily-bound reactors - let reactor = rt.reactor().clone(); - let connection = - ipc::connect(endpoint, &reactor).expect("Couldn't connect to IPC endpoint"); - let client: ipc::Client = - rt.block_on(connection).expect("Couldn't connect to IPC endpoint"); + let client: ipc::Client = rt + .block_on(async { ipc::connect(endpoint).await }) + .expect("Couldn't connect to IPC endpoint"); let (file_loader, callbacks) = client.split(); ( @@ -113,7 +110,6 @@ impl Callbacks for ShimCalls { ) -> Compilation { use rustc_session::config::Input; - use futures::future::Future; use rls_ipc::rpc::{Crate, Edition}; use std::collections::{HashMap, HashSet}; @@ -149,7 +145,7 @@ impl Callbacks for ShimCalls { input_files.entry(file).or_default().insert(krate.clone()); } - if let Err(e) = callbacks.input_files(input_files).wait() { + if let Err(e) = futures::executor::block_on(callbacks.input_files(input_files)) { log::error!("Can't send input files as part of a compilation callback: {:?}", e); } @@ -162,8 +158,6 @@ impl Callbacks for ShimCalls { compiler: &interface::Compiler, queries: &'tcx Queries<'tcx>, ) -> Compilation { - use futures::future::Future; - let callbacks = match self.callbacks.as_ref() { Some(callbacks) => callbacks, None => return Compilation::Continue, @@ -196,7 +190,9 @@ impl Callbacks for ShimCalls { CallbackHandler { callback: &mut |a| { let analysis = unsafe { ::std::mem::transmute(a.clone()) }; - if let Err(e) = callbacks.complete_analysis(analysis).wait() { + if let Err(e) = + futures::executor::block_on(callbacks.complete_analysis(analysis)) + { log::error!( "Can't send analysis as part of a compilation callback: {:?}", e diff --git a/rls/src/build/ipc.rs b/rls/src/build/ipc.rs index c65f4b0b2ae..a356f01908a 100644 --- a/rls/src/build/ipc.rs +++ b/rls/src/build/ipc.rs @@ -57,13 +57,7 @@ pub fn start_with_handler(io: IoHandler) -> Result { let endpoint_path = endpoint_path.clone(); move || { log::trace!("Attempting to spin up IPC server at {}", endpoint_path); - let runtime = tokio::runtime::Builder::new().core_threads(1).build().unwrap(); - #[allow(deprecated)] // Windows won't work with lazily bound reactor - let (reactor, executor) = (runtime.reactor(), runtime.executor()); - let server = ServerBuilder::new(io) - .event_loop_executor(executor) - .event_loop_reactor(reactor.clone()) .start(&endpoint_path) .map_err(|_| log::warn!("Couldn't open socket")) .unwrap(); diff --git a/tests/client.rs b/tests/client.rs index b33cb7723ff..de7e9a26cbb 100644 --- a/tests/client.rs +++ b/tests/client.rs @@ -1,8 +1,8 @@ use std::fs; use std::path::Path; -use std::time::{Duration, Instant}; +use std::time::Duration; -use futures::future::Future; +use futures::future; use lsp_types::{notification::*, request::*, *}; use serde::de::Deserialize; use serde_json::json; @@ -245,7 +245,8 @@ fn client_changing_workspace_lib_retains_diagnostics() { let lib = rls.future_diagnostics("library/src/lib.rs"); let bin = rls.future_diagnostics("binary/src/main.rs"); - let (lib, bin) = rls.block_on(lib.join(bin)).unwrap(); + let (lib, bin) = rls.block_on(future::join(lib, bin)).unwrap(); + let (lib, bin) = (lib.unwrap(), bin.unwrap()); assert!(lib.diagnostics.iter().any(|m| m.message.contains("unused variable: `test_val`"))); assert!(lib.diagnostics.iter().any(|m| m.message.contains("unused variable: `unused`"))); @@ -268,7 +269,8 @@ fn client_changing_workspace_lib_retains_diagnostics() { let lib = rls.future_diagnostics("library/src/lib.rs"); let bin = rls.future_diagnostics("binary/src/main.rs"); - let (lib, bin) = rls.block_on(lib.join(bin)).unwrap(); + let (lib, bin) = rls.block_on(future::join(lib, bin)).unwrap(); + let (lib, bin) = (lib.unwrap(), bin.unwrap()); // lib unit tests have compile errors assert!(lib.diagnostics.iter().any(|m| m.message.contains("unused variable: `unused`"))); @@ -293,7 +295,8 @@ fn client_changing_workspace_lib_retains_diagnostics() { let lib = rls.future_diagnostics("library/src/lib.rs"); let bin = rls.future_diagnostics("binary/src/main.rs"); - let (lib, bin) = rls.block_on(lib.join(bin)).unwrap(); + let (lib, bin) = rls.block_on(future::join(lib, bin)).unwrap(); + let (lib, bin) = (lib.unwrap(), bin.unwrap()); assert!(lib.diagnostics.iter().any(|m| m.message.contains("unused variable: `test_val`"))); assert!(lib.diagnostics.iter().any(|m| m.message.contains("unused variable: `unused`"))); @@ -349,6 +352,7 @@ fn client_implicit_workspace_pick_up_lib_changes() { let bin = rls.future_diagnostics("src/main.rs"); let bin = rls.block_on(bin).unwrap(); + let bin = bin.unwrap(); assert!(bin.diagnostics[0].message.contains("unused variable: `val`")); rls.notify::(DidChangeTextDocumentParams { @@ -369,6 +373,7 @@ fn client_implicit_workspace_pick_up_lib_changes() { // bin depending on lib picks up type mismatch let bin = rls.future_diagnostics("src/main.rs"); let bin = rls.block_on(bin).unwrap(); + let bin = bin.unwrap(); assert!(bin.diagnostics[0].message.contains("cannot find function `foo`")); rls.notify::(DidChangeTextDocumentParams { @@ -388,6 +393,7 @@ fn client_implicit_workspace_pick_up_lib_changes() { let bin = rls.future_diagnostics("src/main.rs"); let bin = rls.block_on(bin).unwrap(); + let bin = bin.unwrap(); assert!(bin.diagnostics[0].message.contains("unused variable: `val`")); } @@ -1971,7 +1977,7 @@ fn client_omit_init_build() { // We need to assert that no other messages are received after a short // period of time (e.g. no build progress messages). std::thread::sleep(std::time::Duration::from_secs(1)); - rls.block_on(response).unwrap(); + rls.block_on(response).unwrap().unwrap(); assert_eq!(rls.messages().iter().count(), 1); } @@ -2141,8 +2147,7 @@ fn client_fail_uninitialized_request() { }, ); - let delay = tokio_timer::Delay::new(Instant::now() + Duration::from_secs(1)); - rls.block_on(delay).unwrap(); + rls.block_on(async { tokio::time::delay_for(Duration::from_secs(1)).await }).unwrap(); let err = jsonrpc_core::Failure::deserialize(rls.messages().last().unwrap()).unwrap(); assert_eq!(err.id, jsonrpc_core::Id::Num(ID)); diff --git a/tests/support/client/child_process.rs b/tests/support/client/child_process.rs index a8f2f35f079..c3ec088ddeb 100644 --- a/tests/support/client/child_process.rs +++ b/tests/support/client/child_process.rs @@ -1,36 +1,42 @@ -use std::io::{Read, Write}; +use std::io; +use std::pin::Pin; use std::process::{Command, Stdio}; use std::rc::Rc; +use std::task::{Context, Poll}; -use futures::Poll; use tokio::io::{AsyncRead, AsyncWrite}; -use tokio_process::{Child, CommandExt}; pub struct ChildProcess { - stdin: tokio_process::ChildStdin, - stdout: tokio_process::ChildStdout, - child: Rc, + stdin: tokio::process::ChildStdin, + stdout: tokio::process::ChildStdout, + child: Rc, } -impl Read for ChildProcess { - fn read(&mut self, buf: &mut [u8]) -> std::io::Result { - Read::read(&mut self.stdout, buf) +impl AsyncRead for ChildProcess { + fn poll_read( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + buf: &mut [u8], + ) -> Poll> { + Pin::new(&mut self.stdout).poll_read(cx, buf) } } -impl Write for ChildProcess { - fn write(&mut self, buf: &[u8]) -> std::io::Result { - Write::write(&mut self.stdin, buf) +impl AsyncWrite for ChildProcess { + fn poll_write( + mut self: Pin<&mut Self>, + cx: &mut Context<'_>, + buf: &[u8], + ) -> Poll> { + Pin::new(&mut self.stdin).poll_write(cx, buf) } - fn flush(&mut self) -> std::io::Result<()> { - Write::flush(&mut self.stdin) + + fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + Pin::new(&mut self.stdin).poll_flush(cx) } -} -impl AsyncRead for ChildProcess {} -impl AsyncWrite for ChildProcess { - fn shutdown(&mut self) -> Poll<(), std::io::Error> { - AsyncWrite::shutdown(&mut self.stdin) + fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { + Pin::new(&mut self.stdin).poll_shutdown(cx) } } @@ -38,18 +44,18 @@ impl ChildProcess { pub fn spawn_from_command(mut cmd: Command) -> Result { cmd.stdin(Stdio::piped()); cmd.stdout(Stdio::piped()); - let mut child = cmd.spawn_async()?; + let mut child = tokio::process::Command::from(cmd).spawn().expect("to async spawn process"); Ok(ChildProcess { - stdout: child.stdout().take().unwrap(), - stdin: child.stdin().take().unwrap(), + stdout: child.stdout.take().unwrap(), + stdin: child.stdin.take().unwrap(), child: Rc::new(child), }) } /// Returns a handle to the underlying `Child` process. /// Useful when waiting until child process exits. - pub fn child(&self) -> Rc { + pub fn child(&self) -> Rc { Rc::clone(&self.child) } } diff --git a/tests/support/client/mod.rs b/tests/support/client/mod.rs index 6847363a8e0..ccdc56f0984 100644 --- a/tests/support/client/mod.rs +++ b/tests/support/client/mod.rs @@ -11,28 +11,26 @@ //! receiver (thus, implementing the Future model). use std::cell::{Ref, RefCell}; +use std::future::Future; use std::process::{Command, Stdio}; use std::rc::Rc; -use futures::sink::Sink; -use futures::stream::{SplitSink, Stream}; -use futures::unsync::oneshot; -use futures::Future; +use futures::channel::oneshot; +use futures::stream::SplitSink; +use futures::StreamExt; use lsp_codec::LspCodec; use lsp_types::notification::{Notification, PublishDiagnostics}; use lsp_types::PublishDiagnosticsParams; use serde::Deserialize; use serde_json::{json, Value}; use tokio::io::{AsyncRead, AsyncWrite}; -use tokio::runtime::current_thread::Runtime; -use tokio::util::{FutureExt, StreamExt}; +use tokio::runtime::Runtime; use super::project_builder::Project; use super::{rls_exe, rls_timeout}; -use child_process::ChildProcess; - mod child_process; +use child_process::ChildProcess; // `Rc` because we share those in message reader stream and the RlsHandle. // `RefCell` because borrows don't overlap. This is safe, because `process_msg` @@ -42,7 +40,7 @@ mod child_process; type Messages = Rc>>; type Channels = Rc bool>, oneshot::Sender)>>>; -type LspFramed = tokio::codec::Framed; +type LspFramed = tokio_util::codec::Framed; trait LspFramedExt { fn from_transport(transport: T) -> Self; @@ -50,7 +48,7 @@ trait LspFramedExt { impl LspFramedExt for LspFramed { fn from_transport(transport: T) -> Self { - tokio::codec::Framed::new(transport, LspCodec::default()) + tokio_util::codec::Framed::new(transport, LspCodec::default()) } } @@ -68,39 +66,55 @@ impl Project { } pub fn spawn_rls_async(&self) -> RlsHandle { - let rt = Runtime::new().unwrap(); + let rt = tokio::runtime::Builder::new() + .basic_scheduler() + .enable_all() + .core_threads(1) + .build() + .unwrap(); let cmd = self.rls_cmd(); - let process = ChildProcess::spawn_from_command(cmd).unwrap(); - + let process = rt.enter(|| ChildProcess::spawn_from_command(cmd).unwrap()); self.spawn_rls_with_params(rt, process) } - fn spawn_rls_with_params(&self, mut rt: Runtime, transport: T) -> RlsHandle + fn spawn_rls_with_params(&self, runtime: Runtime, transport: T) -> RlsHandle where T: AsyncRead + AsyncWrite + 'static, { let (finished_reading, reader_closed) = oneshot::channel(); - let msgs = Messages::default(); - let chans = Channels::default(); + let messages = Messages::default(); + let channels = Channels::default(); + + let (writer, stream) = LspFramed::from_transport(transport).split(); - let (sink, stream) = LspFramed::from_transport(transport).split(); + let msgs = Rc::clone(&messages); + let chans = Rc::clone(&channels); + let local_set = tokio::task::LocalSet::new(); + // Our message handler loop is tied to a single thread, so spawn it on + // a `LocalSet` and keep it around to progress the message processing #[allow(clippy::unit_arg)] // We're interested in the side-effects of `process_msg`. - let reader = stream - .timeout(rls_timeout()) - .map_err(|_| ()) - .for_each({ - let msgs = Rc::clone(&msgs); - let chans = Rc::clone(&chans); - move |msg| Ok(process_msg(msg, msgs.clone(), chans.clone())) - }) - .and_then(move |_| finished_reading.send(())); - rt.spawn(reader); - - let sink = Some(sink); - - RlsHandle { writer: sink, runtime: rt, reader_closed, messages: msgs, channels: chans } + local_set.spawn_local(async move { + use futures::TryStreamExt; + use tokio::stream::StreamExt; + + stream + .timeout(rls_timeout()) + .map_err(drop) + .for_each(move |msg| { + futures::future::ready({ + if let Ok(Ok(msg)) = msg { + process_msg(msg, msgs.clone(), chans.clone()) + } + }) + }) + .await; + + let _ = finished_reading.send(()); + }); + + RlsHandle { writer: Some(writer), runtime, local_set, reader_closed, messages, channels } } } @@ -144,11 +158,12 @@ pub struct RlsHandle { /// sanity check, after sending Shutdown request. reader_closed: oneshot::Receiver<()>, /// Asynchronous LSP writer. - writer: Option>>, + writer: Option, Value>>, /// Tokio single-thread runtime onto which LSP message reading task has /// been spawned. Allows to synchronously write messages via `writer` and /// block on received messages matching an enqueued predicate in `channels`. runtime: Runtime, + local_set: tokio::task::LocalSet, /// Handle to all of the received LSP messages. messages: Messages, /// Handle to enqueued channel senders, used to notify when a given message @@ -163,13 +178,9 @@ impl RlsHandle { } /// Block on returned, associated future with a timeout. - pub fn block_on( - &mut self, - f: F, - ) -> Result> { - let future_with_timeout = f.timeout(rls_timeout()); - - self.runtime.block_on(future_with_timeout) + pub fn block_on(&mut self, f: F) -> Result { + self.local_set + .block_on(&mut self.runtime, async { tokio::time::timeout(rls_timeout(), f).await }) } /// Send a request to the RLS and block until we receive the message. @@ -210,13 +221,15 @@ impl RlsHandle { /// Synchronously sends a message to the RLS. pub fn send(&mut self, msg: Value) { + use futures::SinkExt; eprintln!("Sending: {:?}", msg); - let writer = self.writer.take().unwrap(); + let mut writer = self.writer.take().unwrap(); - let fut = writer.send(msg); + let fut = SinkExt::send(&mut writer, msg); - self.writer = Some(self.block_on(fut).unwrap()); + self.block_on(fut).unwrap().unwrap(); + self.writer = Some(writer); } /// Enqueues a channel that is notified and consumed when a given predicate @@ -224,7 +237,7 @@ impl RlsHandle { pub fn future_msg( &mut self, f: impl Fn(&Value) -> bool + 'static, - ) -> impl Future { + ) -> impl Future> + 'static { let (tx, rx) = oneshot::channel(); self.channels.borrow_mut().push((Box::new(f), tx)); @@ -237,19 +250,19 @@ impl RlsHandle { pub fn future_diagnostics( &mut self, path: impl AsRef + 'static, - ) -> impl Future { + ) -> impl Future> { + use futures::TryFutureExt; self.future_msg(move |msg| msg["method"] == PublishDiagnostics::METHOD && msg["params"]["uri"].as_str().unwrap().ends_with(path.as_ref()) - ) - .and_then(|msg| Ok(PublishDiagnosticsParams::deserialize(&msg["params"]).unwrap())) + ).and_then(|msg| async move { Ok(PublishDiagnosticsParams::deserialize(&msg["params"]).unwrap())}) } /// Blocks until a message, for which predicate `f` returns true, is received. pub fn wait_for_message(&mut self, f: impl Fn(&Value) -> bool + 'static) -> Value { let fut = self.future_msg(f); - self.block_on(fut).unwrap() + self.block_on(fut).unwrap().unwrap() } /// Blocks until the processing (building + indexing) is done by the RLS. @@ -277,8 +290,7 @@ impl Drop for RlsHandle { // Wait until the underlying connection is closed. let (_, dummy) = oneshot::channel(); let reader_closed = std::mem::replace(&mut self.reader_closed, dummy); - let reader_closed = reader_closed.timeout(rls_timeout()); - self.runtime.block_on(reader_closed).unwrap(); + self.block_on(reader_closed).unwrap().unwrap(); } }