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

MIR dump: print pointers consistently with Miri output #71590

Merged
merged 5 commits into from
May 1, 2020

Conversation

RalfJung
Copy link
Member

This makes MIR allocation dump pointer printing consistent with Miri output: both use hexadecimal offsets with a 0x prefix. To save some space, MIR dump replaces the alloc prefix by a when necessary.

I also made AllocId/Pointer printing more consistent in their Debug/Display handling, and adjusted Display printing for Scalar a bit to avoid using decimal printing when we do not know the sign with which to interpret the value (IMO using decimal then is misleading).

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(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 Apr 26, 2020
@petrochenkov
Copy link
Contributor

r? @eddyb

@rust-highfive rust-highfive assigned eddyb and unassigned petrochenkov Apr 26, 2020
@RalfJung
Copy link
Member Author

Cc @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Apr 27, 2020

r? @oli-obk

@bors r+

@bors
Copy link
Contributor

bors commented Apr 27, 2020

📌 Commit b12faeb has been approved by oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned eddyb Apr 27, 2020
@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 Apr 27, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 30, 2020
Rollup of 8 pull requests

Successful merges:

 - rust-lang#71148 (Vec drop and truncate: drop using raw slice *mut [T])
 - rust-lang#71465 (Add a convenience method on `TyCtxt` for checking for thread locals)
 - rust-lang#71567 (Handle build completion message from Cargo)
 - rust-lang#71590 (MIR dump: print pointers consistently with Miri output)
 - rust-lang#71682 (Bump pulldown-cmark)
 - rust-lang#71688 (Allow `Downcast` projections unconditionally in const-checking)
 - rust-lang#71691 (Allow `Unreachable` terminators unconditionally in const-checking)
 - rust-lang#71719 (Update backtrace-sys)

Failed merges:

r? @ghost
@bors bors merged commit 3c75f70 into rust-lang:master May 1, 2020
Comment on lines +37 to +39
0x00 │ 00 00 00 00 __ __ __ __ ╾─a4+0x0──╼ 00 00 00 00 │ ....░░░░╾──╼....
0x10 │ 00 00 00 00 __ __ __ __ ╾─a8+0x0──╼ 02 00 00 00 │ ....░░░░╾──╼....
0x20 │ 01 00 00 00 2a 00 00 00 ╾─a13+0x0─╼ 03 00 00 00 │ ....*...╾──╼....
Copy link
Member

Choose a reason for hiding this comment

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

Hmpf, for the common case (offset is 0, or otherwise small), this seems unnecessarily noisy compared to decimal (due to the prefix).

I know @RalfJung doesn't like it, but my preferred approach of printing arbitrary integers involves using a decimal digit when unambiguous (i.e. <= 9), and +0 feels unnecessary so I would skip it too.

But maybe this won't matter long-term, if we improve our ty::Const printing to move beyond the need for these (otherwise really cool!) allocation dumps. (We would need to detect if the allocations are entirely reproducible from the pretty value, and don't have e.g. initialized padding, to avoid losing information)

Copy link
Member Author

@RalfJung RalfJung May 1, 2020

Choose a reason for hiding this comment

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

I'm okay introducing a special case for 0, to not print the offset at all.

But alloc13+4 and elsewhere alloc13+0x10 seems oddly inconsistent to me.

@RalfJung RalfJung deleted the mir-dump-pointers branch May 1, 2020 08:49
bors added a commit to rust-lang-ci/rust that referenced this pull request May 1, 2020
Miri: tweak error print

I started by adjusting the "invalid use of int as pointer" message (it wasn't really clear what is invalid about the use). But then I realized that these are all `Debug` impls we use for these errors, for some reason, so I fixed that to use `Display` instead.

~~This includes rust-lang#71590 (to get the `Display` impl for `Pointer`), so the diff will look better once that finally lands. Here's the [relative diff](RalfJung/rust@e72ebf5...RalfJung:miri-error-print).~~

r? @oli-obk
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.

6 participants