Skip to content

dbg! put spaces around :: #81209

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

Closed
pickfire opened this issue Jan 20, 2021 · 6 comments
Closed

dbg! put spaces around :: #81209

pickfire opened this issue Jan 20, 2021 · 6 comments
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pickfire
Copy link
Contributor

pickfire commented Jan 20, 2021

While trying out Ipv4Addr for #81202

I tried this code:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=d4e00191c64a2608f3306178bff743c8

use std::net::Ipv4Addr;

fn main() {
    dbg!(format!("{:#?}", Ipv4Addr::new(127, 0, 0, 1)));
}

I expected to see this happen:

[src/main.rs:4] format!("{:#?}", Ipv4Addr::new(127, 0, 0, 1)) = "127.0.0.1"

Instead, this happened:

[src/main.rs:4] format!("{:#?}", Ipv4Addr :: new(127, 0, 0, 1)) = "127.0.0.1"

Meta

rustc --version --verbose: Same happens for nightly

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0
@pickfire pickfire added the C-bug Category: This is a bug. label Jan 20, 2021
@jonas-schievink
Copy link
Contributor

This is just what stringify! does, I believe

@clarfonthey
Copy link
Contributor

The result is based upon tokens, not the actual code. It will be normalised like this no matter what.

@pickfire
Copy link
Contributor Author

pickfire commented Jan 29, 2021

But why shouldn't it be normalized without spaces around :: like (?

@clarfonthey
Copy link
Contributor

I didn't realise that, and it's a good point.

It could potentially be worthwhile to make stringify! format the code in a reasonably nice way if it's valid Rust syntax, but that could induce a lot of overhead. Really depends on what people think is best and makes the most sense.

@fmease fmease added A-pretty Area: Pretty printing (including `-Z unpretty`) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. needs-triage-legacy labels Sep 6, 2023
@GrigorenkoPV
Copy link
Contributor

Pretty sure it got fixed in 1.76

https://godbolt.org/z/3bnrvE5M7

@clarfonthey
Copy link
Contributor

Seems like this should be closed, then.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants