diff --git a/Cargo.toml b/Cargo.toml index 677a997fc..ec1b992d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ members = [ "tokio-fs", "tokio-futures", "tokio-io", - "tokio-macros", "tokio-reactor", "tokio-signal", "tokio-sync", diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 31704211a..f0d1fc4fc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,7 +91,7 @@ jobs: - template: ci/azure-check-minrust.yml parameters: name: minrust - rust_version: 1.26.0 + rust_version: 1.28.0 - template: ci/azure-tsan.yml parameters: diff --git a/tokio-buf/tests/buf_stream.rs b/tokio-buf/tests/buf_stream.rs index 35a3f938d..e6f918405 100644 --- a/tokio-buf/tests/buf_stream.rs +++ b/tokio-buf/tests/buf_stream.rs @@ -4,4 +4,4 @@ use tokio_buf::BufStream; // Ensures that `BufStream` can be a trait object #[allow(dead_code)] -fn obj(_: &mut BufStream) {} +fn obj(_: &mut dyn BufStream) {} diff --git a/tokio-current-thread/src/lib.rs b/tokio-current-thread/src/lib.rs index 8dc3ebd14..33f7fa26a 100644 --- a/tokio-current-thread/src/lib.rs +++ b/tokio-current-thread/src/lib.rs @@ -64,7 +64,7 @@ pub struct CurrentThread { spawn_handle: Handle, /// Receiver for futures spawned from other threads - spawn_receiver: mpsc::Receiver + Send + 'static>>, + spawn_receiver: mpsc::Receiver + Send + 'static>>, /// The thread-local ID assigned to this executor. id: u64, @@ -186,11 +186,15 @@ struct Borrow<'a, U: 'a> { } trait SpawnLocal { - fn spawn_local(&mut self, future: Box>, already_counted: bool); + fn spawn_local( + &mut self, + future: Box>, + already_counted: bool, + ); } struct CurrentRunner { - spawn: Cell>, + spawn: Cell>, id: Cell>, } @@ -424,7 +428,7 @@ impl Drop for CurrentThread

{ impl tokio_executor::Executor for CurrentThread { fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError> { self.borrow().spawn_local(future, false); Ok(()) @@ -629,7 +633,7 @@ impl<'a, P: Park> fmt::Debug for Entered<'a, P> { /// Handle to spawn a future on the corresponding `CurrentThread` instance #[derive(Clone)] pub struct Handle { - sender: mpsc::Sender + Send + 'static>>, + sender: mpsc::Sender + Send + 'static>>, num_futures: Arc, shut_down: Cell, notify: executor::NotifyHandle, @@ -731,7 +735,7 @@ impl TaskExecutor { /// Spawn a future onto the current `CurrentThread` instance. pub fn spawn_local( &mut self, - future: Box>, + future: Box>, ) -> Result<(), SpawnError> { CURRENT.with(|current| match current.spawn.get() { Some(spawn) => { @@ -746,7 +750,7 @@ impl TaskExecutor { impl tokio_executor::Executor for TaskExecutor { fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError> { self.spawn_local(future) } @@ -791,7 +795,11 @@ impl<'a, U: Unpark> Borrow<'a, U> { } impl<'a, U: Unpark> SpawnLocal for Borrow<'a, U> { - fn spawn_local(&mut self, future: Box>, already_counted: bool) { + fn spawn_local( + &mut self, + future: Box>, + already_counted: bool, + ) { if !already_counted { // NOTE: we have a borrow of the Runtime, so we know that it isn't shut down. // NOTE: += 2 since LSB is the shutdown bit @@ -804,7 +812,7 @@ impl<'a, U: Unpark> SpawnLocal for Borrow<'a, U> { // ===== impl CurrentRunner ===== impl CurrentRunner { - fn set_spawn(&self, spawn: &mut SpawnLocal, f: F) -> R + fn set_spawn(&self, spawn: &mut dyn SpawnLocal, f: F) -> R where F: FnOnce() -> R, { @@ -819,14 +827,14 @@ impl CurrentRunner { let _reset = Reset(self); - let spawn = unsafe { hide_lt(spawn as *mut SpawnLocal) }; + let spawn = unsafe { hide_lt(spawn as *mut dyn SpawnLocal) }; self.spawn.set(Some(spawn)); f() } } -unsafe fn hide_lt<'a>(p: *mut (SpawnLocal + 'a)) -> *mut (SpawnLocal + 'static) { +unsafe fn hide_lt<'a>(p: *mut (dyn SpawnLocal + 'a)) -> *mut (dyn SpawnLocal + 'static) { use std::mem; mem::transmute(p) } diff --git a/tokio-current-thread/src/scheduler.rs b/tokio-current-thread/src/scheduler.rs index c814b60f7..76b890eb9 100644 --- a/tokio-current-thread/src/scheduler.rs +++ b/tokio-current-thread/src/scheduler.rs @@ -125,7 +125,7 @@ enum Dequeue { } /// Wraps a spawned boxed future -struct Task(Spawn>>); +struct Task(Spawn>>); /// A task that is scheduled. `turn` must be called pub struct Scheduled<'a, U: 'a> { @@ -171,7 +171,7 @@ where self.inner.clone().into() } - pub fn schedule(&mut self, item: Box>) { + pub fn schedule(&mut self, item: Box>) { // Get the current scheduler tick let tick_num = self.inner.tick_num.load(SeqCst); @@ -359,7 +359,7 @@ impl<'a, U: Unpark> Scheduled<'a, U> { } impl Task { - pub fn new(future: Box + 'static>) -> Self { + pub fn new(future: Box + 'static>) -> Self { Task(executor::spawn(future)) } } @@ -687,8 +687,8 @@ unsafe impl UnsafeNotify for ArcNode { } } -unsafe fn hide_lt(p: *mut ArcNode) -> *mut UnsafeNotify { - mem::transmute(p as *mut UnsafeNotify) +unsafe fn hide_lt(p: *mut ArcNode) -> *mut dyn UnsafeNotify { + mem::transmute(p as *mut dyn UnsafeNotify) } impl Node { diff --git a/tokio-current-thread/tests/current_thread.rs b/tokio-current-thread/tests/current_thread.rs index 0ed0ca246..00013f01e 100644 --- a/tokio-current-thread/tests/current_thread.rs +++ b/tokio-current-thread/tests/current_thread.rs @@ -22,7 +22,7 @@ use futures::sync::oneshot; mod from_block_on_all { use super::*; - fn test>) + 'static>(spawn: F) { + fn test>) + 'static>(spawn: F) { let cnt = Rc::new(Cell::new(0)); let c = cnt.clone(); @@ -102,7 +102,7 @@ fn spawn_many() { mod does_not_set_global_executor_by_default { use super::*; - fn test + Send>) -> Result<(), E> + 'static, E>( + fn test + Send>) -> Result<(), E> + 'static, E>( spawn: F, ) { block_on_all(lazy(|| { @@ -127,7 +127,7 @@ mod does_not_set_global_executor_by_default { mod from_block_on_future { use super::*; - fn test>)>(spawn: F) { + fn test>)>(spawn: F) { let cnt = Rc::new(Cell::new(0)); let mut tokio_current_thread = CurrentThread::new(); @@ -181,8 +181,8 @@ mod outstanding_tasks_are_dropped_when_executor_is_dropped { fn test(spawn: F, dotspawn: G) where - F: Fn(Box>) + 'static, - G: Fn(&mut CurrentThread, Box>), + F: Fn(Box>) + 'static, + G: Fn(&mut CurrentThread, Box>), { let mut rc = Rc::new(()); @@ -383,8 +383,8 @@ mod and_turn { fn test(spawn: F, dotspawn: G) where - F: Fn(Box>) + 'static, - G: Fn(&mut CurrentThread, Box>), + F: Fn(Box>) + 'static, + G: Fn(&mut CurrentThread, Box>), { let cnt = Rc::new(Cell::new(0)); let c = cnt.clone(); @@ -459,7 +459,7 @@ mod in_drop { } struct MyFuture { - _data: Box, + _data: Box, } impl Future for MyFuture { @@ -473,8 +473,8 @@ mod in_drop { fn test(spawn: F, dotspawn: G) where - F: Fn(Box>) + 'static, - G: Fn(&mut CurrentThread, Box>), + F: Fn(Box>) + 'static, + G: Fn(&mut CurrentThread, Box>), { let mut tokio_current_thread = CurrentThread::new(); diff --git a/tokio-executor/src/enter.rs b/tokio-executor/src/enter.rs index b005a1ada..1f8ef1a70 100644 --- a/tokio-executor/src/enter.rs +++ b/tokio-executor/src/enter.rs @@ -11,7 +11,7 @@ thread_local!(static ENTERED: Cell = Cell::new(false)); /// /// For more details, see [`enter` documentation](fn.enter.html) pub struct Enter { - on_exit: Vec>, + on_exit: Vec>, permanent: bool, } diff --git a/tokio-executor/src/executor.rs b/tokio-executor/src/executor.rs index 11276d0e8..2a8abc682 100644 --- a/tokio-executor/src/executor.rs +++ b/tokio-executor/src/executor.rs @@ -94,7 +94,7 @@ pub trait Executor { /// ``` fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError>; /// Provides a best effort **hint** to whether or not `spawn` will succeed. @@ -140,7 +140,7 @@ pub trait Executor { impl Executor for Box { fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError> { (**self).spawn(future) } diff --git a/tokio-executor/src/global.rs b/tokio-executor/src/global.rs index 47f7505ca..801341fcf 100644 --- a/tokio-executor/src/global.rs +++ b/tokio-executor/src/global.rs @@ -37,7 +37,7 @@ impl DefaultExecutor { } #[inline] - fn with_current R, R>(f: F) -> Option { + fn with_current R, R>(f: F) -> Option { EXECUTOR.with( |current_executor| match current_executor.replace(State::Active) { State::Ready(executor_ptr) => { @@ -57,7 +57,7 @@ enum State { // default executor not defined Empty, // default executor is defined and ready to be used - Ready(*mut Executor), + Ready(*mut dyn Executor), // default executor is currently active (used to detect recursive calls) Active, } @@ -72,7 +72,7 @@ thread_local! { impl super::Executor for DefaultExecutor { fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError> { DefaultExecutor::with_current(|executor| executor.spawn(future)) .unwrap_or_else(|| Err(SpawnError::shutdown())) @@ -210,7 +210,7 @@ where }) } -unsafe fn hide_lt<'a>(p: *mut (Executor + 'a)) -> *mut (Executor + 'static) { +unsafe fn hide_lt<'a>(p: *mut (dyn Executor + 'a)) -> *mut (dyn Executor + 'static) { use std::mem; mem::transmute(p) } diff --git a/tokio-executor/src/lib.rs b/tokio-executor/src/lib.rs index 165bf67b5..41f502cf5 100644 --- a/tokio-executor/src/lib.rs +++ b/tokio-executor/src/lib.rs @@ -1,7 +1,5 @@ #![deny(missing_docs, missing_debug_implementations, warnings)] #![doc(html_root_url = "https://docs.rs/tokio-executor/0.1.8")] -// Our MSRV doesn't allow us to fix these warnings yet -#![allow(rust_2018_idioms)] //! Task execution related traits and utilities. //! diff --git a/tokio-executor/src/park.rs b/tokio-executor/src/park.rs index 073c4fef3..8626f089a 100644 --- a/tokio-executor/src/park.rs +++ b/tokio-executor/src/park.rs @@ -128,13 +128,13 @@ pub trait Unpark: Sync + Send + 'static { fn unpark(&self); } -impl Unpark for Box { +impl Unpark for Box { fn unpark(&self) { (**self).unpark() } } -impl Unpark for Arc { +impl Unpark for Arc { fn unpark(&self) { (**self).unpark() } diff --git a/tokio-executor/tests/executor.rs b/tokio-executor/tests/executor.rs index bb0202438..8d82c893c 100644 --- a/tokio-executor/tests/executor.rs +++ b/tokio-executor/tests/executor.rs @@ -10,7 +10,7 @@ mod out_of_executor_context { fn test(spawn: F) where - F: Fn(Box + Send>) -> Result<(), E>, + F: Fn(Box + Send>) -> Result<(), E>, { let res = spawn(Box::new(lazy(|| Ok(())))); assert!(res.is_err()); diff --git a/tokio-fs/Cargo.toml b/tokio-fs/Cargo.toml index 46613dd6f..a46a6583e 100644 --- a/tokio-fs/Cargo.toml +++ b/tokio-fs/Cargo.toml @@ -28,8 +28,7 @@ tokio-io = "0.1.6" [dev-dependencies] rand = "0.6" -tempfile = "3" -tempdir = "0.3" +tempfile = ">=3.0.5, <3.1" tokio-io = "0.1.6" tokio-codec = "0.1.0" tokio = "0.1.7" diff --git a/tokio-fs/examples/std-echo.rs b/tokio-fs/examples/std-echo.rs index f7433fba6..d11e98f9f 100644 --- a/tokio-fs/examples/std-echo.rs +++ b/tokio-fs/examples/std-echo.rs @@ -14,7 +14,7 @@ use futures::{Future, Sink, Stream}; use std::io; -pub fn main() -> Result<(), Box> { +pub fn main() -> Result<(), Box> { let pool = Builder::new().pool_size(1).build(); pool.spawn({ diff --git a/tokio-fs/tests/dir.rs b/tokio-fs/tests/dir.rs index 3a1ed351a..5f81a12a7 100644 --- a/tokio-fs/tests/dir.rs +++ b/tokio-fs/tests/dir.rs @@ -1,18 +1,18 @@ extern crate futures; -extern crate tempdir; +extern crate tempfile; extern crate tokio_fs; use futures::{Future, Stream}; use std::fs; use std::sync::{Arc, Mutex}; -use tempdir::TempDir; +use tempfile::tempdir; use tokio_fs::*; mod pool; #[test] fn create() { - let base_dir = TempDir::new("base").unwrap(); + let base_dir = tempdir().unwrap(); let new_dir = base_dir.path().join("foo"); pool::run({ create_dir(new_dir.clone()) }); @@ -22,7 +22,7 @@ fn create() { #[test] fn create_all() { - let base_dir = TempDir::new("base").unwrap(); + let base_dir = tempdir().unwrap(); let new_dir = base_dir.path().join("foo").join("bar"); pool::run({ create_dir_all(new_dir.clone()) }); @@ -32,7 +32,7 @@ fn create_all() { #[test] fn remove() { - let base_dir = TempDir::new("base").unwrap(); + let base_dir = tempdir().unwrap(); let new_dir = base_dir.path().join("foo"); fs::create_dir(new_dir.clone()).unwrap(); @@ -44,7 +44,7 @@ fn remove() { #[test] fn read() { - let base_dir = TempDir::new("base").unwrap(); + let base_dir = tempdir().unwrap(); let p = base_dir.path(); fs::create_dir(p.join("aa")).unwrap(); diff --git a/tokio-fs/tests/link.rs b/tokio-fs/tests/link.rs index 11e6f45fc..b45f04cc4 100644 --- a/tokio-fs/tests/link.rs +++ b/tokio-fs/tests/link.rs @@ -1,19 +1,19 @@ extern crate futures; -extern crate tempdir; +extern crate tempfile; extern crate tokio_fs; use futures::Future; use std::fs; use std::io::prelude::*; use std::io::BufReader; -use tempdir::TempDir; +use tempfile::tempdir; use tokio_fs::*; mod pool; #[test] fn test_hard_link() { - let dir = TempDir::new("base").unwrap(); + let dir = tempdir().unwrap(); let src = dir.path().join("src.txt"); let dst = dir.path().join("dst.txt"); @@ -38,7 +38,7 @@ fn test_hard_link() { #[cfg(unix)] #[test] fn test_symlink() { - let dir = TempDir::new("base").unwrap(); + let dir = tempdir().unwrap(); let src = dir.path().join("src.txt"); let dst = dir.path().join("dst.txt"); diff --git a/tokio-io/src/lib.rs b/tokio-io/src/lib.rs index 090366407..790c0b589 100644 --- a/tokio-io/src/lib.rs +++ b/tokio-io/src/lib.rs @@ -21,10 +21,10 @@ use std::io as std_io; use futures::{Future, Stream}; /// A convenience typedef around a `Future` whose error component is `io::Error` -pub type IoFuture = Box + Send>; +pub type IoFuture = Box + Send>; /// A convenience typedef around a `Stream` whose error component is `io::Error` -pub type IoStream = Box + Send>; +pub type IoStream = Box + Send>; /// A convenience macro for working with `io::Result` from the `Read` and /// `Write` traits. @@ -65,6 +65,6 @@ pub use self::async_write::AsyncWrite; fn _assert_objects() { fn _assert() {} - _assert::>(); - _assert::>(); + _assert::>(); + _assert::>(); } diff --git a/tokio-reactor/Cargo.toml b/tokio-reactor/Cargo.toml index 0975ac5b9..c70d78256 100644 --- a/tokio-reactor/Cargo.toml +++ b/tokio-reactor/Cargo.toml @@ -36,4 +36,4 @@ tokio-sync = "0.1.1" [dev-dependencies] num_cpus = "1.8.0" tokio = "0.1.7" -tokio-io-pool = "0.1.4" +tokio-io-pool = "=0.1.4" diff --git a/tokio-reactor/src/lib.rs b/tokio-reactor/src/lib.rs index 15ea8fd2d..6b0bf3f67 100644 --- a/tokio-reactor/src/lib.rs +++ b/tokio-reactor/src/lib.rs @@ -652,7 +652,7 @@ impl Inner { /// Register an I/O resource with the reactor. /// /// The registration token is returned. - fn add_source(&self, source: &Evented) -> io::Result { + fn add_source(&self, source: &dyn Evented) -> io::Result { // Get an ABA guard value let aba_guard = self.next_aba_guard.fetch_add(1 << TOKEN_SHIFT, Relaxed); @@ -690,7 +690,7 @@ impl Inner { } /// Deregisters an I/O resource from the reactor. - fn deregister_source(&self, source: &Evented) -> io::Result<()> { + fn deregister_source(&self, source: &dyn Evented) -> io::Result<()> { self.io.deregister(source) } diff --git a/tokio-signal/examples/ctrl-c.rs b/tokio-signal/examples/ctrl-c.rs index 6d6adfd76..7cb3770f5 100644 --- a/tokio-signal/examples/ctrl-c.rs +++ b/tokio-signal/examples/ctrl-c.rs @@ -7,7 +7,7 @@ use futures::{Future, Stream}; /// how many signals to handle before exiting const STOP_AFTER: u64 = 10; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // tokio_signal provides a convenience builder for Ctrl+C // this even works cross-platform: linux and windows! // diff --git a/tokio-signal/examples/multiple.rs b/tokio-signal/examples/multiple.rs index fa8f1be25..8baad876c 100644 --- a/tokio-signal/examples/multiple.rs +++ b/tokio-signal/examples/multiple.rs @@ -11,7 +11,7 @@ mod platform { use futures::{Future, Stream}; use tokio_signal::unix::{Signal, SIGINT, SIGTERM}; - pub fn main() -> Result<(), Box<::std::error::Error>> { + pub fn main() -> Result<(), Box> { // Create a stream for each of the signals we'd like to handle. let sigint = Signal::new(SIGINT).flatten_stream(); let sigterm = Signal::new(SIGTERM).flatten_stream(); @@ -49,6 +49,6 @@ mod platform { } } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { platform::main() } diff --git a/tokio-signal/examples/sighup-example.rs b/tokio-signal/examples/sighup-example.rs index 5edb78624..8f3305258 100644 --- a/tokio-signal/examples/sighup-example.rs +++ b/tokio-signal/examples/sighup-example.rs @@ -9,7 +9,7 @@ mod platform { use futures::{Future, Stream}; use tokio_signal::unix::{Signal, SIGHUP}; - pub fn main() -> Result<(), Box<::std::error::Error>> { + pub fn main() -> Result<(), Box> { // on Unix, we can listen to whatever signal we want, in this case: SIGHUP let stream = Signal::new(SIGHUP).flatten_stream(); @@ -48,6 +48,6 @@ mod platform { } } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { platform::main() } diff --git a/tokio-signal/src/lib.rs b/tokio-signal/src/lib.rs index 1a33ec789..f4b03c652 100644 --- a/tokio-signal/src/lib.rs +++ b/tokio-signal/src/lib.rs @@ -86,9 +86,9 @@ pub mod unix; pub mod windows; /// A future whose error is `io::Error` -pub type IoFuture = Box + Send>; +pub type IoFuture = Box + Send>; /// A stream whose error is `io::Error` -pub type IoStream = Box + Send>; +pub type IoStream = Box + Send>; /// Creates a stream which receives "ctrl-c" notifications sent to a process. /// @@ -125,7 +125,7 @@ pub fn ctrl_c_handle(handle: &Handle) -> IoFuture> { let handle = handle.clone(); Box::new(future::lazy(move || { unix::Signal::with_handle(unix::libc::SIGINT, &handle) - .map(|x| Box::new(x.map(|_| ())) as Box + Send>) + .map(|x| Box::new(x.map(|_| ())) as Box + Send>) })) } diff --git a/tokio-threadpool/src/builder.rs b/tokio-threadpool/src/builder.rs index a51e8e520..b06568e6a 100644 --- a/tokio-threadpool/src/builder.rs +++ b/tokio-threadpool/src/builder.rs @@ -67,7 +67,7 @@ pub struct Builder { max_blocking: usize, /// Generates the `Park` instances - new_park: Box BoxPark>, + new_park: Box BoxPark>, } impl Builder { @@ -223,7 +223,7 @@ impl Builder { /// ``` pub fn panic_handler(&mut self, f: F) -> &mut Self where - F: Fn(Box) + Send + Sync + 'static, + F: Fn(Box) + Send + Sync + 'static, { self.config.panic_handler = Some(Arc::new(f)); self diff --git a/tokio-threadpool/src/callback.rs b/tokio-threadpool/src/callback.rs index aabf876f4..4fea4cac8 100644 --- a/tokio-threadpool/src/callback.rs +++ b/tokio-threadpool/src/callback.rs @@ -7,7 +7,7 @@ use tokio_executor::Enter; #[derive(Clone)] pub(crate) struct Callback { - f: Arc, + f: Arc, } impl Callback { diff --git a/tokio-threadpool/src/config.rs b/tokio-threadpool/src/config.rs index 5cbd0156e..94b3c06a0 100644 --- a/tokio-threadpool/src/config.rs +++ b/tokio-threadpool/src/config.rs @@ -13,9 +13,9 @@ pub(crate) struct Config { pub name_prefix: Option, pub stack_size: Option, pub around_worker: Option, - pub after_start: Option>, - pub before_stop: Option>, - pub panic_handler: Option) + Send + Sync>>, + pub after_start: Option>, + pub before_stop: Option>, + pub panic_handler: Option) + Send + Sync>>, } /// Max number of workers that can be part of a pool. This is the most that can diff --git a/tokio-threadpool/src/lib.rs b/tokio-threadpool/src/lib.rs index b74e0e2ef..c53afb588 100644 --- a/tokio-threadpool/src/lib.rs +++ b/tokio-threadpool/src/lib.rs @@ -1,7 +1,5 @@ #![doc(html_root_url = "https://docs.rs/tokio-threadpool/0.1.15")] #![deny(warnings, missing_docs, missing_debug_implementations)] -// Our MSRV doesn't allow us to fix these warnings yet -#![allow(rust_2018_idioms)] //! A work-stealing based thread pool for executing futures. //! diff --git a/tokio-threadpool/src/park/boxed.rs b/tokio-threadpool/src/park/boxed.rs index 8beaa0bb5..030866450 100644 --- a/tokio-threadpool/src/park/boxed.rs +++ b/tokio-threadpool/src/park/boxed.rs @@ -3,8 +3,8 @@ use tokio_executor::park::{Park, Unpark}; use std::error::Error; use std::time::Duration; -pub(crate) type BoxPark = Box + Send>; -pub(crate) type BoxUnpark = Box; +pub(crate) type BoxPark = Box + Send>; +pub(crate) type BoxUnpark = Box; pub(crate) struct BoxedPark(T); diff --git a/tokio-threadpool/src/sender.rs b/tokio-threadpool/src/sender.rs index fadd0cba3..3ae3deca4 100644 --- a/tokio-threadpool/src/sender.rs +++ b/tokio-threadpool/src/sender.rs @@ -131,7 +131,7 @@ impl tokio_executor::Executor for Sender { fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError> { let mut s = &*self; tokio_executor::Executor::spawn(&mut s, future) @@ -157,7 +157,7 @@ impl<'a> tokio_executor::Executor for &'a Sender { fn spawn( &mut self, - future: Box + Send>, + future: Box + Send>, ) -> Result<(), SpawnError> { self.prepare_for_spawn()?; diff --git a/tokio-threadpool/src/task/mod.rs b/tokio-threadpool/src/task/mod.rs index d9bdb07a4..9c5a448fc 100644 --- a/tokio-threadpool/src/task/mod.rs +++ b/tokio-threadpool/src/task/mod.rs @@ -60,7 +60,7 @@ pub(crate) enum Run { Complete, } -type BoxFuture = Box + Send + 'static>; +type BoxFuture = Box + Send + 'static>; // ===== impl Task ===== diff --git a/tokio-threadpool/tests/threadpool.rs b/tokio-threadpool/tests/threadpool.rs index 507fd03ea..bd6736f9a 100644 --- a/tokio-threadpool/tests/threadpool.rs +++ b/tokio-threadpool/tests/threadpool.rs @@ -18,7 +18,9 @@ use std::time::Duration; thread_local!(static FOO: Cell = Cell::new(0)); -fn ignore_results(f: F) -> Box + Send> { +fn ignore_results( + f: F, +) -> Box + Send> { Box::new(f.map(|_| ()).map_err(|_| ())) } diff --git a/tokio-timer/src/clock/clock.rs b/tokio-timer/src/clock/clock.rs index 9b9de89ef..fbba6981d 100644 --- a/tokio-timer/src/clock/clock.rs +++ b/tokio-timer/src/clock/clock.rs @@ -17,7 +17,7 @@ use std::time::Instant; /// [`Instant::now`]: https://doc.rust-lang.org/std/time/struct.Instant.html#method.now #[derive(Default, Clone)] pub struct Clock { - now: Option>, + now: Option>, } thread_local! { diff --git a/tokio-timer/src/throttle.rs b/tokio-timer/src/throttle.rs index 0ab49aaa5..97d313313 100644 --- a/tokio-timer/src/throttle.rs +++ b/tokio-timer/src/throttle.rs @@ -158,7 +158,7 @@ impl StdError for ThrottleError { // FIXME(taiki-e): When the minimum support version of tokio reaches Rust 1.30, // replace this with Error::source. #[allow(deprecated)] - fn cause(&self) -> Option<&StdError> { + fn cause(&self) -> Option<&dyn StdError> { match self.0 { Either::A(ref err) => Some(err), Either::B(ref err) => Some(err), diff --git a/tokio-timer/src/timer/mod.rs b/tokio-timer/src/timer/mod.rs index 05b0672e6..c79a82a26 100644 --- a/tokio-timer/src/timer/mod.rs +++ b/tokio-timer/src/timer/mod.rs @@ -162,7 +162,7 @@ pub(crate) struct Inner { process: AtomicStack, /// Unparks the timer thread. - unpark: Box, + unpark: Box, } /// Maximum number of timeouts the system can handle concurrently. @@ -426,7 +426,7 @@ impl Drop for Timer { // ===== impl Inner ===== impl Inner { - fn new(start: Instant, unpark: Box) -> Inner { + fn new(start: Instant, unpark: Box) -> Inner { Inner { num: AtomicUsize::new(0), elapsed: AtomicU64::new(0), diff --git a/tokio-tls/examples/download-rust-lang.rs b/tokio-tls/examples/download-rust-lang.rs index 9d23dc78f..0b5148178 100644 --- a/tokio-tls/examples/download-rust-lang.rs +++ b/tokio-tls/examples/download-rust-lang.rs @@ -12,7 +12,7 @@ use native_tls::TlsConnector; use tokio::net::TcpStream; use tokio::runtime::Runtime; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let mut runtime = Runtime::new()?; let addr = "www.rust-lang.org:443" .to_socket_addrs()? diff --git a/tokio-tls/examples/echo.rs b/tokio-tls/examples/echo.rs index c39d5873b..65db1a150 100644 --- a/tokio-tls/examples/echo.rs +++ b/tokio-tls/examples/echo.rs @@ -8,7 +8,7 @@ use tokio::io; use tokio::net::TcpListener; use tokio::prelude::*; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Bind the server's socket let addr = "127.0.0.1:12345".parse()?; let tcp = TcpListener::bind(&addr)?; diff --git a/tokio-uds/Cargo.toml b/tokio-uds/Cargo.toml index a884f1bca..49315000f 100644 --- a/tokio-uds/Cargo.toml +++ b/tokio-uds/Cargo.toml @@ -33,4 +33,4 @@ tokio-io = "0.1.6" [dev-dependencies] tokio = "0.1.6" -tempfile = "3" +tempfile = ">=3.0.5, <3.1" diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index b42d84f3f..9a5539813 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -83,7 +83,7 @@ tokio-uds = { version = "0.2.1", optional = true } [dev-dependencies] env_logger = { version = "0.5", default-features = false } -flate2 = { version = "1", features = ["tokio"] } +flate2 = { version = ">=1.0.2, <1.0.10", features = ["tokio"] } futures-cpupool = "0.1" http = "0.1" httparse = "1.0" diff --git a/tokio/examples/chat-combinator-current-thread.rs b/tokio/examples/chat-combinator-current-thread.rs index ee147025d..4ef5c205f 100644 --- a/tokio/examples/chat-combinator-current-thread.rs +++ b/tokio/examples/chat-combinator-current-thread.rs @@ -41,7 +41,7 @@ use std::io::BufReader; use std::iter; use std::rc::Rc; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let mut runtime = Runtime::new().unwrap(); // Create the TCP listener we'll accept connections on. diff --git a/tokio/examples/chat-combinator.rs b/tokio/examples/chat-combinator.rs index b81e8f7c3..354d999fb 100644 --- a/tokio/examples/chat-combinator.rs +++ b/tokio/examples/chat-combinator.rs @@ -34,7 +34,7 @@ use std::io::BufReader; use std::iter; use std::sync::{Arc, Mutex}; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Create the TCP listener we'll accept connections on. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); let addr = addr.parse()?; diff --git a/tokio/examples/chat.rs b/tokio/examples/chat.rs index b21432afa..c2d56ff02 100644 --- a/tokio/examples/chat.rs +++ b/tokio/examples/chat.rs @@ -422,7 +422,7 @@ fn process(socket: TcpStream, state: Arc>) { tokio::spawn(connection); } -pub fn main() -> Result<(), Box> { +pub fn main() -> Result<(), Box> { // Create the shared state. This is how all the peers communicate. // // The server task will hold a handle to this. For every new client, the diff --git a/tokio/examples/connect.rs b/tokio/examples/connect.rs index 4dc0ea31e..a0b769a4d 100644 --- a/tokio/examples/connect.rs +++ b/tokio/examples/connect.rs @@ -29,7 +29,7 @@ use std::thread; use futures::sync::mpsc; use tokio::prelude::*; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Determine if we're going to run in TCP or UDP mode let mut args = env::args().skip(1).collect::>(); let tcp = match args.iter().position(|a| a == "--udp") { @@ -133,8 +133,8 @@ mod tcp { pub fn connect( addr: &SocketAddr, - stdin: Box, Error = io::Error> + Send>, - ) -> Result + Send>, Box> { + stdin: Box, Error = io::Error> + Send>, + ) -> Result + Send>, Box> { let tcp = TcpStream::connect(addr); // After the TCP connection has been established, we set up our client @@ -185,8 +185,8 @@ mod udp { pub fn connect( &addr: &SocketAddr, - stdin: Box, Error = io::Error> + Send>, - ) -> Result + Send>, Box> { + stdin: Box, Error = io::Error> + Send>, + ) -> Result + Send>, Box> { // We'll bind our UDP socket to a local IP/port, but for now we // basically let the OS pick both of those. let addr_to_bind = if addr.ip().is_ipv4() { diff --git a/tokio/examples/echo-udp.rs b/tokio/examples/echo-udp.rs index 93ebca799..1d3836d2b 100644 --- a/tokio/examples/echo-udp.rs +++ b/tokio/examples/echo-udp.rs @@ -50,7 +50,7 @@ impl Future for Server { } } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); let addr = addr.parse::()?; diff --git a/tokio/examples/echo.rs b/tokio/examples/echo.rs index 45f808f89..96b454fb8 100644 --- a/tokio/examples/echo.rs +++ b/tokio/examples/echo.rs @@ -30,7 +30,7 @@ use tokio::prelude::*; use std::env; use std::net::SocketAddr; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Allow passing an address to listen on as the first argument of this // program, but otherwise we'll just set up our TCP listener on // 127.0.0.1:8080 for connections. diff --git a/tokio/examples/hello_world.rs b/tokio/examples/hello_world.rs index c82762691..4febb38aa 100644 --- a/tokio/examples/hello_world.rs +++ b/tokio/examples/hello_world.rs @@ -19,7 +19,7 @@ use tokio::io; use tokio::net::TcpStream; use tokio::prelude::*; -pub fn main() -> Result<(), Box> { +pub fn main() -> Result<(), Box> { let addr = "127.0.0.1:6142".parse()?; // Open a TCP stream to the socket address. diff --git a/tokio/examples/manual-runtime.rs b/tokio/examples/manual-runtime.rs index 8e3e12996..2b715f321 100644 --- a/tokio/examples/manual-runtime.rs +++ b/tokio/examples/manual-runtime.rs @@ -60,7 +60,7 @@ fn run>(f: F) -> Result<(), IoError> { Ok(()) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { run(future::lazy(|| { // Here comes the application logic. It can spawn further tasks by tokio_current_thread::spawn(). // It also can use the default reactor and create timeouts. diff --git a/tokio/examples/print_each_packet.rs b/tokio/examples/print_each_packet.rs index 94a606483..57d312c0a 100644 --- a/tokio/examples/print_each_packet.rs +++ b/tokio/examples/print_each_packet.rs @@ -65,7 +65,7 @@ use tokio_codec::BytesCodec; use std::env; use std::net::SocketAddr; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Allow passing an address to listen on as the first argument of this // program, but otherwise we'll just set up our TCP listener on // 127.0.0.1:8080 for connections. diff --git a/tokio/examples/proxy.rs b/tokio/examples/proxy.rs index 2cbcf119a..950a8f594 100644 --- a/tokio/examples/proxy.rs +++ b/tokio/examples/proxy.rs @@ -33,7 +33,7 @@ use tokio::io::{copy, shutdown}; use tokio::net::{TcpListener, TcpStream}; use tokio::prelude::*; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let listen_addr = env::args().nth(1).unwrap_or("127.0.0.1:8081".to_string()); let listen_addr = listen_addr.parse::()?; diff --git a/tokio/examples/tinydb.rs b/tokio/examples/tinydb.rs index 11298ed13..d4dc4db12 100644 --- a/tokio/examples/tinydb.rs +++ b/tokio/examples/tinydb.rs @@ -83,7 +83,7 @@ enum Response { }, } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Parse the address we're going to run this server on // and set up our TCP listener to accept connections. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); diff --git a/tokio/examples/tinyhttp.rs b/tokio/examples/tinyhttp.rs index cde1b79af..90ac58695 100644 --- a/tokio/examples/tinyhttp.rs +++ b/tokio/examples/tinyhttp.rs @@ -34,7 +34,7 @@ use bytes::BytesMut; use http::header::HeaderValue; use http::{Request, Response, StatusCode}; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { // Parse the arguments, bind the TCP socket we'll be listening to, spin up // our worker threads, and start shipping sockets to those worker threads. let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); @@ -82,7 +82,7 @@ fn process(socket: TcpStream) { /// This function is a map from and HTTP request to a future of a response and /// represents the various handling a server might do. Currently the contents /// here are pretty uninteresting. -fn respond(req: Request<()>) -> Box, Error = io::Error> + Send> { +fn respond(req: Request<()>) -> Box, Error = io::Error> + Send> { let f = future::lazy(move || { let mut response = Response::builder(); let body = match req.uri().path() { diff --git a/tokio/examples/udp-client.rs b/tokio/examples/udp-client.rs index 900d3616d..77ae00d1e 100644 --- a/tokio/examples/udp-client.rs +++ b/tokio/examples/udp-client.rs @@ -35,13 +35,13 @@ use std::net::SocketAddr; use tokio::net::UdpSocket; use tokio::prelude::*; -fn get_stdin_data() -> Result, Box> { +fn get_stdin_data() -> Result, Box> { let mut buf = Vec::new(); stdin().read_to_end(&mut buf)?; Ok(buf) } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let remote_addr: SocketAddr = env::args() .nth(1) .unwrap_or("127.0.0.1:8080".into()) diff --git a/tokio/examples/udp-codec.rs b/tokio/examples/udp-codec.rs index 3657d8cc1..9a48312c7 100644 --- a/tokio/examples/udp-codec.rs +++ b/tokio/examples/udp-codec.rs @@ -19,7 +19,7 @@ use tokio::net::{UdpFramed, UdpSocket}; use tokio::prelude::*; use tokio_codec::BytesCodec; -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let _ = env_logger::init(); let addr: SocketAddr = "127.0.0.1:0".parse()?; diff --git a/tokio/src/runtime/current_thread/runtime.rs b/tokio/src/runtime/current_thread/runtime.rs index e297e873d..e6562809b 100644 --- a/tokio/src/runtime/current_thread/runtime.rs +++ b/tokio/src/runtime/current_thread/runtime.rs @@ -105,7 +105,7 @@ impl Error for RunError { // FIXME(taiki-e): When the minimum support version of tokio reaches Rust 1.30, // replace this with Error::source. #[allow(deprecated)] - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { self.inner.cause() } } diff --git a/tokio/src/runtime/threadpool/builder.rs b/tokio/src/runtime/threadpool/builder.rs index 68626b09a..076cf8bf8 100644 --- a/tokio/src/runtime/threadpool/builder.rs +++ b/tokio/src/runtime/threadpool/builder.rs @@ -128,7 +128,7 @@ impl Builder { /// ``` pub fn panic_handler(&mut self, f: F) -> &mut Self where - F: Fn(Box) + Send + Sync + 'static, + F: Fn(Box) + Send + Sync + 'static, { self.threadpool_builder.panic_handler(f); self diff --git a/tokio/src/runtime/threadpool/task_executor.rs b/tokio/src/runtime/threadpool/task_executor.rs index 91c665820..302aae0d8 100644 --- a/tokio/src/runtime/threadpool/task_executor.rs +++ b/tokio/src/runtime/threadpool/task_executor.rs @@ -67,7 +67,7 @@ where T: Future + Send + 'static, } impl ::executor::Executor for TaskExecutor { - fn spawn(&mut self, future: Box + Send>) + fn spawn(&mut self, future: Box + Send>) -> Result<(), ::executor::SpawnError> { self.inner.spawn(future) diff --git a/tokio/tests/reactor.rs b/tokio/tests/reactor.rs index fd3a8eea6..53e770c6d 100644 --- a/tokio/tests/reactor.rs +++ b/tokio/tests/reactor.rs @@ -30,7 +30,7 @@ fn test_drop_on_notify() { struct MyNotify; - type Task = Mutex>>>; + type Task = Mutex>>>; impl Notify for MyNotify { fn notify(&self, _: usize) { @@ -66,7 +66,7 @@ fn test_drop_on_notify() { .incoming() .for_each(|_| Ok(())) .map_err(|_| panic!()) - }) as Box>; + }) as Box>; let task = Arc::new(Mutex::new(spawn(task))); let notify = Arc::new(MyNotify); diff --git a/tokio/tests/runtime.rs b/tokio/tests/runtime.rs index f84c66738..62c046986 100644 --- a/tokio/tests/runtime.rs +++ b/tokio/tests/runtime.rs @@ -25,7 +25,7 @@ macro_rules! t { }; } -fn create_client_server_future() -> Box + Send> { +fn create_client_server_future() -> Box + Send> { let server = t!(TcpListener::bind(&"127.0.0.1:0".parse().unwrap())); let addr = t!(server.local_addr()); let client = TcpStream::connect(&addr); @@ -84,7 +84,7 @@ mod runtime_single_threaded_block_on_all { fn test(spawn: F) where - F: Fn(Box + Send>), + F: Fn(Box + Send>), { let cnt = Arc::new(Mutex::new(0)); let c = cnt.clone(); @@ -133,7 +133,10 @@ mod runtime_single_threaded_racy { use super::*; fn test(spawn: F) where - F: Fn(tokio::runtime::current_thread::Handle, Box + Send>), + F: Fn( + tokio::runtime::current_thread::Handle, + Box + Send>, + ), { let (trigger, exit) = futures::sync::oneshot::channel(); let (handle_tx, handle_rx) = ::std::sync::mpsc::channel(); @@ -218,7 +221,7 @@ fn block_on_timer() { use std::time::{Duration, Instant}; use tokio::timer::{Delay, Error}; - fn after_1s(x: T) -> Box + Send> + fn after_1s(x: T) -> Box + Send> where T: Send + 'static, { @@ -235,7 +238,7 @@ mod from_block_on { fn test(spawn: F) where - F: Fn(Box + Send>) + Send + 'static, + F: Fn(Box + Send>) + Send + 'static, { let cnt = Arc::new(Mutex::new(0)); let c = cnt.clone(); @@ -317,7 +320,7 @@ mod many { const ITER: usize = 200; fn test(spawn: F) where - F: Fn(&mut Runtime, Box + Send>), + F: Fn(&mut Runtime, Box + Send>), { let cnt = Arc::new(Mutex::new(0)); let mut runtime = Runtime::new().unwrap(); @@ -360,7 +363,7 @@ mod from_block_on_all { fn test(spawn: F) where - F: Fn(Box + Send>) + Send + 'static, + F: Fn(Box + Send>) + Send + 'static, { let cnt = Arc::new(Mutex::new(0)); let c = cnt.clone(); @@ -414,8 +417,8 @@ mod nested_enter { fn test(first: F1, nested: F2) where - F1: Fn(Box + Send>) + Send + 'static, - F2: Fn(Box + Send>) + panic::UnwindSafe + Send + 'static, + F1: Fn(Box + Send>) + Send + 'static, + F2: Fn(Box + Send>) + panic::UnwindSafe + Send + 'static, { let panicked = Arc::new(Mutex::new(false)); let panicked2 = panicked.clone();