summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2015-04-06 16:30:18 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-04-23 15:18:14 -0700
commit8b5482e5ab2b180a1943c4d0cf130cd2e3d74731 (patch)
treef0e5e8ad4e7610596e95bf5c8b72c09e0ca70ec0 /src/libstd
parentfc74ba2bb0f99c43ae5aee115602dff25fc2494d (diff)
downloadrust-8b5482e5ab2b180a1943c4d0cf130cd2e3d74731.tar.gz
rust-8b5482e5ab2b180a1943c4d0cf130cd2e3d74731.zip
Add `Sync` to the bounds in `io::Error`
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.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/error.rs14
-rw-r--r--src/libstd/io/error.rs11
2 files changed, 15 insertions, 10 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs
index 96087bf1183..9f09f464cfc 100644
--- a/src/libstd/error.rs
+++ b/src/libstd/error.rs
@@ -50,7 +50,7 @@
 use boxed::Box;
 use convert::From;
 use fmt::{self, Debug, Display};
-use marker::Send;
+use marker::{Send, Sync};
 use num;
 use option::Option;
 use option::Option::None;
@@ -81,15 +81,15 @@ impl<'a, E: Error + 'a> From<E> for Box<Error + 'a> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, E: Error + Send + 'a> From<E> for Box<Error + Send + 'a> {
-    fn from(err: E) -> Box<Error + Send + 'a> {
+impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<Error + Send + Sync + 'a> {
+    fn from(err: E) -> Box<Error + Send + Sync + 'a> {
         Box::new(err)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl From<String> for Box<Error + Send> {
-    fn from(err: String) -> Box<Error + Send> {
+impl From<String> for Box<Error + Send + Sync> {
+    fn from(err: String) -> Box<Error + Send + Sync> {
         #[derive(Debug)]
         struct StringError(String);
 
@@ -108,8 +108,8 @@ impl From<String> for Box<Error + Send> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, 'b> From<&'b str> for Box<Error + Send + 'a> {
-    fn from(err: &'b str) -> Box<Error + Send + 'a> {
+impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a> {
+    fn from(err: &'b str) -> Box<Error + Send + Sync + 'a> {
         From::from(String::from_str(err))
     }
 }
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs
index 4e36b2438b4..97c5a29d308 100644
--- a/src/libstd/io/error.rs
+++ b/src/libstd/io/error.rs
@@ -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 {
@@ -216,3 +216,8 @@ impl error::Error for Error {
         }
     }
 }
+
+fn _assert_error_is_sync_send() {
+    fn _is_sync_send<T: Sync+Send>() {}
+    _is_sync_send::<Error>();
+}