Skip to content

Commit d034bc3

Browse files
committed
Rollup merge of rust-lang#23125 - danburkert:master, r=brson
2 parents cc45572 + e8ed2d4 commit d034bc3

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

src/libstd/sync/mpsc/mod.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
use prelude::v1::*;
319319

320320
use sync::Arc;
321+
use error;
321322
use fmt;
322323
use mem;
323324
use cell::UnsafeCell;
@@ -975,6 +976,18 @@ impl<T> fmt::Display for SendError<T> {
975976
}
976977
}
977978

979+
#[stable(feature = "rust1", since = "1.0.0")]
980+
impl<T> error::Error for SendError<T> {
981+
982+
fn description(&self) -> &str {
983+
"sending on a closed channel"
984+
}
985+
986+
fn cause(&self) -> Option<&error::Error> {
987+
None
988+
}
989+
}
990+
978991
#[stable(feature = "rust1", since = "1.0.0")]
979992
impl<T> fmt::Debug for TrySendError<T> {
980993
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -999,13 +1012,44 @@ impl<T> fmt::Display for TrySendError<T> {
9991012
}
10001013
}
10011014

1015+
#[stable(feature = "rust1", since = "1.0.0")]
1016+
impl<T> error::Error for TrySendError<T> {
1017+
1018+
fn description(&self) -> &str {
1019+
match *self {
1020+
TrySendError::Full(..) => {
1021+
"sending on a full channel"
1022+
}
1023+
TrySendError::Disconnected(..) => {
1024+
"sending on a closed channel"
1025+
}
1026+
}
1027+
}
1028+
1029+
fn cause(&self) -> Option<&error::Error> {
1030+
None
1031+
}
1032+
}
1033+
10021034
#[stable(feature = "rust1", since = "1.0.0")]
10031035
impl fmt::Display for RecvError {
10041036
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
10051037
"receiving on a closed channel".fmt(f)
10061038
}
10071039
}
10081040

1041+
#[stable(feature = "rust1", since = "1.0.0")]
1042+
impl error::Error for RecvError {
1043+
1044+
fn description(&self) -> &str {
1045+
"receiving on a closed channel"
1046+
}
1047+
1048+
fn cause(&self) -> Option<&error::Error> {
1049+
None
1050+
}
1051+
}
1052+
10091053
#[stable(feature = "rust1", since = "1.0.0")]
10101054
impl fmt::Display for TryRecvError {
10111055
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -1020,6 +1064,25 @@ impl fmt::Display for TryRecvError {
10201064
}
10211065
}
10221066

1067+
#[stable(feature = "rust1", since = "1.0.0")]
1068+
impl error::Error for TryRecvError {
1069+
1070+
fn description(&self) -> &str {
1071+
match *self {
1072+
TryRecvError::Empty => {
1073+
"receiving on an empty channel"
1074+
}
1075+
TryRecvError::Disconnected => {
1076+
"receiving on a closed channel"
1077+
}
1078+
}
1079+
}
1080+
1081+
fn cause(&self) -> Option<&error::Error> {
1082+
None
1083+
}
1084+
}
1085+
10231086
#[cfg(test)]
10241087
mod test {
10251088
use prelude::v1::*;

0 commit comments

Comments
 (0)