Mpsc::Sender::send() only returns SendError once, then succeeds


#1

If the receiver is gone, send only returns an error once:

use std::sync::mpsc::{channel, SendError};

#[test]
fn doublesend() {
    let (tx, _) = channel();
    
    assert_eq!(tx.send(123), Err(SendError(123)));  // OK
    assert_eq!(tx.send(123), Err(SendError(123)));  // Fails - returns success
}

This fails with:
thread 'doublesend' panicked at 'assertion failed:(left == right)(left:Ok(()), right:Err(“SendError(…)”))', <anon>:8

It seems like a bug. Is it intended?

https://play.rust-lang.org/?gist=ab77c7835df90477ba2e&version=stable


#2

Seems like a bug. It’s something that only happens if the receiver drops before the first send, too.


#3

I filed an issue: https://github.com/rust-lang/rust/issues/32114