Better SpawnToken error messages

This commit is contained in:
Dario Nieuwenhuis 2020-12-26 15:15:50 +01:00
parent 80c504cd95
commit db8b4ca565

View File

@ -225,15 +225,15 @@ unsafe impl<F: Future + 'static> Sync for Task<F> {}
//============= //=============
// Spawn token // Spawn token
#[must_use = "Calling a task function does nothing on its own. To spawn a task, pass the result to Executor::spawn()"] #[must_use = "Calling a task function does nothing on its own. You must pass the returned SpawnToken to Executor::spawn()"]
pub struct SpawnToken { pub struct SpawnToken {
header: Option<NonNull<Header>>, header: Option<NonNull<Header>>,
} }
impl Drop for SpawnToken { impl Drop for SpawnToken {
fn drop(&mut self) { fn drop(&mut self) {
// TODO maybe we can deallocate the task instead. // TODO deallocate the task instead.
panic!("Please do not drop SpawnToken instances") panic!("SpawnToken instances may not be dropped. You must pass them to Executor::spawn()")
} }
} }