Skip to content

Commit

Permalink
Merge branch 'tokio-rs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tglane authored Apr 2, 2024
2 parents f231a51 + e9ae5d4 commit 8012200
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
# Change to specific Rust release to pin
rust_stable: stable
rust_nightly: nightly-2023-10-21
rust_clippy: '1.76'
rust_clippy: '1.77'
# When updating this, also update:
# - README.md
# - tokio/README.md
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ When updating this, also update:
-->

```
cargo +1.76 clippy --all --tests --all-features
cargo +1.77 clippy --all --tests --all-features
```

When building documentation normally, the markers that list the features
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ full = ["codec", "compat", "io-util", "time", "net", "rt"]

net = ["tokio/net"]
compat = ["futures-io",]
codec = ["tracing"]
codec = []
time = ["tokio/time","slab"]
io = []
io-util = ["io", "tokio/rt", "tokio/io-util"]
Expand Down
1 change: 0 additions & 1 deletion tokio-util/src/codec/framed_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::borrow::{Borrow, BorrowMut};
use std::io;
use std::pin::Pin;
use std::task::{Context, Poll};
use tracing::trace;

pin_project! {
#[derive(Debug)]
Expand Down
3 changes: 3 additions & 0 deletions tokio-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ mod cfg;
mod loom;

cfg_codec! {
#[macro_use]
mod tracing;

pub mod codec;
}

Expand Down
6 changes: 6 additions & 0 deletions tokio-util/src/tracing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
macro_rules! trace {
($($arg:tt)*) => {
#[cfg(feature = "tracing")]
tracing::trace!($($arg)*);
};
}
1 change: 1 addition & 0 deletions tokio-util/tests/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async fn compat_file_seek() -> futures_util::io::Result<()> {
.read(true)
.write(true)
.create(true)
.truncate(true)
.open(temp_file)
.await?
.compat_write();
Expand Down
15 changes: 14 additions & 1 deletion tokio/src/io/join.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Join two values implementing `AsyncRead` and `AsyncWrite` into a single one.
use crate::io::{AsyncRead, AsyncWrite, ReadBuf};
use crate::io::{AsyncBufRead, AsyncRead, AsyncWrite, ReadBuf};

use std::io;
use std::pin::Pin;
Expand Down Expand Up @@ -115,3 +115,16 @@ where
self.writer.is_write_vectored()
}
}

impl<R, W> AsyncBufRead for Join<R, W>
where
R: AsyncBufRead,
{
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&[u8]>> {
self.project().reader.poll_fill_buf(cx)
}

fn consume(self: Pin<&mut Self>, amt: usize) {
self.project().reader.consume(amt)
}
}
1 change: 1 addition & 0 deletions tokio/src/runtime/signal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl Driver {
// Drain the pipe completely so we can receive a new readiness event
// if another signal has come in.
let mut buf = [0; 128];
#[allow(clippy::unused_io_amount)]
loop {
match self.receiver.read(&mut buf) {
Ok(0) => panic!("EOF on self-pipe"),
Expand Down
2 changes: 1 addition & 1 deletion tokio/tests/io_async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn socketpair() -> (FileDescriptor, FileDescriptor) {

fn drain(mut fd: &FileDescriptor) {
let mut buf = [0u8; 512];

#[allow(clippy::unused_io_amount)]
loop {
match fd.read(&mut buf[..]) {
Err(e) if e.kind() == ErrorKind::WouldBlock => break,
Expand Down
4 changes: 2 additions & 2 deletions tokio/tests/rt_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ rt_test! {
use std::thread;

thread_local!(
static R: RefCell<Option<Runtime>> = RefCell::new(None);
static R: RefCell<Option<Runtime>> = const { RefCell::new(None) };
);

thread::spawn(|| {
Expand Down Expand Up @@ -1402,7 +1402,7 @@ rt_test! {
}

std::thread_local! {
static TL_DATA: RefCell<Option<TLData>> = RefCell::new(None);
static TL_DATA: RefCell<Option<TLData>> = const { RefCell::new(None) };
};

let (send, recv) = channel();
Expand Down
16 changes: 8 additions & 8 deletions tokio/tests/task_local_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async fn local_current_thread_scheduler() {
#[tokio::test(flavor = "multi_thread")]
async fn local_threadpool() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand All @@ -55,7 +55,7 @@ async fn local_threadpool() {
#[tokio::test(flavor = "multi_thread")]
async fn localset_future_threadpool() {
thread_local! {
static ON_LOCAL_THREAD: Cell<bool> = Cell::new(false);
static ON_LOCAL_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_LOCAL_THREAD.with(|cell| cell.set(true));
Expand Down Expand Up @@ -118,7 +118,7 @@ async fn local_threadpool_timer() {
// This test ensures that runtime services like the timer are properly
// set for the local task set.
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand Down Expand Up @@ -158,7 +158,7 @@ fn enter_guard_spawn() {
#[should_panic]
fn local_threadpool_blocking_in_place() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand All @@ -182,7 +182,7 @@ fn local_threadpool_blocking_in_place() {
#[tokio::test(flavor = "multi_thread")]
async fn local_threadpool_blocking_run() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand Down Expand Up @@ -212,7 +212,7 @@ async fn local_threadpool_blocking_run() {
async fn all_spawns_are_local() {
use futures::future;
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand All @@ -238,7 +238,7 @@ async fn all_spawns_are_local() {
#[tokio::test(flavor = "multi_thread")]
async fn nested_spawn_is_local() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand Down Expand Up @@ -274,7 +274,7 @@ async fn nested_spawn_is_local() {
#[test]
fn join_local_future_elsewhere() {
thread_local! {
static ON_RT_THREAD: Cell<bool> = Cell::new(false);
static ON_RT_THREAD: Cell<bool> = const { Cell::new(false) };
}

ON_RT_THREAD.with(|cell| cell.set(true));
Expand Down

0 comments on commit 8012200

Please sign in to comment.