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

Change Debug impl of SocketAddr and IpAddr to match their Display output #74409

Merged

Conversation

LukasKalbertodt
Copy link
Member

This has already been done for SocketAddrV4, SocketAddrV6, IpAddrV4 and IpAddrV6. I don't see a point to keep the rather bad to read derived impl, especially so when pretty printing:

V4(
    127.0.0.1
)

From the Display, one can easily and unambiguously see if it's V4 or V6. Two examples:

127.0.0.1:443
[2001:db8:85a3::8a2e:370:7334]:443

Luckily the docs explicitly state that Debug output is not stable and that it may be changed at any time.

Using Display as Debug is very convenient for configuration structs (e.g. for webservers) that often just have a derive(Debug) and are printed that way to the one starting the server.

@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 16, 2020
@joshtriplett
Copy link
Member

I certainly agree that there isn't much value in the extra newlines when pretty-printing.

As for changing the Debug impl to match the Display, I know it can change at any time, but we might still want to do a quick crater run just to make sure it doesn't break anyone.

@LukasKalbertodt
Copy link
Member Author

A crater run sounds fine to me!

@joshtriplett
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Jul 17, 2020

⌛ Trying commit 805b171bcab72bdfd11f18d82b3c029e0d40d73d with merge 0abbfa7f48aec40f12e368b7ff814b60d1e4d145...

@bors
Copy link
Contributor

bors commented Jul 17, 2020

💥 Test timed out

@joshtriplett
Copy link
Member

@bors retry

@bors
Copy link
Contributor

bors commented Jul 17, 2020

⌛ Trying commit 805b171bcab72bdfd11f18d82b3c029e0d40d73d with merge 03a1ea71b075ab964b5278bc6e74cd6c52c36ee0...

@bors
Copy link
Contributor

bors commented Jul 17, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 03a1ea71b075ab964b5278bc6e74cd6c52c36ee0 (03a1ea71b075ab964b5278bc6e74cd6c52c36ee0)

@joshtriplett
Copy link
Member

@craterbot run

@craterbot
Copy link
Collaborator

👌 Experiment pr-74409 created and queued.
🤖 Automatically detected try build 03a1ea71b075ab964b5278bc6e74cd6c52c36ee0
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 17, 2020
@LukasKalbertodt
Copy link
Member Author

Given that that crater queue is pretty long right now (with probably more important PRs), I thought about this again. While I still don't mind a crater run, I don't really think it is necessary here. For one, we explicitly documented that the output is not stable, so even if some crates fail I would tend to say "that's their fault". And also, I really can't imagine people using the debug output in any way that would be caught by running the tests. I can imagine people using the Display impl in such a ways, as its output is useful; but the Debug impl... I don't know.

So yeah, maybe we should remove this PR from the crater queue again?

@joshtriplett
Copy link
Member

@LukasKalbertodt I can easily imagine a crate that compares the overall output of a test, where that test output includes various values such as an IpAddr or SocketAddr. I'm not necessarily suggesting we would avoid making this change in that case, but I'd like to know the overall impact of a change like this, and where problems tend to arise. We might, for instance, make sure that key crates get fixed before this makes it to a stable release.

@Mark-Simulacrum
Copy link
Member

FWIW historically we've not done much about cases where people are comparing or otherwise making use of Debug output in cases like this, though we can of course be more stringent in this case. We could try and catch this in 1.47 beta crater as well (so in ~6 weeks, roughly, once this hits beta).

I'd personally be fine with trying to catch this in beta crater or even just letting it roll out, Debug impls are IMO sort of outside stability guarantees, and doubly so when we have a Display impl on the same type.

@craterbot
Copy link
Collaborator

🚧 Experiment pr-74409 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-74409 is completed!
📊 54 regressed and 47 fixed (113492 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jul 27, 2020
@LukasKalbertodt
Copy link
Member Author

I checked all regressions and it looks like 3 are caused by this PR:

  • archion.eHosts.a2b12a40857bce3f33923ec39c6bfe77280b39aa
  • cassandra-proto-0.1.2
  • cdrs-2.3.3

Those indeed compare the Debug output of two values which contain IpAddr/SocketAddr. All other regressions are spurious or caused by something else.

I think this kind of breakage is absolutely acceptable, especially since the instability of the Debug output is explicitly stated in the docs.

@joshtriplett
Copy link
Member

@LukasKalbertodt I think this is acceptable as well. No huge swathes of dependencies (two of them are from the same project), and no surprises. I think it'd be reasonable to proceed with this.

@Amanieu
Copy link
Member

Amanieu commented Jul 28, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jul 28, 2020

📌 Commit 805b171bcab72bdfd11f18d82b3c029e0d40d73d has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 28, 2020
@bors
Copy link
Contributor

bors commented Jul 28, 2020

☔ The latest upstream changes (presumably #73265) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 28, 2020
This has already been done for `SocketAddrV4`, `SocketAddrV6`,
`IpAddrV4` and `IpAddrV6`. I don't see a point to keep the rather bad
to read derived impl, especially when pretty printing:

    V4(
        127.0.0.1
    )

From the `Display`, one can easily and unambiguously see if it's V4 or
V6. Using `Display` as `Debug` is very convenient for configuration
structs (e.g. for webservers) that often just have a `derive(Debug)`
and are printed that way to the user.
@LukasKalbertodt LukasKalbertodt force-pushed the improve-debug-impl-of-socketaddr-ipaddr branch from 805b171 to 6293dca Compare July 28, 2020 15:49
@LukasKalbertodt
Copy link
Member Author

rebased

@Muirrum Muirrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2020
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 14, 2020
@Dylan-DPC-zz
Copy link

@bors r=Amanieu

@bors
Copy link
Contributor

bors commented Aug 14, 2020

📌 Commit 6293dca has been approved by Amanieu

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2020
Rollup of 17 pull requests

Successful merges:

 - rust-lang#73943 (Document the unsafe keyword)
 - rust-lang#74062 (deny(unsafe_op_in_unsafe_fn) in libstd/ffi/c_str.rs)
 - rust-lang#74185 (Remove liballoc unneeded explicit link)
 - rust-lang#74192 (Improve documentation on process::Child.std* fields)
 - rust-lang#74409 (Change Debug impl of SocketAddr and IpAddr to match their Display output)
 - rust-lang#75195 (BTreeMap: purge innocent use of into_kv_mut)
 - rust-lang#75214 (Use intra-doc links in `mem::manually_drop` & `mem::maybe_uninit`)
 - rust-lang#75432 (Switch to intra-doc links in `std::process`)
 - rust-lang#75482 (Clean up E0752 explanation)
 - rust-lang#75501 (Move to intra doc links in std::ffi)
 - rust-lang#75509 (Tweak suggestion for `this` -> `self`)
 - rust-lang#75511 (Do not emit E0228 when it is implied by E0106)
 - rust-lang#75515 (Bump std's libc version to 0.2.74)
 - rust-lang#75517 (Promotion and const interning comments)
 - rust-lang#75519 (BTreeMap: refactor splitpoint and move testing over to unit test)
 - rust-lang#75530 (Switch to intra-doc links in os/raw/*.md)
 - rust-lang#75531 (Migrate unit tests of btree collections to their native breeding ground)

Failed merges:

r? @ghost
@bors bors merged commit 5b61230 into rust-lang:master Aug 15, 2020
@LukasKalbertodt LukasKalbertodt deleted the improve-debug-impl-of-socketaddr-ipaddr branch January 19, 2021 09:08
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants