Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tokio: bump MSRV to 1.56 #5559

Merged
merged 5 commits into from
Mar 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.49"
msrv = "1.56"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

@@ -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
2 changes: 1 addition & 1 deletion tokio-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion tokio-stream/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion tokio-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion tokio-util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 1 addition & 5 deletions tokio-util/src/sync/cancellation_token/tree_node.rs
Original file line number Diff line number Diff line change
@@ -243,11 +243,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);
}
}

4 changes: 2 additions & 2 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
21 changes: 17 additions & 4 deletions tokio/README.md
Original file line number Diff line number Diff line change
@@ -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

@@ -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
31 changes: 0 additions & 31 deletions tokio/build.rs
Original file line number Diff line number Diff line change
@@ -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);
@@ -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;
@@ -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;
@@ -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:
31 changes: 0 additions & 31 deletions tokio/src/macros/addr_of.rs
Original file line number Diff line number Diff line change
@@ -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 {$(
@@ -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
Original file line number Diff line number Diff line change
@@ -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};
1 change: 0 additions & 1 deletion tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
@@ -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};
1 change: 0 additions & 1 deletion tokio/src/net/udp.rs
Original file line number Diff line number Diff line change
@@ -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};
1 change: 0 additions & 1 deletion tokio/src/net/unix/datagram/socket.rs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 0 additions & 1 deletion tokio/src/net/unix/listener.rs
Original file line number Diff line number Diff line change
@@ -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))]
1 change: 0 additions & 1 deletion tokio/src/net/unix/stream.rs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 0 additions & 2 deletions tokio/src/process/mod.rs
Original file line number Diff line number Diff line change
@@ -156,7 +156,6 @@
//! ```no_run
//! use tokio::join;
//! use tokio::process::Command;
//! use std::convert::TryInto;
//! use std::process::Stdio;
//!
//! #[tokio::main]
@@ -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;
1 change: 0 additions & 1 deletion tokio/src/runtime/metrics/batch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::runtime::WorkerMetrics;

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

2 changes: 0 additions & 2 deletions tokio/src/runtime/time/source.rs
Original file line number Diff line number Diff line change
@@ -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 {
1 change: 0 additions & 1 deletion tokio/src/signal/windows/sys.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::TryFrom;
use std::io;
use std::sync::Once;

2 changes: 1 addition & 1 deletion tokio/src/time/instant.rs
Original file line number Diff line number Diff line change
@@ -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))
}
}

2 changes: 1 addition & 1 deletion tokio/src/time/interval.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tokio/src/util/slab.rs
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 38 additions & 29 deletions tokio/tests/macros_select.rs
Original file line number Diff line number Diff line change
@@ -206,47 +206,56 @@ async fn nested() {
assert_eq!(res, 3);
}

#[maybe_tokio_test]
#[cfg(target_pointer_width = "64")]
async fn struct_size() {
mod pointer_64_tests {
use super::maybe_tokio_test;
use futures::future;
use std::mem;

let fut = async {
let ready = future::ready(0i32);
#[maybe_tokio_test]
async fn struct_size_1() {
let fut = async {
let ready = future::ready(0i32);

tokio::select! {
_ = ready => {},
}
};
tokio::select! {
_ = ready => {},
}
};

assert_eq!(mem::size_of_val(&fut), 40);
assert_eq!(mem::size_of_val(&fut), 32);
}

let fut = async {
let ready1 = future::ready(0i32);
let ready2 = future::ready(0i32);
#[maybe_tokio_test]
async fn struct_size_2() {
let fut = async {
let ready1 = future::ready(0i32);
let ready2 = future::ready(0i32);

tokio::select! {
_ = ready1 => {},
_ = ready2 => {},
}
};
tokio::select! {
_ = ready1 => {},
_ = ready2 => {},
}
};

assert_eq!(mem::size_of_val(&fut), 48);
assert_eq!(mem::size_of_val(&fut), 40);
}

let fut = async {
let ready1 = future::ready(0i32);
let ready2 = future::ready(0i32);
let ready3 = future::ready(0i32);
#[maybe_tokio_test]
async fn struct_size_3() {
let fut = async {
let ready1 = future::ready(0i32);
let ready2 = future::ready(0i32);
let ready3 = future::ready(0i32);

tokio::select! {
_ = ready1 => {},
_ = ready2 => {},
_ = ready3 => {},
}
};
tokio::select! {
_ = ready1 => {},
_ = ready2 => {},
_ = ready3 => {},
}
};

assert_eq!(mem::size_of_val(&fut), 56);
assert_eq!(mem::size_of_val(&fut), 48);
}
}

#[maybe_tokio_test]
1 change: 0 additions & 1 deletion tokio/tests/net_bind_resource.rs
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@

use tokio::net::TcpListener;

use std::convert::TryFrom;
use std::net;

#[test]
2 changes: 1 addition & 1 deletion tokio/tests/process_kill_on_drop.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use tokio_test::assert_ok;
#[tokio::test]
async fn kill_on_drop() {
let mut cmd = Command::new("bash");
cmd.args(&[
cmd.args([
"-c",
"
# Fork another child that won't get killed
2 changes: 1 addition & 1 deletion tokio/tests/tcp_peek.rs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ use tokio::net::TcpStream;
use tokio_test::assert_ok;

use std::thread;
use std::{convert::TryInto, io::Write, net};
use std::{io::Write, net};

#[tokio::test]
async fn peek() {