Auto merge of #24133 - kballard:add-sync-to-io-error, r=alexcrichton
This allows `io::Error` values to be stored in `Arc` properly. Because this requires `Sync` of any value passed to `io::Error::new()` and modifies the relevant `convert::From` impls, this is a [breaking-change] Fixes #24049.
This commit is contained in:
@@ -12,7 +12,7 @@ use boxed::Box;
|
||||
use convert::Into;
|
||||
use error;
|
||||
use fmt;
|
||||
use marker::Send;
|
||||
use marker::{Send, Sync};
|
||||
use option::Option::{self, Some, None};
|
||||
use result;
|
||||
use sys;
|
||||
@@ -46,7 +46,7 @@ enum Repr {
|
||||
#[derive(Debug)]
|
||||
struct Custom {
|
||||
kind: ErrorKind,
|
||||
error: Box<error::Error+Send>,
|
||||
error: Box<error::Error+Send+Sync>,
|
||||
}
|
||||
|
||||
/// A list specifying general categories of I/O error.
|
||||
@@ -146,7 +146,7 @@ impl Error {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new<E>(kind: ErrorKind, error: E) -> Error
|
||||
where E: Into<Box<error::Error+Send>>
|
||||
where E: Into<Box<error::Error+Send+Sync>>
|
||||
{
|
||||
Error {
|
||||
repr: Repr::Custom(Box::new(Custom {
|
||||
@@ -223,3 +223,8 @@ impl error::Error for Error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn _assert_error_is_sync_send() {
|
||||
fn _is_sync_send<T: Sync+Send>() {}
|
||||
_is_sync_send::<Error>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user