task: remove raw-entry feature from hashbrown dep (#7252)

This commit is contained in:
Conrad Ludgate
2025-07-22 15:52:54 +02:00
committed by GitHub
parent 0d234c3cf9
commit 9e94fa7e15
3 changed files with 100 additions and 105 deletions
+33
View File
@@ -1,6 +1,8 @@
#![warn(rust_2018_idioms)]
#![cfg(all(feature = "rt", tokio_unstable))]
use std::panic::AssertUnwindSafe;
use tokio::sync::oneshot;
use tokio::time::Duration;
use tokio_util::task::JoinMap;
@@ -343,3 +345,34 @@ async fn duplicate_keys2() {
assert!(map.join_next().await.is_none());
}
#[cfg_attr(not(panic = "unwind"), ignore)]
#[tokio::test]
async fn duplicate_keys_drop() {
#[derive(Hash, Debug, PartialEq, Eq)]
struct Key;
impl Drop for Key {
fn drop(&mut self) {
panic!("drop called for key");
}
}
let (send, recv) = oneshot::channel::<()>();
let mut map = JoinMap::new();
map.spawn(Key, async { recv.await.unwrap() });
// replace the task, force it to drop the key and abort the task
// we should expect it to panic when dropping the key.
let _ = std::panic::catch_unwind(AssertUnwindSafe(|| map.spawn(Key, async {}))).unwrap_err();
// don't panic when this key drops.
let (key, _) = map.join_next().await.unwrap();
std::mem::forget(key);
// original task should have been aborted, so the sender should be dangling.
assert!(send.is_closed());
assert!(map.join_next().await.is_none());
}