From cf3206842c0d94ecdaaeb421a58b1c963b627c3d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Tue, 23 Nov 2021 12:09:24 +0900 Subject: [PATCH] chore: bump MSRV to 1.46 (#4254) --- .clippy.toml | 2 +- .github/workflows/ci.yml | 2 +- README.md | 2 +- tokio-macros/Cargo.toml | 1 + tokio-stream/Cargo.toml | 1 + tokio-test/Cargo.toml | 1 + tokio-util/Cargo.toml | 1 + tokio/Cargo.toml | 4 +--- tokio/README.md | 2 +- tokio/build.rs | 22 ---------------------- tokio/src/runtime/handle.rs | 18 ++++-------------- tokio/src/runtime/mod.rs | 6 +++--- tokio/src/task/blocking.rs | 2 +- tokio/src/task/builder.rs | 6 +++--- tokio/src/task/local.rs | 4 ++-- tokio/src/task/spawn.rs | 4 ++-- tokio/src/time/driver/sleep.rs | 10 ++-------- tokio/src/time/timeout.rs | 2 +- tokio/src/util/trace.rs | 17 ++++------------- 19 files changed, 31 insertions(+), 76 deletions(-) delete mode 100644 tokio/build.rs diff --git a/.clippy.toml b/.clippy.toml index 1cf14c6d0..eb66960ac 100644 --- a/.clippy.toml +++ b/.clippy.toml @@ -1 +1 @@ -msrv = "1.45" +msrv = "1.46" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e07f18c0..b3df113d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ env: RUSTFLAGS: -Dwarnings RUST_BACKTRACE: 1 nightly: nightly-2021-10-25 - minrust: 1.45.2 + minrust: 1.46 jobs: # Depends on all action sthat are required for a "successful" CI run. diff --git a/README.md b/README.md index 19f049cba..1bc185008 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ several other libraries, including: ## Supported Rust Versions Tokio is built against the latest stable release. The minimum supported version -is 1.45. The current Tokio version is not guaranteed to build on Rust versions +is 1.46. The current Tokio version is not guaranteed to build on Rust versions earlier than the minimum supported version. ## Release schedule diff --git a/tokio-macros/Cargo.toml b/tokio-macros/Cargo.toml index 2114cd294..34ca4b0a3 100644 --- a/tokio-macros/Cargo.toml +++ b/tokio-macros/Cargo.toml @@ -8,6 +8,7 @@ name = "tokio-macros" # - Create "tokio-macros-1.0.x" git tag. version = "1.6.0" edition = "2018" +rust-version = "1.46" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio-stream/Cargo.toml b/tokio-stream/Cargo.toml index 83f855182..41c1a71c3 100644 --- a/tokio-stream/Cargo.toml +++ b/tokio-stream/Cargo.toml @@ -8,6 +8,7 @@ name = "tokio-stream" # - Create "tokio-stream-0.1.x" git tag. version = "0.1.8" edition = "2018" +rust-version = "1.46" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio-test/Cargo.toml b/tokio-test/Cargo.toml index 55d5aafc5..09fdf06b5 100644 --- a/tokio-test/Cargo.toml +++ b/tokio-test/Cargo.toml @@ -8,6 +8,7 @@ name = "tokio-test" # - Create "tokio-test-0.4.x" git tag. version = "0.4.2" edition = "2018" +rust-version = "1.46" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml index 676b0e2ec..2bf6ac9a0 100644 --- a/tokio-util/Cargo.toml +++ b/tokio-util/Cargo.toml @@ -8,6 +8,7 @@ name = "tokio-util" # - Create "tokio-util-0.6.x" git tag. version = "0.6.9" edition = "2018" +rust-version = "1.46" authors = ["Tokio Contributors "] license = "MIT" repository = "https://github.com/tokio-rs/tokio" diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 5b18d4095..0a5cfea03 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -9,6 +9,7 @@ name = "tokio" # - Create "v1.0.x" git tag. version = "1.14.0" edition = "2018" +rust-version = "1.46" authors = ["Tokio Contributors "] license = "MIT" readme = "README.md" @@ -137,9 +138,6 @@ mio-aio = { version = "0.6.0", features = ["tokio"] } [target.'cfg(loom)'.dev-dependencies] loom = { version = "0.5", features = ["futures", "checkpoint"] } -[build-dependencies] -autocfg = "1" # Needed for conditionally enabling `track-caller` - [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] diff --git a/tokio/README.md b/tokio/README.md index 19f049cba..1bc185008 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -164,7 +164,7 @@ several other libraries, including: ## Supported Rust Versions Tokio is built against the latest stable release. The minimum supported version -is 1.45. The current Tokio version is not guaranteed to build on Rust versions +is 1.46. The current Tokio version is not guaranteed to build on Rust versions earlier than the minimum supported version. ## Release schedule diff --git a/tokio/build.rs b/tokio/build.rs deleted file mode 100644 index fe5c83005..000000000 --- a/tokio/build.rs +++ /dev/null @@ -1,22 +0,0 @@ -use autocfg::AutoCfg; - -fn main() { - match AutoCfg::new() { - Ok(ac) => { - // The #[track_caller] attribute was stabilized in rustc 1.46.0. - if ac.probe_rustc_version(1, 46) { - autocfg::emit("tokio_track_caller") - } - } - - Err(e) => { - // If we couldn't detect the compiler version and features, just - // print a warning. This isn't a fatal error: we can still build - // Tokio, we just can't enable cfgs automatically. - println!( - "cargo:warning=tokio: failed to detect compiler features: {}", - e - ); - } - } -} diff --git a/tokio/src/runtime/handle.rs b/tokio/src/runtime/handle.rs index cd1cb760a..ba9a9eaf7 100644 --- a/tokio/src/runtime/handle.rs +++ b/tokio/src/runtime/handle.rs @@ -157,7 +157,7 @@ impl Handle { /// }); /// # } /// ``` - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn(&self, future: F) -> JoinHandle where F: Future + Send + 'static, @@ -187,7 +187,7 @@ impl Handle { /// println!("now running on a worker thread"); /// }); /// # } - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_blocking(&self, func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, @@ -200,7 +200,7 @@ impl Handle { } } - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub(crate) fn spawn_blocking_inner(&self, func: F, name: Option<&str>) -> JoinHandle where F: FnOnce() -> R + Send + 'static, @@ -211,9 +211,7 @@ impl Handle { #[cfg(all(tokio_unstable, feature = "tracing"))] let fut = { use tracing::Instrument; - #[cfg(tokio_track_caller)] let location = std::panic::Location::caller(); - #[cfg(tokio_track_caller)] let span = tracing::trace_span!( target: "tokio::task::blocking", "runtime.spawn", @@ -222,14 +220,6 @@ impl Handle { "fn" = %std::any::type_name::(), spawn.location = %format_args!("{}:{}:{}", location.file(), location.line(), location.column()), ); - #[cfg(not(tokio_track_caller))] - let span = tracing::trace_span!( - target: "tokio::task::blocking", - "runtime.spawn", - kind = %"blocking", - task.name = %name.unwrap_or_default(), - "fn" = %std::any::type_name::(), - ); fut.instrument(span) }; @@ -311,7 +301,7 @@ impl Handle { /// [`tokio::fs`]: crate::fs /// [`tokio::net`]: crate::net /// [`tokio::time`]: crate::time - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn block_on(&self, future: F) -> F::Output { #[cfg(all(tokio_unstable, feature = "tracing"))] let future = crate::util::trace::task(future, "block_on", None); diff --git a/tokio/src/runtime/mod.rs b/tokio/src/runtime/mod.rs index 96bb47c1d..a4fa89242 100644 --- a/tokio/src/runtime/mod.rs +++ b/tokio/src/runtime/mod.rs @@ -375,7 +375,7 @@ cfg_rt! { /// }); /// # } /// ``` - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn(&self, future: F) -> JoinHandle where F: Future + Send + 'static, @@ -400,7 +400,7 @@ cfg_rt! { /// println!("now running on a worker thread"); /// }); /// # } - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_blocking(&self, func: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, @@ -450,7 +450,7 @@ cfg_rt! { /// ``` /// /// [handle]: fn@Handle::block_on - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn block_on(&self, future: F) -> F::Output { #[cfg(all(tokio_unstable, feature = "tracing"))] let future = crate::util::trace::task(future, "block_on", None); diff --git a/tokio/src/task/blocking.rs b/tokio/src/task/blocking.rs index 825f25f8c..5fe358f3e 100644 --- a/tokio/src/task/blocking.rs +++ b/tokio/src/task/blocking.rs @@ -188,7 +188,7 @@ cfg_rt! { /// worker.await.unwrap(); /// # } /// ``` - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_blocking(f: F) -> JoinHandle where F: FnOnce() -> R + Send + 'static, diff --git a/tokio/src/task/builder.rs b/tokio/src/task/builder.rs index f991fc65e..dae334928 100644 --- a/tokio/src/task/builder.rs +++ b/tokio/src/task/builder.rs @@ -65,7 +65,7 @@ impl<'a> Builder<'a> { /// /// See [`task::spawn`](crate::task::spawn) for /// more details. - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn(self, future: Fut) -> JoinHandle where Fut: Future + Send + 'static, @@ -78,7 +78,7 @@ impl<'a> Builder<'a> { /// /// See [`task::spawn_local`](crate::task::spawn_local) /// for more details. - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_local(self, future: Fut) -> JoinHandle where Fut: Future + 'static, @@ -91,7 +91,7 @@ impl<'a> Builder<'a> { /// /// See [`task::spawn_blocking`](crate::task::spawn_blocking) /// for more details. - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_blocking(self, function: Function) -> JoinHandle where Function: FnOnce() -> Output + Send + 'static, diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs index 4a5d313c6..1beee6891 100644 --- a/tokio/src/task/local.rs +++ b/tokio/src/task/local.rs @@ -286,7 +286,7 @@ cfg_rt! { /// }).await; /// } /// ``` - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_local(future: F) -> JoinHandle where F: Future + 'static, @@ -377,7 +377,7 @@ impl LocalSet { /// } /// ``` /// [`spawn_local`]: fn@spawn_local - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn_local(&self, future: F) -> JoinHandle where F: Future + 'static, diff --git a/tokio/src/task/spawn.rs b/tokio/src/task/spawn.rs index 065d38f54..a9d736674 100644 --- a/tokio/src/task/spawn.rs +++ b/tokio/src/task/spawn.rs @@ -121,7 +121,7 @@ cfg_rt! { /// ```text /// error[E0391]: cycle detected when processing `main` /// ``` - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub fn spawn(future: T) -> JoinHandle where T: Future + Send + 'static, @@ -136,7 +136,7 @@ cfg_rt! { } } - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub(super) fn spawn_inner(future: T, name: Option<&str>) -> JoinHandle where T: Future + Send + 'static, diff --git a/tokio/src/time/driver/sleep.rs b/tokio/src/time/driver/sleep.rs index 43ff694ff..7a2327be6 100644 --- a/tokio/src/time/driver/sleep.rs +++ b/tokio/src/time/driver/sleep.rs @@ -45,7 +45,7 @@ cfg_trace! { /// [`interval`]: crate::time::interval() // Alias for old name in 0.x #[cfg_attr(docsrs, doc(alias = "delay_until"))] -#[cfg_attr(tokio_track_caller, track_caller)] +#[track_caller] pub fn sleep_until(deadline: Instant) -> Sleep { return Sleep::new_timeout(deadline, trace::caller_location()); } @@ -89,7 +89,7 @@ pub fn sleep_until(deadline: Instant) -> Sleep { // Alias for old name in 0.x #[cfg_attr(docsrs, doc(alias = "delay_for"))] #[cfg_attr(docsrs, doc(alias = "wait"))] -#[cfg_attr(tokio_track_caller, track_caller)] +#[track_caller] pub fn sleep(duration: Duration) -> Sleep { let location = trace::caller_location(); @@ -232,10 +232,8 @@ impl Sleep { let deadline_tick = time_source.deadline_to_tick(deadline); let duration = deadline_tick.checked_sub(time_source.now()).unwrap_or(0); - #[cfg(tokio_track_caller)] let location = location.expect("should have location if tracking caller"); - #[cfg(tokio_track_caller)] let resource_span = tracing::trace_span!( "runtime.resource", concrete_type = "Sleep", @@ -245,10 +243,6 @@ impl Sleep { loc.col = location.column(), ); - #[cfg(not(tokio_track_caller))] - let resource_span = - tracing::trace_span!("runtime.resource", concrete_type = "Sleep", kind = "timer"); - let async_op_span = tracing::trace_span!("runtime.resource.async_op", source = "Sleep::new_timeout"); diff --git a/tokio/src/time/timeout.rs b/tokio/src/time/timeout.rs index 6725caa09..cf90540bf 100644 --- a/tokio/src/time/timeout.rs +++ b/tokio/src/time/timeout.rs @@ -48,7 +48,7 @@ use std::task::{self, Poll}; /// } /// # } /// ``` -#[cfg_attr(tokio_track_caller, track_caller)] +#[track_caller] pub fn timeout(duration: Duration, future: T) -> Timeout where T: Future, diff --git a/tokio/src/util/trace.rs b/tokio/src/util/trace.rs index e3c26f9d6..74ae73935 100644 --- a/tokio/src/util/trace.rs +++ b/tokio/src/util/trace.rs @@ -3,12 +3,10 @@ cfg_trace! { pub(crate) use tracing::instrument::Instrumented; #[inline] - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub(crate) fn task(task: F, kind: &'static str, name: Option<&str>) -> Instrumented { use tracing::instrument::Instrument; - #[cfg(tokio_track_caller)] let location = std::panic::Location::caller(); - #[cfg(tokio_track_caller)] let span = tracing::trace_span!( target: "tokio::task", "runtime.spawn", @@ -18,23 +16,16 @@ cfg_trace! { loc.line = location.line(), loc.col = location.column(), ); - #[cfg(not(tokio_track_caller))] - let span = tracing::trace_span!( - target: "tokio::task", - "runtime.spawn", - %kind, - task.name = %name.unwrap_or_default(), - ); task.instrument(span) } } } cfg_time! { - #[cfg_attr(tokio_track_caller, track_caller)] + #[track_caller] pub(crate) fn caller_location() -> Option<&'static std::panic::Location<'static>> { - #[cfg(all(tokio_track_caller, tokio_unstable, feature = "tracing"))] + #[cfg(all(tokio_unstable, feature = "tracing"))] return Some(std::panic::Location::caller()); - #[cfg(not(all(tokio_track_caller, tokio_unstable, feature = "tracing")))] + #[cfg(not(all(tokio_unstable, feature = "tracing")))] None } }