Skip to content

Commit fd6c9db

Browse files
committed
docs: Make empty listener panic clearer
This commit makes the panic message for a listener that's not inserted into the linked list much clearer. The goal is to convey to the user that they may be `poll`ing the listener after it has completed. This commit also fixes some new Clippy lints. cc #124 Signed-off-by: John Nunley <[email protected]>
1 parent 8f11a87 commit fd6c9db

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
//! [`portable-atomic`]: https://crates.io/crates/portable-atomic
6969
7070
#![cfg_attr(not(feature = "std"), no_std)]
71+
#![allow(clippy::multiple_bound_locations)] // pin_project_lite can't work around this
7172
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
7273
#![doc(
7374
html_favicon_url = "https://raw.githubusercontent.com/smol-rs/smol/master/assets/images/logo_fullsize_transparent.png"
@@ -1248,7 +1249,7 @@ impl<T> RegisterResult<T> {
12481249
match self {
12491250
Self::Notified(tag) => Some(tag),
12501251
Self::Registered => None,
1251-
Self::NeverInserted => panic!("listener was never inserted into the list"),
1252+
Self::NeverInserted => panic!("{}", NEVER_INSERTED_PANIC),
12521253
}
12531254
}
12541255
}
@@ -1326,6 +1327,9 @@ impl TaskRef<'_> {
13261327
}
13271328
}
13281329

1330+
const NEVER_INSERTED_PANIC: &str = "\
1331+
EventListener was not inserted into the linked list, make sure you're not polling EventListener/listener! after it has finished";
1332+
13291333
/// Synchronization primitive implementation.
13301334
mod sync {
13311335
pub(super) use core::cell;

0 commit comments

Comments
 (0)