-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Refactor to use debug_struct
in several Debug impls
#44775
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/sync/mpsc/mod.rs
Outdated
@@ -919,7 +919,7 @@ impl<T> Drop for Sender<T> { | |||
#[stable(feature = "mpsc_debug", since = "1.8.0")] | |||
impl<T> fmt::Debug for Sender<T> { | |||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |||
write!(f, "Sender {{ .. }}") | |||
f.pad("Sender {{ .. }}") |
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.
The {{
and }}
need to be changed to {
and }
as this string is no longer being used as a format string.
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.
Good catch, thanks for the review!
I removed the double braces.
b694349
to
3139584
Compare
I don't think this really fixes what #44771 was talking about - the output is still going to be on a single line if you format with |
I've tested on my machine that: println!("{:#?}", std::sync::Mutex::new(5)); prints (because of Mutex {
data: 5
} But you're right that for e.g. I think this is another related issue that we can fix later, because I just refactored this part to be more consistent with other |
ping @sfackler - do you think this can be merged as-is to fix part of the problem? |
The proper change seems like |
Using |
Yep, debug representations aren't stable. |
3139584
to
7b02a2d
Compare
I've rebased and applied the requested changes.
With these changes, fn main() {
let a = std::sync::Mutex::new(5);
let b = a.lock().unwrap();
println!("{:#?}", a);
} prints: Mutex {
data: <locked>
} |
Thanks! @bors r+ rollup |
📌 Commit 7b02a2d has been approved by |
@bors r- CI failed.
|
Sorry for the failed CI, this should be fixed now. |
Can we just get rid of those tests? It doesn't seem like they're doing anything useful. |
74b930b
to
679457a
Compare
Sure, I've removed these tests and squashed commits. |
@bors r+ rollup |
📌 Commit 679457a has been approved by |
Refactor to use `debug_struct` in several Debug impls Also use `pad` and derive `Debug` for `Edge`. Fixes rust-lang#44771.
Also use
pad
and deriveDebug
forEdge
.Fixes #44771.