-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: impl Value
for dyn Error + Send/Sync
#2066
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me.
In general, it's a lot easier if we make changes that apply to both the master
and v0.1.x
branches on the master
branch, and then backport them to v0.1.x
when the change applies to both v0.1.x and v0.2. It's a bit more work to have to backport and forward-port changes. Would you mind changing this PR to be based on master
, and I'll handle backporting it after it merges?
Ok. I wasn't sure how best to handle that. I'll rebase it onto |
c9cfe7e
to
0446b59
Compare
Oh good, GitHub appears to be rather confused by me force-pushing and then changing the base >_< I'll try again. |
`Value` was already implemented for `dyn Error + 'static`, but rust doesn't silently coerce trait objects. This means that passing an error of type `dyn Error + Send + Sync + 'static` would not work. These extra impls just delegate to the existing `dyn Error + 'static` impl. Also update one of the examples to use `dyn Error + Send + Sync` to demonstrate that this works. Refs: tokio-rs#1308
0446b59
to
f7776be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, looks great to me now! Thanks again!
## Motivation `Value` was already implemented for `dyn Error + 'static`, but rust doesn't silently coerce trait objects. This means that passing an error of type `dyn Error + Send + Sync + 'static` would not work. This is related to #1308. ## Solution Add impls for `dyn Error + …` variants for `Send`, `Sync`, and `Send + Sync`. These extra impls just delegate to the existing `dyn Error + 'static` impl. Also update one of the examples to use `dyn Error + Send + Sync` to demonstrate that this works. Refs: #1308
# 0.1.25 (April 12, 2022) This release adds additional `Value` implementations for `std::error::Error` trait objects with auto trait bounds (`Send` and `Sync`), as Rust will not auto-coerce trait objects. Additionally, it fixes a bug when setting scoped dispatchers that was introduced in the previous release ([v0.1.24]). ### Added - `Value` implementations for `dyn Error + Send + 'static`, `dyn Error + Send + Sync + 'static`, `dyn Error + Sync + 'static` ([#2066]) ### Fixed - Failure to use the global default dispatcher if a thread has set a scoped default prior to setting the global default, and unset the scoped default after setting the global default ([#2065]) Thanks to @lilyball for contributing to this release! [v0.1.24]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.24 [#2066]: #2066 [#2065]: #2065
# 0.1.25 (April 12, 2022) This release adds additional `Value` implementations for `std::error::Error` trait objects with auto trait bounds (`Send` and `Sync`), as Rust will not auto-coerce trait objects. Additionally, it fixes a bug when setting scoped dispatchers that was introduced in the previous release ([v0.1.24]). ### Added - `Value` implementations for `dyn Error + Send + 'static`, `dyn Error + Send + Sync + 'static`, `dyn Error + Sync + 'static` ([#2066]) ### Fixed - Failure to use the global default dispatcher if a thread has set a scoped default prior to setting the global default, and unset the scoped default after setting the global default ([#2065]) Thanks to @lilyball for contributing to this release! [v0.1.24]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.24 [#2066]: #2066 [#2065]: #2065
# 0.1.25 (April 12, 2022) This release adds additional `Value` implementations for `std::error::Error` trait objects with auto trait bounds (`Send` and `Sync`), as Rust will not auto-coerce trait objects. Additionally, it fixes a bug when setting scoped dispatchers that was introduced in the previous release ([v0.1.24]). ### Added - `Value` implementations for `dyn Error + Send + 'static`, `dyn Error + Send + Sync + 'static`, `dyn Error + Sync + 'static` ([tokio-rs#2066]) ### Fixed - Failure to use the global default dispatcher if a thread has set a scoped default prior to setting the global default, and unset the scoped default after setting the global default ([tokio-rs#2065]) Thanks to @lilyball for contributing to this release! [v0.1.24]: https://github.com/tokio-rs/tracing/releases/tag/tracing-core-0.1.24 [tokio-rs#2066]: tokio-rs#2066 [tokio-rs#2065]: tokio-rs#2065
This commit adds a `Value` implementation for `Box<T> where T: Value`. This is *primarily* intended to make `Box<dyn Error + ...>` implement `Value`, building on the `Value` impls for `dyn Error + ...` added in tokio-rs#2066, but it may be useful for other boxed values as well. Refs: tokio-rs#1308
Motivation
Value
was already implemented fordyn Error + 'static
, but rust doesn't silently coerce trait objects. This means that passing an error of typedyn Error + Send + Sync + 'static
would not work. This is related to #1308.Solution
Add impls for
dyn Error + …
variants forSend
,Sync
, andSend + Sync
. These extra impls just delegate to the existingdyn Error + 'static
impl.Also update one of the examples to use
dyn Error + Send + Sync
to demonstrate that this works.