Skip to content

Commit

Permalink
Rename tokio::select!'s internal util module to `__tokio_select_u…
Browse files Browse the repository at this point in the history
…til`

This internal module's identifier can clash with existing identifiers in library users' code and produce confusing error messages
  • Loading branch information
WilliamVenner committed Feb 25, 2022
1 parent ac69d37 commit 20794d2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tokio/src/macros/select.rs
Expand Up @@ -429,7 +429,8 @@ macro_rules! select {
//
// This module is defined within a scope and should not leak out of this
// macro.
mod util {
#[doc(hidden)]
mod __tokio_select_util {
// Generate an enum with one variant per select branch
$crate::select_priv_declare_output_enum!( ( $($count)* ) );
}
Expand All @@ -442,13 +443,13 @@ macro_rules! select {

const BRANCHES: u32 = $crate::count!( $($count)* );

let mut disabled: util::Mask = Default::default();
let mut disabled: __tokio_select_util::Mask = Default::default();

// First, invoke all the pre-conditions. For any that return true,
// set the appropriate bit in `disabled`.
$(
if !$c {
let mask: util::Mask = 1 << $crate::count!( $($skip)* );
let mask: __tokio_select_util::Mask = 1 << $crate::count!( $($skip)* );
disabled |= mask;
}
)*
Expand Down Expand Up @@ -525,7 +526,7 @@ macro_rules! select {
}

// The select is complete, return the value
return Ready($crate::select_variant!(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"),
Expand All @@ -536,16 +537,16 @@ macro_rules! select {
Pending
} else {
// All branches have been disabled.
Ready(util::Out::Disabled)
Ready(__tokio_select_util::Out::Disabled)
}
}).await
};

match output {
$(
$crate::select_variant!(util::Out, ($($skip)*) ($bind)) => $handle,
$crate::select_variant!(__tokio_select_util::Out, ($($skip)*) ($bind)) => $handle,
)*
util::Out::Disabled => $else,
__tokio_select_util::Out::Disabled => $else,
_ => unreachable!("failed to match bind"),
}
}};
Expand Down

0 comments on commit 20794d2

Please sign in to comment.