diff --git a/tokio/src/sync/watch.rs b/tokio/src/sync/watch.rs index 401b68b50e4..273c96c8032 100644 --- a/tokio/src/sync/watch.rs +++ b/tokio/src/sync/watch.rs @@ -641,18 +641,19 @@ impl Sender { // Update the value and catch possible panic inside func. let result = panic::catch_unwind(panic::AssertUnwindSafe(|| modify(&mut lock))); match result { - Ok(true) => { + Ok(modified) => { + if !modified { + // Abort, i.e. don't notify receivers if unmodified + return false; + } // Continue if modified }, - Ok(false) => { - // Don't notify receivers if unmodified - return false; - } Err(panicked) => { // Drop the lock to avoid poisoning it. drop(lock); // Forward the panic to the caller. panic::resume_unwind(panicked); + // Unreachable } };