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

Bump to Tokio 1.0 #1741

Merged
merged 5 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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