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

MutexGuard's Debug implementation is unuseful #57702

Closed
m-ou-se opened this issue Jan 17, 2019 · 0 comments
Closed

MutexGuard's Debug implementation is unuseful #57702

m-ou-se opened this issue Jan 17, 2019 · 0 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Jan 17, 2019

MutexGuard's Debug implementation just forwards to the Mutex's Debug implementation, which will simply print <locked>, because the Mutex was locked (by that very same MutexGuard).

Effectively, this means that the current Debug implementation of MutexGuard is equivalent to:

f.write_str("MutexGuard { lock: Mutex { data: <locked> } }")

Instead, it should not try to lock the mutex, but use its own Deref implementation to print the contents of the mutex.

@Centril Centril added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jan 17, 2019
Centril added a commit to Centril/rust that referenced this issue Jan 26, 2019
Make MutexGuard's Debug implementation more useful.

Fixes rust-lang#57702.
Centril added a commit to Centril/rust that referenced this issue Jan 26, 2019
Make MutexGuard's Debug implementation more useful.

Fixes rust-lang#57702.
Centril added a commit to Centril/rust that referenced this issue Jan 26, 2019
Make MutexGuard's Debug implementation more useful.

Fixes rust-lang#57702.
JohnTitor added a commit to JohnTitor/rust that referenced this issue Mar 27, 2021
…ackh726

Fix Debug implementation for RwLock{Read,Write}Guard.

This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print `"<locked>"` unhelpfully.

After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do.

MutexGuard had this problem too: rust-lang#57702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants