diff --git a/tokio-util/CHANGELOG.md b/tokio-util/CHANGELOG.md index 896857b27..735c1d917 100644 --- a/tokio-util/CHANGELOG.md +++ b/tokio-util/CHANGELOG.md @@ -1,3 +1,21 @@ +# 0.7.15 (April 23rd, 2025) + +### Fixed + +- task: properly handle removed entries in `JoinMap` ([#7264]) + +### Updated + +- deps: update hashbrown to 0.15 ([#7219]) + +### Documented + +- task: explicitly state that `TaskTracker` does not abort tasks on Drop ([#7223]) + +[#7219]: https://github.com/tokio-rs/tokio/pull/7219 +[#7223]: https://github.com/tokio-rs/tokio/pull/7223 +[#7264]: https://github.com/tokio-rs/tokio/pull/7264 + # 0.7.14 (March 12th, 2025) ### Added diff --git a/tokio-util/Cargo.toml b/tokio-util/Cargo.toml index 971286cbd..4187ebfb5 100644 --- a/tokio-util/Cargo.toml +++ b/tokio-util/Cargo.toml @@ -4,7 +4,7 @@ name = "tokio-util" # - Remove path dependencies # - Update CHANGELOG.md. # - Create "tokio-util-0.7.x" git tag. -version = "0.7.14" +version = "0.7.15" edition = "2021" rust-version = "1.70" authors = ["Tokio Contributors "] diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index a29b00a8d..a2f2ad6cf 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -131,7 +131,7 @@ features = [ tokio-test = { version = "0.4.0", path = "../tokio-test" } tokio-stream = { version = "0.1", path = "../tokio-stream" } futures = { version = "0.3.0", features = ["async-await"] } -mockall = "0.11.1" +mockall = "0.13.0" async-stream = "0.3" futures-concurrency = "7.6.3" diff --git a/tokio/src/fs/mocks.rs b/tokio/src/fs/mocks.rs index 54da6be93..5343fb90b 100644 --- a/tokio/src/fs/mocks.rs +++ b/tokio/src/fs/mocks.rs @@ -62,6 +62,13 @@ impl Read for MockFile { impl Read for &'_ MockFile { fn read(&mut self, dst: &mut [u8]) -> io::Result { + // Placate Miri. Tokio will call this method with an uninitialized + // buffer, which is ok because std::io::Read::read implementations don't usually read + // from their input buffers. But Mockall 0.12-0.13 will try to Debug::fmt the + // buffer, even if there is no failure, triggering an uninitialized data access alert from + // Miri. Initialize the data here just to prevent those Miri alerts. + // This can be removed after upgrading to Mockall 0.14. + dst.fill(0); self.inner_read(dst) } } diff --git a/tokio/src/net/tcp/listener.rs b/tokio/src/net/tcp/listener.rs index d29e6ee13..95a2469cc 100644 --- a/tokio/src/net/tcp/listener.rs +++ b/tokio/src/net/tcp/listener.rs @@ -84,13 +84,12 @@ impl TcpListener { /// # Examples /// /// ```no_run - /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::TcpListener; - /// /// use std::io; /// /// #[tokio::main] /// async fn main() -> io::Result<()> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// let listener = TcpListener::bind("127.0.0.1:2345").await?; /// /// // use the listener diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index a9b454b3c..27c97700f 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -743,12 +743,12 @@ impl TcpSocket { /// # Examples /// /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::TcpSocket; /// use socket2::{Domain, Socket, Type}; /// /// #[tokio::main] /// async fn main() -> std::io::Result<()> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// let socket2_socket = Socket::new(Domain::IPV4, Type::STREAM, None)?; /// socket2_socket.set_nonblocking(true)?; /// diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 7c753741c..b0e3ec27c 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -220,7 +220,6 @@ impl TcpStream { /// # Examples /// /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// use std::error::Error; /// use std::io::Read; /// use tokio::net::TcpListener; @@ -229,6 +228,7 @@ impl TcpStream { /// /// #[tokio::main] /// async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// let mut data = [0u8; 12]; /// # if false { /// let listener = TcpListener::bind("127.0.0.1:34254").await?; diff --git a/tokio/src/net/udp.rs b/tokio/src/net/udp.rs index 044096eb6..c6406a240 100644 --- a/tokio/src/net/udp.rs +++ b/tokio/src/net/udp.rs @@ -135,12 +135,12 @@ impl UdpSocket { /// # Example /// /// ```no_run - /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::UdpSocket; /// use std::io; /// /// #[tokio::main] /// async fn main() -> io::Result<()> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// let sock = UdpSocket::bind("0.0.0.0:8080").await?; /// // use `sock` /// # let _ = sock; @@ -303,12 +303,12 @@ impl UdpSocket { /// # Example /// /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::UdpSocket; /// /// # use std::{io, net::SocketAddr}; /// # #[tokio::main] /// # async fn main() -> io::Result<()> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// let addr = "0.0.0.0:8080".parse::().unwrap(); /// let peer = "127.0.0.1:11100".parse::().unwrap(); /// let sock = UdpSocket::bind(addr).await?; @@ -2130,12 +2130,12 @@ impl UdpSocket { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// use tokio::net::UdpSocket; /// use std::io; /// /// #[tokio::main] /// async fn main() -> io::Result<()> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// // Create a socket /// let socket = UdpSocket::bind("0.0.0.0:8080").await?; /// diff --git a/tokio/src/net/unix/datagram/socket.rs b/tokio/src/net/unix/datagram/socket.rs index 4f1fb6695..0a065ec3e 100644 --- a/tokio/src/net/unix/datagram/socket.rs +++ b/tokio/src/net/unix/datagram/socket.rs @@ -36,10 +36,10 @@ cfg_net_unix! { /// # Examples /// Using named sockets, associated with a filesystem path: /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -69,10 +69,10 @@ cfg_net_unix! { /// /// Using unnamed sockets, created as a pair /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// /// // Create the pair of sockets @@ -374,10 +374,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -407,10 +407,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// /// // Create the pair of sockets @@ -466,10 +466,10 @@ impl UnixDatagram { /// explicitly with [`Runtime::enter`](crate::runtime::Runtime::enter) function. /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use std::os::unix::net::UnixDatagram as StdUDS; /// use tempfile::tempdir; @@ -533,10 +533,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -573,10 +573,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -618,10 +618,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// /// // Create the pair of sockets @@ -749,10 +749,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// /// // Create the pair of sockets @@ -900,10 +900,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -1017,10 +1017,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// /// // Create the pair of sockets @@ -1068,10 +1068,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -1119,10 +1119,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -1436,10 +1436,10 @@ impl UnixDatagram { /// # Examples /// For a socket bound to a local path /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -1459,10 +1459,10 @@ impl UnixDatagram { /// /// For an unbound socket /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// /// // Create an unbound socket @@ -1484,10 +1484,10 @@ impl UnixDatagram { /// # Examples /// For a peer with a local path /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// use tempfile::tempdir; /// @@ -1510,10 +1510,10 @@ impl UnixDatagram { /// /// For an unbound peer /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// /// // Create the pair of sockets @@ -1532,10 +1532,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// use tokio::net::UnixDatagram; /// /// // Create an unbound socket @@ -1560,10 +1560,10 @@ impl UnixDatagram { /// /// # Examples /// ``` - /// # if cfg!(miri) { return } // No SOCK_DGRAM for `socketpair` in miri. /// # use std::error::Error; /// # #[tokio::main] /// # async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No SOCK_DGRAM for `socketpair` in miri. /// use tokio::net::UnixDatagram; /// use std::net::Shutdown; /// diff --git a/tokio/src/net/unix/stream.rs b/tokio/src/net/unix/stream.rs index 3f3220cd8..867b5b81e 100644 --- a/tokio/src/net/unix/stream.rs +++ b/tokio/src/net/unix/stream.rs @@ -840,7 +840,6 @@ impl UnixStream { /// # Examples /// /// ``` - /// # if cfg!(miri) { return } // No `socket` in miri. /// use std::error::Error; /// use std::io::Read; /// use tokio::net::UnixListener; @@ -849,6 +848,7 @@ impl UnixStream { /// /// #[tokio::main] /// async fn main() -> Result<(), Box> { + /// # if cfg!(miri) { return Ok(()); } // No `socket` in miri. /// let dir = tempfile::tempdir().unwrap(); /// let bind_path = dir.path().join("bind_path"); /// diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 0616a11b2..eba17cff3 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -810,7 +810,6 @@ impl Command { /// Basic usage: /// /// ```no_run - /// # if cfg!(miri) { return } // No `pidfd_spawnp` in miri. /// use tokio::process::Command; /// /// async fn run_ls() -> std::process::ExitStatus { @@ -1347,7 +1346,6 @@ impl Child { /// This function is cancel safe. /// /// ``` - /// # if cfg!(miri) { return } // No `pidfd_spawnp` in miri. /// # #[cfg(not(unix))]fn main(){} /// # #[cfg(unix)] /// use tokio::io::AsyncWriteExt; @@ -1359,6 +1357,7 @@ impl Child { /// # #[cfg(unix)] /// #[tokio::main] /// async fn main() { + /// # if cfg!(miri) { return; } // No `pidfd_spawnp` in miri. /// let mut child = Command::new("cat") /// .stdin(Stdio::piped()) /// .spawn() diff --git a/tokio/src/runtime/runtime.rs b/tokio/src/runtime/runtime.rs index 421a9be0e..2f2b07d32 100644 --- a/tokio/src/runtime/runtime.rs +++ b/tokio/src/runtime/runtime.rs @@ -407,7 +407,6 @@ impl Runtime { /// # Examples /// /// ``` - /// # if cfg!(miri) { return } // Miri reports error when main thread terminated without waiting all remaining threads. /// use tokio::runtime::Runtime; /// use tokio::task; /// @@ -415,6 +414,7 @@ impl Runtime { /// use std::time::Duration; /// /// fn main() { + /// # if cfg!(miri) { return } // Miri reports error when main thread terminated without waiting all remaining threads. /// let runtime = Runtime::new().unwrap(); /// /// runtime.block_on(async move {