Skip to content

Commit

Permalink
tokio: bump MSRV to 1.56 (#5559)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Mar 21, 2023
1 parent 2dfe4e8 commit 0c8e824
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .clippy.toml
@@ -1 +1 @@
msrv = "1.49"
msrv = "1.56"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -21,7 +21,7 @@ env:
# - tokio-util/Cargo.toml
# - tokio-test/Cargo.toml
# - tokio-stream/Cargo.toml
rust_min: 1.49.0
rust_min: 1.56.0

defaults:
run:
Expand Down
21 changes: 17 additions & 4 deletions README.md
Expand Up @@ -187,7 +187,20 @@ When updating this, also update:

Tokio will keep a rolling MSRV (minimum supported rust version) policy of **at
least** 6 months. When increasing the MSRV, the new Rust version must have been
released at least six months ago. The current MSRV is 1.49.0.
released at least six months ago. The current MSRV is 1.56.0.

Note that the MSRV is not increased automatically, and only as part of a minor
release. The MSRV history for past minor releases can be found below:

* 1.27 to now - Rust 1.56
* 1.17 to 1.26 - Rust 1.49
* 1.15 to 1.16 - Rust 1.46
* 1.0 to 1.14 - Rust 1.45

Note that although we try to avoid the situation where a dependency transitively
increases the MSRV of Tokio, we do not guarantee that this does not happen.
However, every minor release will have some set of versions of dependencies that
works with the MSRV of that minor release.

## Release schedule

Expand All @@ -202,9 +215,9 @@ warrants a patch release with a fix for the bug, it will be backported and
released as a new patch release for each LTS minor version. Our current LTS
releases are:

* `1.18.x` - LTS release until June 2023
* `1.20.x` - LTS release until September 2023.
* `1.25.x` - LTS release until March 2024
* `1.18.x` - LTS release until June 2023. (MSRV 1.49)
* `1.20.x` - LTS release until September 2023. (MSRV 1.49)
* `1.25.x` - LTS release until March 2024. (MSRV 1.49)

Each LTS release will continue to receive backported fixes for at least a year.
If you wish to use a fixed minor release in your project, we recommend that you
Expand Down
2 changes: 1 addition & 1 deletion tokio-macros/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ name = "tokio-macros"
# - Create "tokio-macros-1.x.y" git tag.
version = "1.8.2"
edition = "2018"
rust-version = "1.49"
rust-version = "1.56"
authors = ["Tokio Contributors <team@tokio.rs>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ name = "tokio-stream"
# - Create "tokio-stream-0.1.x" git tag.
version = "0.1.12"
edition = "2018"
rust-version = "1.49"
rust-version = "1.56"
authors = ["Tokio Contributors <team@tokio.rs>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
Expand Down
2 changes: 1 addition & 1 deletion tokio-test/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ name = "tokio-test"
# - Create "tokio-test-0.4.x" git tag.
version = "0.4.2"
edition = "2018"
rust-version = "1.49"
rust-version = "1.56"
authors = ["Tokio Contributors <team@tokio.rs>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/Cargo.toml
Expand Up @@ -6,7 +6,7 @@ name = "tokio-util"
# - Create "tokio-util-0.7.x" git tag.
version = "0.7.7"
edition = "2018"
rust-version = "1.49"
rust-version = "1.56"
authors = ["Tokio Contributors <team@tokio.rs>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
Expand Down
6 changes: 1 addition & 5 deletions tokio-util/src/sync/cancellation_token/tree_node.rs
Expand Up @@ -239,11 +239,7 @@ fn remove_child(parent: &mut Inner, mut node: MutexGuard<'_, Inner>) {

let len = parent.children.len();
if 4 * len <= parent.children.capacity() {
// equal to:
// parent.children.shrink_to(2 * len);
// but shrink_to was not yet stabilized in our minimal compatible version
let old_children = std::mem::replace(&mut parent.children, Vec::with_capacity(2 * len));
parent.children.extend(old_children);
parent.children.shrink_to(2 * len);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tokio/Cargo.toml
Expand Up @@ -7,8 +7,8 @@ name = "tokio"
# - Update CHANGELOG.md.
# - Create "v1.x.y" git tag.
version = "1.26.0"
edition = "2018"
rust-version = "1.49"
edition = "2021"
rust-version = "1.56"
authors = ["Tokio Contributors <team@tokio.rs>"]
license = "MIT"
readme = "README.md"
Expand Down
21 changes: 17 additions & 4 deletions tokio/README.md
Expand Up @@ -187,7 +187,20 @@ When updating this, also update:

Tokio will keep a rolling MSRV (minimum supported rust version) policy of **at
least** 6 months. When increasing the MSRV, the new Rust version must have been
released at least six months ago. The current MSRV is 1.49.0.
released at least six months ago. The current MSRV is 1.56.0.

Note that the MSRV is not increased automatically, and only as part of a minor
release. The MSRV history for past minor releases can be found below:

* 1.27 to now - Rust 1.56
* 1.17 to 1.26 - Rust 1.49
* 1.15 to 1.16 - Rust 1.46
* 1.0 to 1.14 - Rust 1.45

Note that although we try to avoid the situation where a dependency transitively
increases the MSRV of Tokio, we do not guarantee that this does not happen.
However, every minor release will have some set of versions of dependencies that
works with the MSRV of that minor release.

## Release schedule

Expand All @@ -202,9 +215,9 @@ warrants a patch release with a fix for the bug, it will be backported and
released as a new patch release for each LTS minor version. Our current LTS
releases are:

* `1.18.x` - LTS release until June 2023
* `1.20.x` - LTS release until September 2023.
* `1.25.x` - LTS release until March 2024
* `1.18.x` - LTS release until June 2023. (MSRV 1.49)
* `1.20.x` - LTS release until September 2023. (MSRV 1.49)
* `1.25.x` - LTS release until March 2024. (MSRV 1.49)

Each LTS release will continue to receive backported fixes for at least a year.
If you wish to use a fixed minor release in your project, we recommend that you
Expand Down
31 changes: 0 additions & 31 deletions tokio/build.rs
Expand Up @@ -10,13 +10,6 @@ const CONST_THREAD_LOCAL_PROBE: &str = r#"
}
"#;

const ADDR_OF_PROBE: &str = r#"
{
let my_var = 10;
::std::ptr::addr_of!(my_var)
}
"#;

const CONST_MUTEX_NEW_PROBE: &str = r#"
{
static MY_MUTEX: ::std::sync::Mutex<i32> = ::std::sync::Mutex::new(1);
Expand Down Expand Up @@ -53,7 +46,6 @@ const TARGET_ATOMIC_U64_PROBE: &str = r#"

fn main() {
let mut enable_const_thread_local = false;
let mut enable_addr_of = false;
let mut enable_target_has_atomic = false;
let mut enable_const_mutex_new = false;
let mut enable_as_fd = false;
Expand Down Expand Up @@ -81,21 +73,6 @@ fn main() {
}
}

// The `addr_of` and `addr_of_mut` macros were stabilized in 1.51.
if ac.probe_rustc_version(1, 52) {
enable_addr_of = true;
} else if ac.probe_rustc_version(1, 51) {
// This compiler claims to be 1.51, but there are some nightly
// compilers that claim to be 1.51 without supporting the
// feature. Explicitly probe to check if code using them
// compiles.
//
// The oldest nightly that supports the feature is 2021-01-31.
if ac.probe_expression(ADDR_OF_PROBE) {
enable_addr_of = true;
}
}

// The `target_has_atomic` cfg was stabilized in 1.60.
if ac.probe_rustc_version(1, 61) {
enable_target_has_atomic = true;
Expand Down Expand Up @@ -167,14 +144,6 @@ fn main() {
autocfg::emit("tokio_no_const_thread_local")
}

if !enable_addr_of {
// To disable this feature on compilers that support it, you can
// explicitly pass this flag with the following environment variable:
//
// RUSTFLAGS="--cfg tokio_no_addr_of"
autocfg::emit("tokio_no_addr_of")
}

if !enable_target_has_atomic {
// To disable this feature on compilers that support it, you can
// explicitly pass this flag with the following environment variable:
Expand Down
31 changes: 0 additions & 31 deletions tokio/src/macros/addr_of.rs
@@ -1,7 +1,6 @@
//! This module defines a macro that lets you go from a raw pointer to a struct
//! to a raw pointer to a field of the struct.

#[cfg(not(tokio_no_addr_of))]
macro_rules! generate_addr_of_methods {
(
impl<$($gen:ident)*> $struct_name:ty {$(
Expand All @@ -21,33 +20,3 @@ macro_rules! generate_addr_of_methods {
)*}
};
}

// The `addr_of_mut!` macro is only available for MSRV at least 1.51.0. This
// version of the macro uses a workaround for older versions of rustc.
#[cfg(tokio_no_addr_of)]
macro_rules! generate_addr_of_methods {
(
impl<$($gen:ident)*> $struct_name:ty {$(
$(#[$attrs:meta])*
$vis:vis unsafe fn $fn_name:ident(self: NonNull<Self>) -> NonNull<$field_type:ty> {
&self$(.$field_name:tt)+
}
)*}
) => {
impl<$($gen)*> $struct_name {$(
$(#[$attrs])*
$vis unsafe fn $fn_name(me: ::core::ptr::NonNull<Self>) -> ::core::ptr::NonNull<$field_type> {
let me = me.as_ptr();
let me_u8 = me as *mut u8;

let field_offset = {
let me_ref = &*me;
let field_ref_u8 = (&me_ref $(.$field_name)+ ) as *const $field_type as *const u8;
field_ref_u8.offset_from(me_u8)
};

::core::ptr::NonNull::new_unchecked(me_u8.offset(field_offset).cast())
}
)*}
};
}
1 change: 0 additions & 1 deletion tokio/src/net/tcp/listener.rs
Expand Up @@ -5,7 +5,6 @@ cfg_not_wasi! {
use crate::net::{to_socket_addrs, ToSocketAddrs};
}

use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::net::{self, SocketAddr};
Expand Down
1 change: 0 additions & 1 deletion tokio/src/net/tcp/stream.rs
Expand Up @@ -8,7 +8,6 @@ use crate::io::{AsyncRead, AsyncWrite, Interest, PollEvented, ReadBuf, Ready};
use crate::net::tcp::split::{split, ReadHalf, WriteHalf};
use crate::net::tcp::split_owned::{split_owned, OwnedReadHalf, OwnedWriteHalf};

use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::net::{Shutdown, SocketAddr};
Expand Down
1 change: 0 additions & 1 deletion tokio/src/net/udp.rs
@@ -1,7 +1,6 @@
use crate::io::{Interest, PollEvented, ReadBuf, Ready};
use crate::net::{to_socket_addrs, ToSocketAddrs};

use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::net::{self, Ipv4Addr, Ipv6Addr, SocketAddr};
Expand Down
1 change: 0 additions & 1 deletion tokio/src/net/unix/datagram/socket.rs
@@ -1,7 +1,6 @@
use crate::io::{Interest, PollEvented, ReadBuf, Ready};
use crate::net::unix::SocketAddr;

use std::convert::TryFrom;
use std::fmt;
use std::io;
use std::net::Shutdown;
Expand Down
1 change: 0 additions & 1 deletion tokio/src/net/unix/listener.rs
@@ -1,7 +1,6 @@
use crate::io::{Interest, PollEvented};
use crate::net::unix::{SocketAddr, UnixStream};

use std::convert::TryFrom;
use std::fmt;
use std::io;
#[cfg(not(tokio_no_as_fd))]
Expand Down
1 change: 0 additions & 1 deletion tokio/src/net/unix/stream.rs
Expand Up @@ -5,7 +5,6 @@ use crate::net::unix::split_owned::{split_owned, OwnedReadHalf, OwnedWriteHalf};
use crate::net::unix::ucred::{self, UCred};
use crate::net::unix::SocketAddr;

use std::convert::TryFrom;
use std::fmt;
use std::io::{self, Read, Write};
use std::net::Shutdown;
Expand Down
2 changes: 0 additions & 2 deletions tokio/src/process/mod.rs
Expand Up @@ -156,7 +156,6 @@
//! ```no_run
//! use tokio::join;
//! use tokio::process::Command;
//! use std::convert::TryInto;
//! use std::process::Stdio;
//!
//! #[tokio::main]
Expand Down Expand Up @@ -245,7 +244,6 @@ mod kill;
use crate::io::{AsyncRead, AsyncWrite, ReadBuf};
use crate::process::kill::Kill;

use std::convert::TryInto;
use std::ffi::OsStr;
use std::future::Future;
use std::io;
Expand Down
1 change: 0 additions & 1 deletion tokio/src/runtime/metrics/batch.rs
@@ -1,6 +1,5 @@
use crate::runtime::WorkerMetrics;

use std::convert::TryFrom;
use std::sync::atomic::Ordering::Relaxed;
use std::time::Instant;

Expand Down
2 changes: 0 additions & 2 deletions tokio/src/runtime/time/source.rs
@@ -1,7 +1,5 @@
use crate::time::{Clock, Duration, Instant};

use std::convert::TryInto;

/// A structure which handles conversion from Instants to u64 timestamps.
#[derive(Debug)]
pub(crate) struct TimeSource {
Expand Down
1 change: 0 additions & 1 deletion tokio/src/signal/windows/sys.rs
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::io;
use std::sync::Once;

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/time/instant.rs
Expand Up @@ -188,7 +188,7 @@ impl ops::Sub<Duration> for Instant {
type Output = Instant;

fn sub(self, rhs: Duration) -> Instant {
Instant::from_std(self.std - rhs)
Instant::from_std(std::time::Instant::sub(self.std, rhs))
}
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/time/interval.rs
Expand Up @@ -2,10 +2,10 @@ use crate::future::poll_fn;
use crate::time::{sleep_until, Duration, Instant, Sleep};
use crate::util::trace;

use std::future::Future;
use std::panic::Location;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{convert::TryInto, future::Future};

/// Creates new [`Interval`] that yields with interval of `period`. The first
/// tick completes immediately. The default [`MissedTickBehavior`] is
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/util/slab.rs
Expand Up @@ -560,7 +560,7 @@ impl<T> Slots<T> {
assert!(slot >= base, "unexpected pointer");

let idx = (slot - base) / width;
assert!(idx < self.slots.len() as usize);
assert!(idx < self.slots.len());

idx
}
Expand Down

0 comments on commit 0c8e824

Please sign in to comment.