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

rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl. #66907

Merged
merged 1 commit into from
Dec 2, 2019

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Nov 30, 2019

Context: these fmt::Debug impls only get used with -Z verbose (which some tests use).

I was going to print the path like in #66850 (or rather, use DefId's fmt::Debug, which is close but not as nice), but then I realized that most of the DefIds were crate0:DefIndex(0), i.e. the crate root.
As the crate root is not a lifetime, they're clearly dummies of some sort, and we don't have to print anything other than the name for them.

This means that out of all the tests, there's only 5 instances of BrNamed that now print the full path to the lifetime parameter, and everything else is shorter instead, which doesn't feel too bad.

cc @nikomatsakis

@rust-highfive
Copy link
Collaborator

r? @cramertj

(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 Nov 30, 2019
src/librustc/ty/structural_impls.rs Show resolved Hide resolved
if did.index == CRATE_DEF_INDEX {
write!(f, "BrNamed({})", name)
} else {
write!(f, "BrNamed({:?}, {})", did, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this is easily done, but can you eliminate the Defid(foobar) wrapping? Just the content seems fine since this is already wrapped in a BrNamed

Copy link
Member Author

Choose a reason for hiding this comment

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

It's rare enough that I don't want to touch that right now.
Ideally this would print a proper path, and it still probably could using ty::tls::with or w/e, but also DefId printout could be better in general.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 30, 2019

r? @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Nov 30, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Nov 30, 2019

📌 Commit 9034efe has been approved by oli-obk

@bors
Copy link
Contributor

bors commented Nov 30, 2019

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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 Nov 30, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 1, 2019
rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.

Context: these `fmt::Debug` impls only get used with `-Z verbose` (which some tests use).

I was going to print the path like in rust-lang#66850 (or rather, use `DefId`'s `fmt::Debug`, which is close but not as nice), but then I realized that most of the `DefId`s were `crate0:DefIndex(0)`, i.e. the crate root.
As the crate root is not a lifetime, they're clearly dummies of some sort, and we don't have to print anything other than the name for them.

This means that out of all the tests, there's only 5 instances of `BrNamed` that now print the full path to the lifetime parameter, and everything else is shorter instead, which doesn't feel too bad.

cc @nikomatsakis
bors added a commit that referenced this pull request Dec 1, 2019
Rollup of 7 pull requests

Successful merges:

 - #66346 (Replace .unwrap() with ? in std::os::unix::net)
 - #66789 (rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.)
 - #66822 (libunwind_panic: adjust miri panic hack)
 - #66827 (handle diverging functions forwarding their return place)
 - #66828 (Less minification)
 - #66850 (rustc: hide HirId's fmt::Debug output from -Z span_free_formats.)
 - #66907 (rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.)

Failed merges:

 - #66874 (Miri engine: proper support for `Assert` MIR terminators)

r? @ghost
bors added a commit that referenced this pull request Dec 1, 2019
Rollup of 7 pull requests

Successful merges:

 - #66346 (Replace .unwrap() with ? in std::os::unix::net)
 - #66789 (rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.)
 - #66822 (libunwind_panic: adjust miri panic hack)
 - #66827 (handle diverging functions forwarding their return place)
 - #66828 (Less minification)
 - #66850 (rustc: hide HirId's fmt::Debug output from -Z span_free_formats.)
 - #66907 (rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.)

Failed merges:

 - #66874 (Miri engine: proper support for `Assert` MIR terminators)

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Dec 2, 2019
rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.

Context: these `fmt::Debug` impls only get used with `-Z verbose` (which some tests use).

I was going to print the path like in rust-lang#66850 (or rather, use `DefId`'s `fmt::Debug`, which is close but not as nice), but then I realized that most of the `DefId`s were `crate0:DefIndex(0)`, i.e. the crate root.
As the crate root is not a lifetime, they're clearly dummies of some sort, and we don't have to print anything other than the name for them.

This means that out of all the tests, there's only 5 instances of `BrNamed` that now print the full path to the lifetime parameter, and everything else is shorter instead, which doesn't feel too bad.

cc @nikomatsakis
bors added a commit that referenced this pull request Dec 2, 2019
Rollup of 7 pull requests

Successful merges:

 - #66346 (Replace .unwrap() with ? in std::os::unix::net)
 - #66789 (rustc: move mir::SourceScopeLocalData to a field of SourceScopeData.)
 - #66850 (rustc: hide HirId's fmt::Debug output from -Z span_free_formats.)
 - #66905 (rustc_plugin: Remove some remaining plugin features)
 - #66907 (rustc: don't just show raw DefIndex's in BrNamed's fmt::Debug impl.)
 - #66918 (Add crc and crypto to target feature whitelist on arm)
 - #66926 (add reusable MachineStop variant to Miri engine error enum)

Failed merges:

r? @ghost
@bors bors merged commit 9034efe into rust-lang:master Dec 2, 2019
@bors
Copy link
Contributor

bors commented Dec 2, 2019

☔ The latest upstream changes (presumably #66944) 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 Dec 2, 2019
RalfJung added a commit to RalfJung/rust that referenced this pull request Dec 2, 2019
…wjasper

rustc_mir: use nicer path printing for #[rustc_regions] NLL tests.

Similar to rust-lang#66850, spotted while working on rust-lang#66907.

r? @matthewjasper
@eddyb eddyb deleted the br-nicer-named branch December 2, 2019 10:29
bors added a commit that referenced this pull request Dec 6, 2019
rustc_mir: use nicer path printing for #[rustc_regions] NLL tests.

Similar to #66850, spotted while working on #66907.

r? @matthewjasper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants