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

Some simple improvements to MIR pretty printing #33607

Merged
merged 3 commits into from
May 15, 2016
Merged

Some simple improvements to MIR pretty printing #33607

merged 3 commits into from
May 15, 2016

Conversation

jonas-schievink
Copy link
Contributor

In short, this PR changes the MIR printer so that it:

  • places an empty line between the MIR for each item
  • does not write an empty line before the first BB when there are no
    var decls
  • aligns the "// Scope" comments 50 chars in (makes the output more
    readable)
  • prints the scope comments as "// scope N at ..." instead of "//
    Scope(N) at ..."
  • prints a prettier scope tree:
    • no more unbalanced delimiters!
    • no more "Parent" entry (these convey no useful information)
    • drop the "Scope()" and just print scope IDs
    • no braces when the scope is empty

In action: https://gist.github.com/jonas-schievink/1c11226cbb112892a9470ce0f9870b65

In short, this PR changes the MIR printer so that it:

* places an empty line between the MIR for each item
* does *not* write an empty line before the first BB when there are no
  var decls
* aligns the "// Scope" comments 50 chars in (makes the output more
  readable)
* prints the scope comments as "// scope N at ..." instead of "//
  Scope(N) at ..."
* prints a prettier scope tree:
 * no more unbalanced delimiters!
 * no more "Parent" entry (these convey no useful information)
 * drop the "Scope()" and just print scope IDs
 * no braces when the scope is empty
@rust-highfive
Copy link
Collaborator

r? @nrc

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

@jonas-schievink
Copy link
Contributor Author

I'll make the scope tree printing much smaller tomorrow, so hang on until then :)

@nikomatsakis
Copy link
Contributor

🐊 this looks great, thanks for doing this.

@nagisa
Copy link
Member

nagisa commented May 12, 2016

I feel like scope tree would look better like this:

1
├ 2
│ ├ 3
...

40 chars is still enough indentation (most common MIR statements don't
take more than 40 chars), and fits more easily in 80-character
terminals.
@jonas-schievink
Copy link
Contributor Author

Updated.

Also put a test_new.mir in the gist. The new scope tree printing is much smaller: When a scope only contains a single child, it is put on the same line. Since this is a very common case, output is heavily reduced.

@eddyb
Copy link
Member

eddyb commented May 14, 2016

@bors r+ Thank you!

@bors
Copy link
Contributor

bors commented May 14, 2016

📌 Commit 2c7e398 has been approved by eddyb

@bors
Copy link
Contributor

bors commented May 15, 2016

⌛ Testing commit 2c7e398 with merge 1a26d23...

bors added a commit that referenced this pull request May 15, 2016
Some simple improvements to MIR pretty printing

In short, this PR changes the MIR printer so that it:

* places an empty line between the MIR for each item
* does *not* write an empty line before the first BB when there are no
  var decls
* aligns the "// Scope" comments 50 chars in (makes the output more
  readable)
* prints the scope comments as "// scope N at ..." instead of "//
  Scope(N) at ..."
* prints a prettier scope tree:
 * no more unbalanced delimiters!
 * no more "Parent" entry (these convey no useful information)
 * drop the "Scope()" and just print scope IDs
 * no braces when the scope is empty

In action: https://gist.github.com/jonas-schievink/1c11226cbb112892a9470ce0f9870b65
@bors bors merged commit 2c7e398 into rust-lang:master May 15, 2016
@jonas-schievink jonas-schievink deleted the prettier-mir branch May 15, 2016 12:28
bors added a commit that referenced this pull request May 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants