macros: rename tokio::select!'s internal util module (#4543)

This internal module's identifier can clash with existing identifiers in library users' code and produce confusing error messages.
This commit is contained in:
William
2022-03-02 13:37:37 +01:00
committed by GitHub
parent fb9a01b362
commit ba49294bae
+8 -7
View File
@@ -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)* ) );
}
@@ -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;
}
)*
@@ -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"),
@@ -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"),
}
}};