diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:09:08 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:09:08 -0700 |
| commit | b97e1cc28e0d3fe6a745a02a7c1750564a090f34 (patch) | |
| tree | 52476c90e92bbe4d82c75371ef8ded0733b472a5 /src/libstd/sync | |
| parent | fd13400627108fbf3998545f782ed44422e344bf (diff) | |
| parent | 9231ceb6dd273d8101e1b3906e6060f802e6423d (diff) | |
| download | rust-b97e1cc28e0d3fe6a745a02a7c1750564a090f34.tar.gz rust-b97e1cc28e0d3fe6a745a02a7c1750564a090f34.zip | |
rollup merge of #23541: aturon/stab-error
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change] r? @alexcrichton Closes #21790
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mpsc/mod.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sync/poison.rs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index 123dad978f5..35125125d14 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -977,7 +977,7 @@ impl<T> fmt::Display for SendError<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T> error::Error for SendError<T> { +impl<T: Send> error::Error for SendError<T> { fn description(&self) -> &str { "sending on a closed channel" @@ -1013,7 +1013,7 @@ impl<T> fmt::Display for TrySendError<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T> error::Error for TrySendError<T> { +impl<T: Send> error::Error for TrySendError<T> { fn description(&self) -> &str { match *self { diff --git a/src/libstd/sync/poison.rs b/src/libstd/sync/poison.rs index 2587ff5238e..c07c83d37f4 100644 --- a/src/libstd/sync/poison.rs +++ b/src/libstd/sync/poison.rs @@ -105,11 +105,11 @@ impl<T> fmt::Debug for PoisonError<T> { #[stable(feature = "rust1", since = "1.0.0")] impl<T> fmt::Display for PoisonError<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.description().fmt(f) + "poisoned lock: another task failed inside".fmt(f) } } -impl<T> Error for PoisonError<T> { +impl<T: Send> Error for PoisonError<T> { fn description(&self) -> &str { "poisoned lock: another task failed inside" } @@ -161,13 +161,13 @@ impl<T> fmt::Debug for TryLockError<T> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T> fmt::Display for TryLockError<T> { +impl<T: Send> fmt::Display for TryLockError<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.description().fmt(f) } } -impl<T> Error for TryLockError<T> { +impl<T: Send> Error for TryLockError<T> { fn description(&self) -> &str { match *self { TryLockError::Poisoned(ref p) => p.description(), |
