tokio: raise MSRV to 1.71 (#7658)

This commit is contained in:
Alice Ryhl
2025-10-02 11:14:17 +02:00
committed by GitHub
parent c1f0c76fa0
commit 5b4cbbc39e
11 changed files with 26 additions and 51 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ env:
# - tokio-util/Cargo.toml
# - tokio-test/Cargo.toml
# - tokio-stream/Cargo.toml
rust_min: '1.70'
rust_min: '1.71'
# This excludes unstable features like io_uring,
# which require '--cfg tokio_unstable'.
TOKIO_STABLE_FEATURES: "full,test-util"
+3 -2
View File
@@ -186,12 +186,13 @@ 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.70.
released at least six months ago. The current MSRV is 1.71.
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.39 to now - Rust 1.70
* 1.48 to now - Rust 1.71
* 1.39 to 1.47 - Rust 1.70
* 1.30 to 1.38 - Rust 1.63
* 1.27 to 1.29 - Rust 1.56
* 1.17 to 1.26 - Rust 1.49
+1 -1
View File
@@ -6,7 +6,7 @@ name = "tokio-macros"
# - Create "tokio-macros-x.y.z" git tag.
version = "2.5.0"
edition = "2021"
rust-version = "1.70"
rust-version = "1.71"
authors = ["Tokio Contributors <[email protected]>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
+1 -1
View File
@@ -6,7 +6,7 @@ name = "tokio-stream"
# - Create "tokio-stream-0.1.x" git tag.
version = "0.1.17"
edition = "2021"
rust-version = "1.70"
rust-version = "1.71"
authors = ["Tokio Contributors <[email protected]>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
+2 -9
View File
@@ -734,22 +734,15 @@ mod rand {
#[cfg(not(loom))]
pub(crate) mod rand {
use std::collections::hash_map::RandomState;
use std::hash::{BuildHasher, Hash, Hasher};
use std::hash::BuildHasher;
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering::Relaxed;
static COUNTER: AtomicU32 = AtomicU32::new(1);
pub(crate) fn seed() -> u64 {
let rand_state = RandomState::new();
let mut hasher = rand_state.build_hasher();
// Hash some unique-ish data to generate some new state
COUNTER.fetch_add(1, Relaxed).hash(&mut hasher);
// Get the seed
hasher.finish()
RandomState::new().hash_one(COUNTER.fetch_add(1, Relaxed))
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ name = "tokio-test"
# - Create "tokio-test-0.4.x" git tag.
version = "0.4.4"
edition = "2021"
rust-version = "1.70"
rust-version = "1.71"
authors = ["Tokio Contributors <[email protected]>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
+1 -1
View File
@@ -6,7 +6,7 @@ name = "tokio-util"
# - Create "tokio-util-0.7.x" git tag.
version = "0.7.16"
edition = "2021"
rust-version = "1.70"
rust-version = "1.71"
authors = ["Tokio Contributors <[email protected]>"]
license = "MIT"
repository = "https://github.com/tokio-rs/tokio"
+11 -25
View File
@@ -4,7 +4,7 @@ use std::borrow::Borrow;
use std::collections::hash_map::RandomState;
use std::fmt;
use std::future::Future;
use std::hash::{BuildHasher, Hash, Hasher};
use std::hash::{BuildHasher, Hash};
use std::marker::PhantomData;
use tokio::runtime::Handle;
use tokio::task::{AbortHandle, Id, JoinError, JoinSet, LocalSet};
@@ -391,13 +391,13 @@ where
fn insert(&mut self, mut key: K, mut abort: AbortHandle) {
let hash_builder = self.hashes_by_task.hasher();
let hash = hash_one(hash_builder, &key);
let hash = hash_builder.hash_one(&key);
let id = abort.id();
// Insert the new key into the map of tasks by keys.
let entry =
self.tasks_by_key
.entry(hash, |(k, _)| *k == key, |(k, _)| hash_one(hash_builder, k));
.entry(hash, |(k, _)| *k == key, |(k, _)| hash_builder.hash_one(k));
match entry {
Entry::Occupied(occ) => {
// There was a previous task spawned with the same key! Cancel
@@ -673,9 +673,9 @@ where
/// ```
#[inline]
pub fn reserve(&mut self, additional: usize) {
let hash_builder = self.hashes_by_task.hasher();
self.tasks_by_key
.reserve(additional, |(k, _)| hash_one(hash_builder, k));
self.tasks_by_key.reserve(additional, |(k, _)| {
self.hashes_by_task.hasher().hash_one(k)
});
self.hashes_by_task.reserve(additional);
}
@@ -701,9 +701,8 @@ where
#[inline]
pub fn shrink_to_fit(&mut self) {
self.hashes_by_task.shrink_to_fit();
let hash_builder = self.hashes_by_task.hasher();
self.tasks_by_key
.shrink_to_fit(|(k, _)| hash_one(hash_builder, k));
.shrink_to_fit(|(k, _)| self.hashes_by_task.hasher().hash_one(k));
}
/// Shrinks the capacity of the map with a lower limit. It will drop
@@ -732,9 +731,9 @@ where
#[inline]
pub fn shrink_to(&mut self, min_capacity: usize) {
self.hashes_by_task.shrink_to(min_capacity);
let hash_builder = self.hashes_by_task.hasher();
self.tasks_by_key
.shrink_to(min_capacity, |(k, _)| hash_one(hash_builder, k))
self.tasks_by_key.shrink_to(min_capacity, |(k, _)| {
self.hashes_by_task.hasher().hash_one(k)
})
}
/// Look up a task in the map by its key, returning the key and abort handle.
@@ -743,8 +742,7 @@ where
Q: ?Sized + Hash + Eq,
K: Borrow<Q>,
{
let hash_builder = self.hashes_by_task.hasher();
let hash = hash_one(hash_builder, key);
let hash = self.hashes_by_task.hasher().hash_one(key);
self.tasks_by_key.find(hash, |(k, _)| k.borrow() == key)
}
@@ -765,18 +763,6 @@ where
}
}
/// Returns the hash for a given key.
#[inline]
fn hash_one<S, Q>(hash_builder: &S, key: &Q) -> u64
where
Q: ?Sized + Hash,
S: BuildHasher,
{
let mut hasher = hash_builder.build_hasher();
key.hash(&mut hasher);
hasher.finish()
}
impl<K, V, S> JoinMap<K, V, S>
where
V: 'static,
+1 -1
View File
@@ -8,7 +8,7 @@ name = "tokio"
# - Create "v1.x.y" git tag.
version = "1.47.1"
edition = "2021"
rust-version = "1.70"
rust-version = "1.71"
authors = ["Tokio Contributors <[email protected]>"]
license = "MIT"
readme = "README.md"
+3 -2
View File
@@ -186,12 +186,13 @@ 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.70.
released at least six months ago. The current MSRV is 1.71.
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.39 to now - Rust 1.70
* 1.48 to now - Rust 1.71
* 1.39 to 1.47 - Rust 1.70
* 1.30 to 1.38 - Rust 1.63
* 1.27 to 1.29 - Rust 1.56
* 1.17 to 1.26 - Rust 1.49
+1 -7
View File
@@ -39,14 +39,8 @@ pub(crate) mod rand {
pub(crate) fn seed() -> u64 {
let rand_state = RandomState::new();
let mut hasher = rand_state.build_hasher();
// Hash some unique-ish data to generate some new state
COUNTER.fetch_add(1, Relaxed).hash(&mut hasher);
// Get the seed
hasher.finish()
rand_state.hash_one(COUNTER.fetch_add(1, Relaxed))
}
}