From 1ad0581ddd2d1fc6eb8b96b495eb4e546d4bdd28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= <blaz@mxxn.io>
Date: Thu, 6 May 2021 14:33:53 +0900
Subject: [PATCH] Eliminate a few more futures dependencies.

---
 Cargo.lock                    | 60 ++---------------------------------
 helix-lsp/Cargo.toml          |  5 +--
 helix-term/Cargo.toml         |  2 +-
 helix-term/src/application.rs | 12 +++----
 helix-view/Cargo.toml         |  1 -
 5 files changed, 13 insertions(+), 67 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 2e6292d9..de62a98e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -185,54 +185,12 @@ dependencies = [
  "new_debug_unreachable",
 ]
 
-[[package]]
-name = "futures"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
-dependencies = [
- "futures-channel",
- "futures-core",
- "futures-executor",
- "futures-io",
- "futures-sink",
- "futures-task",
- "futures-util",
-]
-
-[[package]]
-name = "futures-channel"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
-dependencies = [
- "futures-core",
- "futures-sink",
-]
-
 [[package]]
 name = "futures-core"
 version = "0.3.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
 
-[[package]]
-name = "futures-executor"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d"
-dependencies = [
- "futures-core",
- "futures-task",
- "futures-util",
-]
-
-[[package]]
-name = "futures-io"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
-
 [[package]]
 name = "futures-macro"
 version = "0.3.14"
@@ -245,12 +203,6 @@ dependencies = [
  "syn",
 ]
 
-[[package]]
-name = "futures-sink"
-version = "0.3.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
-
 [[package]]
 name = "futures-task"
 version = "0.3.14"
@@ -263,13 +215,9 @@ version = "0.3.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
 dependencies = [
- "futures-channel",
  "futures-core",
- "futures-io",
  "futures-macro",
- "futures-sink",
  "futures-task",
- "memchr",
  "pin-project-lite",
  "pin-utils",
  "proc-macro-hack",
@@ -405,7 +353,6 @@ version = "0.1.0"
 dependencies = [
  "anyhow",
  "crossterm",
- "futures-util",
  "helix-core",
  "helix-lsp",
  "once_cell",
@@ -491,11 +438,10 @@ dependencies = [
 
 [[package]]
 name = "jsonrpc-core"
-version = "17.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07569945133257ff557eb37b015497104cea61a2c9edaf126c1cbd6e8332397f"
+version = "17.1.0"
+source = "git+https://github.com/paritytech/jsonrpc#609d7a6cc160742d035510fa89fb424ccf077660"
 dependencies = [
- "futures",
+ "futures-util",
  "log",
  "serde",
  "serde_derive",
diff --git a/helix-lsp/Cargo.toml b/helix-lsp/Cargo.toml
index 24bb2080..09351f97 100644
--- a/helix-lsp/Cargo.toml
+++ b/helix-lsp/Cargo.toml
@@ -21,7 +21,8 @@ glob = "0.3"
 anyhow = "1"
 serde_json = "1.0"
 serde = { version = "1.0", features = ["derive"] }
-jsonrpc-core = "17.0"
-futures-util = "0.3"
+# jsonrpc-core = { version = "17.1", default-features = false } # don't pull in all of futures
+jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc", default-features = false } # don't pull in all of futures
+futures-util = { version = "0.3", features = ["std", "async-await"] }
 thiserror = "1.0"
 log = "~0.4"
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index b9f27cae..73468f4d 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -25,7 +25,7 @@ tui = { version = "0.15", default-features = false, features = ["crossterm"] }
 crossterm = { version = "0.19", features = ["event-stream"] }
 clap = { version = "3.0.0-beta.2 ", default-features = false, features = ["std", "cargo"] }
 
-futures-util = "0.3"
+futures-util = { version = "0.3", features = ["std", "async-await"] }
 
 # Logging
 fern = "0.6"
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 3bf746ea..9838998a 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -23,7 +23,6 @@ use crossterm::{
 
 use tui::layout::Rect;
 
-// use futures_util::future::BoxFuture;
 use futures_util::stream::FuturesUnordered;
 use std::pin::Pin;
 
@@ -92,15 +91,16 @@ impl Application {
                 break;
             }
 
-            use futures_util::{select, FutureExt, StreamExt};
-            select! {
-                event = reader.next().fuse() => {
+            use futures_util::StreamExt;
+
+            tokio::select! {
+                event = reader.next() => {
                     self.handle_terminal_events(event)
                 }
-                call = futures_util::StreamExt::select_next_some(&mut self.editor.language_servers.incoming) => {
+                Some(call) = self.editor.language_servers.incoming.next() => {
                     self.handle_language_server_message(call).await
                 }
-                callback = futures_util::StreamExt::select_next_some(&mut self.callbacks) => {
+                Some(callback) = &mut self.callbacks.next() => {
                     self.handle_language_server_callback(callback)
                 }
             }
diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml
index 2ed58707..b9d07d01 100644
--- a/helix-view/Cargo.toml
+++ b/helix-view/Cargo.toml
@@ -22,7 +22,6 @@ once_cell = "1.4"
 url = "2"
 
 tokio = { version = "1", features = ["full"] }
-futures-util = "0.3"
 
 slotmap = "1"