Skip to content

Commit

Permalink
macros: add #[allow(unused_mut)] to select! (#2858)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Sep 22, 2020
1 parent cb8f2ce commit e09b90e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions tokio/src/macros/select.rs
Expand Up @@ -404,6 +404,7 @@ macro_rules! select {
// The future returned a value, check if matches
// the specified pattern.
#[allow(unused_variables)]
#[allow(unused_mut)]
match &out {
$bind => {}
_ => continue,
Expand Down
17 changes: 17 additions & 0 deletions tokio/tests/macros_select.rs
Expand Up @@ -462,3 +462,20 @@ async fn async_never() -> ! {
tokio::time::delay_for(Duration::from_millis(10)).await;
}
}

// From https://github.com/tokio-rs/tokio/issues/2857
#[tokio::test]
async fn mut_on_left_hand_side() {
let v = async move {
let ok = async { 1 };
tokio::pin!(ok);
tokio::select! {
mut a = &mut ok => {
a += 1;
a
}
}
}
.await;
assert_eq!(v, 2);
}

0 comments on commit e09b90e

Please sign in to comment.