Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
twittner opened this issue Nov 1, 2016 · 0 comments
Closed

Comments

@twittner
Copy link

twittner commented Nov 1, 2016

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

eddyb added a commit to eddyb/rust that referenced this issue Nov 11, 2016
…or-error-impl, r=alexcrichton

Add Error implementation for std::sync::mpsc::RecvTimeoutError.

Fixes rust-lang#37525.
eddyb added a commit to eddyb/rust that referenced this issue Nov 12, 2016
…or-error-impl, r=alexcrichton

Add Error implementation for std::sync::mpsc::RecvTimeoutError.

Fixes rust-lang#37525.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant