Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Auto merge of #1741 - rust-lang:bump-to-tokio-1.0, r=Xanewok
Browse files Browse the repository at this point in the history
Bump to Tokio 1.0

Closes #1695
Closes #1693

Just enabled by tokio-rs/tokio#3388.

Work in progress to prune winapi 0.2, still needs patches upstreamed that migrate `parity-tokio-ipc` and `jsonrpc-*` crates to Tokio 1.0. Let's see what CI has to say, first.

Blocked on:
- [x] paritytech/parity-tokio-ipc#32
- [x] paritytech/jsonrpc#628
  • Loading branch information
bors committed Aug 24, 2021
2 parents 3a0079a + f612dfd commit 7dfa30b
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 214 deletions.
273 changes: 82 additions & 191 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", rev = "a55912
env_logger = "0.7"
home = "0.5.1"
itertools = "0.9"
jsonrpc-core = "17"
jsonrpc-core = "18"
lsp-types = { version = "0.60", features = ["proposed"] }
lazy_static = "1"
log = "0.4"
Expand Down Expand Up @@ -68,9 +68,10 @@ rustc-workspace-hack = "1.0.0"
[dev-dependencies]
difference = "2"
tempfile = "3"
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"] }
lsp-codec = "0.3"
tokio = { version = "1", default-features = false, features = ["rt", "time", "io-util", "process"] }
tokio-util = { version = "0.6", default-features = false, features = ["codec"] }
tokio-stream = "0.1"
futures = "0.3"

[build-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions rls-ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ repository = "https://github.com/rust-lang/rls"
categories = ["development-tools"]

[dependencies]
jsonrpc-core = "17"
jsonrpc-core-client = "17"
jsonrpc-derive = "17"
jsonrpc-ipc-server = { version = "17", optional = true }
jsonrpc-core = "18"
jsonrpc-core-client = "18"
jsonrpc-derive = "18"
jsonrpc-ipc-server = { version = "18", optional = true }
rls-data = "0.19"
serde = { version = "1.0", features = ["derive"] }

Expand Down
2 changes: 1 addition & 1 deletion rls-rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env_logger = "0.7"
log = "0.4"
rand = "0.7"
clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", rev = "a55912c48e4ac08c0ac39a2d562b44699fa20d4d", optional = true }
tokio = { version = "0.2", optional = true }
tokio = { version = "1", optional = true }
futures = { version = "0.3", optional = true }
serde = { version = "1", features = ["derive"], optional = true }
rls-data = { version = "0.19", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion rls-rustc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod ipc;

pub fn run() -> Result<(), ()> {
#[cfg(feature = "ipc")]
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
#[cfg(feature = "clippy")]
let clippy_preference = clippy::preference();

Expand Down
2 changes: 1 addition & 1 deletion tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ fn client_fail_uninitialized_request() {
},
);

rls.block_on(async { tokio::time::delay_for(Duration::from_secs(1)).await }).unwrap();
rls.block_on(async { tokio::time::sleep(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));
Expand Down
6 changes: 3 additions & 3 deletions tests/support/client/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::{Command, Stdio};
use std::rc::Rc;
use std::task::{Context, Poll};

use tokio::io::{AsyncRead, AsyncWrite};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

pub struct ChildProcess {
stdin: tokio::process::ChildStdin,
Expand All @@ -16,8 +16,8 @@ impl AsyncRead for ChildProcess {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<usize>> {
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> {
Pin::new(&mut self.stdout).poll_read(cx, buf)
}
}
Expand Down
15 changes: 6 additions & 9 deletions tests/support/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,12 @@ impl Project {
}

pub fn spawn_rls_async(&self) -> RlsHandle<ChildProcess> {
let rt = tokio::runtime::Builder::new()
.basic_scheduler()
.enable_all()
.core_threads(1)
.build()
.unwrap();
let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();

let cmd = self.rls_cmd();
let process = rt.enter(|| ChildProcess::spawn_from_command(cmd).unwrap());
let guard = rt.enter();
let process = ChildProcess::spawn_from_command(cmd).unwrap();
drop(guard);
self.spawn_rls_with_params(rt, process)
}

Expand All @@ -97,7 +94,7 @@ impl Project {
#[allow(clippy::unit_arg)] // We're interested in the side-effects of `process_msg`.
local_set.spawn_local(async move {
use futures::TryStreamExt;
use tokio::stream::StreamExt;
use tokio_stream::StreamExt;

stream
.timeout(rls_timeout())
Expand Down Expand Up @@ -178,7 +175,7 @@ impl<T: AsyncRead + AsyncWrite> RlsHandle<T> {
}

/// Block on returned, associated future with a timeout.
pub fn block_on<F: Future>(&mut self, f: F) -> Result<F::Output, tokio::time::Elapsed> {
pub fn block_on<F: Future>(&mut self, f: F) -> Result<F::Output, tokio::time::error::Elapsed> {
self.local_set
.block_on(&mut self.runtime, async { tokio::time::timeout(rls_timeout(), f).await })
}
Expand Down

0 comments on commit 7dfa30b

Please sign in to comment.