Skip to content
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

Override Debug for oneshot::{Sender,Receiver}. #2414

Merged
merged 1 commit into from
May 7, 2021

Conversation

goffrie
Copy link
Contributor

@goffrie goffrie commented May 6, 2021

Prior to this diff, the Debug impl for oneshot channels printed something like:

Sender { inner: Inner { complete: false, data: Lock { locked: false, data: UnsafeCell }, rx_task: Lock { locked: false, data: UnsafeCell }, tx_task: Lock { locked: false, data: UnsafeCell } } }

which isn't very helpful. Instead, just print
Sender { complete: false } (or true, if the other end has dropped).

Note that the T: Debug bound is retained to allow for the possibility
of allowing slightly more interesting debug output in the future.

Prior to this diff, the Debug impl for oneshot channels printed something like:
```
Sender { inner: Inner { complete: false, data: Lock { locked: false, data: UnsafeCell }, rx_task: Lock { locked: false, data: UnsafeCell }, tx_task: Lock { locked: false, data: UnsafeCell } } }
```
which isn't very helpful. Instead, just print
`Sender { complete: false }` (or `true`, if the other end has dropped).

Note that the `T: Debug` bound is retained to allow for the possibility
of allowing slightly more interesting debug output in the future.
@goffrie goffrie requested a review from taiki-e as a code owner May 6, 2021 23:35
@ibraheemdev
Copy link
Member

ibraheemdev commented May 7, 2021

Some users may want the detailed debug information. It could be particularly helpful for debugging deadlocks.

@goffrie
Copy link
Contributor Author

goffrie commented May 7, 2021

A user can't actually lock the internal locks themselves, so if there were a deadlock it would be a bug internal to futures-rs.

Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@taiki-e taiki-e merged commit 4124d8b into rust-lang:master May 7, 2021
@taiki-e taiki-e added A-channel Area: futures::channel 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. labels May 7, 2021
@taiki-e taiki-e mentioned this pull request May 7, 2021
@taiki-e taiki-e added 0.3-backport: completed and removed 0.3-backport: pending The maintainer accepted to backport this to the 0.3 branch, but backport has not been done yet. labels May 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants