Skip to content

std::error::Error is not implemented for std::sync::mpsc::RecvTimeoutError #37525

Closed
@twittner

Description

@twittner

It seems that std::sync::mpsc::RecvTimeoutError is missing impls for std::fmt::Display and std::error::Error. Related error types such as std::sync::mpsc::TryRecvError implement both.

I tried this code:

use std::error::Error;
use std::sync::mpsc;
use std::time::Duration;

fn f(r: mpsc::Receiver<()>) -> Result<(), Box<Error>> {
    let _ = r.recv_timeout(Duration::from_secs(3))?;
    Ok(())
}

fn main() {
    let (_, rx) = mpsc::channel();
    let _ = f(rx);
}

I expected to see this happen: compilation succeeds

Instead, this happened:

rustc 1.14.0-nightly (3f4408347 2016-10-27)
error[E0277]: the trait bound `std::sync::mpsc::RecvTimeoutError: std::error::Error` is not satisfied
 --> <anon>:6:13
  |
6 |     let _ = r.recv_timeout(Duration::from_secs(3))?;
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `std::sync::mpsc::RecvTimeoutError`
  |
  = note: required because of the requirements on the impl of `std::convert::From<std::sync::mpsc::RecvTimeoutError>` for `Box<std::error::Error>`
  = note: required by `std::convert::From::from`

error: aborting due to previous error

Meta

rustc --version --verbose:

rustc 1.14.0-nightly (3f4408347 2016-10-27)
binary: rustc
commit-hash: 3f4408347d2109803edbf53c89c8bce575de4b67
commit-date: 2016-10-27
host: x86_64-unknown-linux-gnu
release: 1.14.0-nightly
LLVM version: 3.9

Backtrace: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions