From 2d0dc891fd4007d863360d0d1674153fa4250387 Mon Sep 17 00:00:00 2001 From: iriri <32588326+iriri@users.noreply.github.com> Date: Mon, 23 Feb 2026 00:11:28 -0800 Subject: [PATCH 1/2] Uglify local `use` declarations in `tokio::select!` --- tokio/src/macros/select.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tokio/src/macros/select.rs b/tokio/src/macros/select.rs index 351ca24ee80..108e70f6b0b 100644 --- a/tokio/src/macros/select.rs +++ b/tokio/src/macros/select.rs @@ -615,9 +615,9 @@ doc! {macro_rules! select { // `tokio::macros::support` is a public, but doc(hidden) module // including a re-export of all types needed by this macro. - use $crate::macros::support::Future; - use $crate::macros::support::Pin; - use $crate::macros::support::Poll::{Ready, Pending}; + use $crate::macros::support::Future as __Future; + use $crate::macros::support::Pin as __Pin; + use $crate::macros::support::Poll::{Ready as __Ready, Pending as __Pending}; const BRANCHES: u32 = $crate::count!( $($count)* ); @@ -701,12 +701,12 @@ doc! {macro_rules! select { // Safety: future is stored on the stack above // and never moved. - let mut fut = unsafe { Pin::new_unchecked(fut) }; + let mut fut = unsafe { __Pin::new_unchecked(fut) }; // Try polling it - let out = match Future::poll(fut, cx) { - Ready(out) => out, - Pending => { + let out = match __Future::poll(fut, cx) { + __Ready(out) => out, + __Pending => { // Track that at least one future is // still pending and continue polling. is_pending = true; @@ -727,7 +727,7 @@ doc! {macro_rules! select { } // The select is complete, return the value - return Ready($crate::select_variant!(__tokio_select_util::Out, ($($skip)*))(out)); + return __Ready($crate::select_variant!(__tokio_select_util::Out, ($($skip)*))(out)); } )* _ => unreachable!("reaching this means there probably is an off by one bug"), @@ -735,10 +735,10 @@ doc! {macro_rules! select { } if is_pending { - Pending + __Pending } else { // All branches have been disabled. - Ready(__tokio_select_util::Out::Disabled) + __Ready(__tokio_select_util::Out::Disabled) } }).await }; From 00b040e5c5e0fdc986d4c065feca28ceca53e316 Mon Sep 17 00:00:00 2001 From: iriri <32588326+iriri@users.noreply.github.com> Date: Mon, 23 Feb 2026 00:34:27 -0800 Subject: [PATCH 2/2] Use fully qualified paths, but revert the change to `Pin` Downstream crates unfortunately (and likely unknowningly) depend on `std::pin::Pin` being implicitly brought into scope in `tokio::select!`. --- tokio/src/macros/select.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tokio/src/macros/select.rs b/tokio/src/macros/select.rs index 108e70f6b0b..257fac40451 100644 --- a/tokio/src/macros/select.rs +++ b/tokio/src/macros/select.rs @@ -615,9 +615,7 @@ doc! {macro_rules! select { // `tokio::macros::support` is a public, but doc(hidden) module // including a re-export of all types needed by this macro. - use $crate::macros::support::Future as __Future; - use $crate::macros::support::Pin as __Pin; - use $crate::macros::support::Poll::{Ready as __Ready, Pending as __Pending}; + use $crate::macros::support::Pin; const BRANCHES: u32 = $crate::count!( $($count)* ); @@ -701,12 +699,12 @@ doc! {macro_rules! select { // Safety: future is stored on the stack above // and never moved. - let mut fut = unsafe { __Pin::new_unchecked(fut) }; + let mut fut = unsafe { Pin::new_unchecked(fut) }; // Try polling it - let out = match __Future::poll(fut, cx) { - __Ready(out) => out, - __Pending => { + let out = match $crate::macros::support::Future::poll(fut, cx) { + $crate::macros::support::Poll::Ready(out) => out, + $crate::macros::support::Poll::Pending => { // Track that at least one future is // still pending and continue polling. is_pending = true; @@ -727,7 +725,7 @@ doc! {macro_rules! select { } // The select is complete, return the value - return __Ready($crate::select_variant!(__tokio_select_util::Out, ($($skip)*))(out)); + return $crate::macros::support::Poll::Ready($crate::select_variant!(__tokio_select_util::Out, ($($skip)*))(out)); } )* _ => unreachable!("reaching this means there probably is an off by one bug"), @@ -735,10 +733,10 @@ doc! {macro_rules! select { } if is_pending { - __Pending + $crate::macros::support::Poll::Pending } else { // All branches have been disabled. - __Ready(__tokio_select_util::Out::Disabled) + $crate::macros::support::Poll::Ready(__tokio_select_util::Out::Disabled) } }).await };