Add a Sync bounds to errors#110
Conversation
`Box<Error + Sync + Send>` is far more common than `Box<Error + Send>` - common conveniences like conversion from strings are not implemented for `Box<Error + Send>`, `Box<Error + Send>` cannot be stored in `io::Error`s, etc. This is a breaking change, but non-`Sync` errors should be rare so the fallout shouldn't be too bad.
|
Do you have an example of code that requires this change? |
|
Returning an error_chain generated error as a |
|
Most errors are Sync I think, since they are read-only? |
|
Yep! |
|
Please update the changelog. |
|
Done |
What do you mean? |
|
This works: |
|
Hum, strange, do you know why? |
|
We never bothered implementing it since |
|
Ok, let see if it breaks something important in another crate ;) |
|
JFTR, my main D-Bus error struct won't implement Sync, because it is a wrapper around an FFI struct, and as such I cannot provide any guarantees that the "C" side of the struct is (or will remain) Sync. |
|
That's what I feared... |
|
What is the suggested workaround for errors that cannot be made Sync? Can I just not use error-chain anymore? |
|
I'll just remove it in 0.9. |
|
Things break without the bound just as they do with it. Can we make the error bounds configurable in the |
|
Yes, see #121. |
|
I ran into this because |
|
See #134 |
|
Reverting this means that |
Currently, they are not Sync because they contain a non-Sync trait object. This is a breaking change. The decision to make errors Send but not Sync was made in rust-lang-deprecated#110. We believe that decision was a mistake, because it perpetuates a !Sync restriction on all users even if their errors are, in fact, Sync. Instead, users who need errors that are !Sync should use synchronization when transforming their errors into error-chain errors.
Currently, they are not Sync because they contain a non-Sync trait object. This is a breaking change. The decision to make errors Send but not Sync was made in rust-lang-deprecated#110. We believe that decision was a mistake, because it perpetuates a !Sync restriction on all users even if their errors are, in fact, Sync. Instead, users who need errors that are !Sync should use synchronization when transforming their errors into error-chain errors.
Box<Error + Sync + Send>is far more common thanBox<Error + Send>- common conveniences like conversion from strings are notimplemented for
Box<Error + Send>,Box<Error + Send>cannot bestored in
io::Errors, etc.This is a breaking change, but non-
Syncerrors should be rare so thefallout shouldn't be too bad.
r? @brson I've confirmed that rustup builds without modification with this change.