Skip to content

Commit e63443d

Browse files
committed
Rollup merge of rust-lang#21312 - michaelsproul:remove-error-send-bound, r=aturon
As discussed with @aturon, this PR removes the `Send` bound from `std::error::Error`, allowing us to implement `Error` for error types containing non-`Send` types. Current examples include `PoisonError` and `TryLockError` from `std::sync` which contain a Guard that we don't want sent between tasks. [breaking-change]
2 parents 409c997 + 97a2b26 commit e63443d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/libstd/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! chain information:
1919
//!
2020
//! ```
21-
//! trait Error: Send {
21+
//! trait Error {
2222
//! fn description(&self) -> &str;
2323
//!
2424
//! fn detail(&self) -> Option<String> { None }
@@ -87,7 +87,7 @@ use string::{FromUtf8Error, FromUtf16Error};
8787

8888
/// Base functionality for all errors in Rust.
8989
#[unstable = "the exact API of this trait may change"]
90-
pub trait Error: Send {
90+
pub trait Error {
9191
/// A short description of the error; usually a static string.
9292
fn description(&self) -> &str;
9393

src/libstd/io/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ use error::{FromError, Error};
234234
use fmt;
235235
use int;
236236
use iter::{Iterator, IteratorExt};
237-
use marker::Sized;
237+
use marker::{Sized, Send};
238238
use mem::transmute;
239239
use ops::FnOnce;
240240
use option::Option;
@@ -363,8 +363,8 @@ impl Error for IoError {
363363
}
364364
}
365365

366-
impl FromError<IoError> for Box<Error> {
367-
fn from_error(err: IoError) -> Box<Error> {
366+
impl FromError<IoError> for Box<Error + Send> {
367+
fn from_error(err: IoError) -> Box<Error + Send> {
368368
box err
369369
}
370370
}

src/libstd/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use error::{FromError, Error};
3737
use fmt;
3838
use io::{IoResult, IoError};
3939
use iter::{Iterator, IteratorExt};
40-
use marker::Copy;
40+
use marker::{Copy, Send};
4141
use libc::{c_void, c_int, c_char};
4242
use libc;
4343
use boxed::Box;
@@ -937,8 +937,8 @@ impl Error for MapError {
937937
fn detail(&self) -> Option<String> { Some(format!("{:?}", self)) }
938938
}
939939

940-
impl FromError<MapError> for Box<Error> {
941-
fn from_error(err: MapError) -> Box<Error> {
940+
impl FromError<MapError> for Box<Error + Send> {
941+
fn from_error(err: MapError) -> Box<Error + Send> {
942942
box err
943943
}
944944
}

0 commit comments

Comments
 (0)