Skip to content

round-trippability of HIR pretty printing #60663

Closed

Description

@oli-obk

Should it be possible to feed the output of --unpretty=hir back to rustc without requiring the user to do any changes? Right now this is only possible for very trivial code, and even then requires adding some feature gates.

Any code with moderately complex expansions will require additional imports or touching the code. Some things I've noticed:

Activity

  1. added
    A-HIRArea: The high-level intermediate representation (HIR)
    A-prettyArea: Pretty printing (including `-Z unpretty`)
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 9, 2019
  2. oli-obk commented on May 9, 2019

    @oli-obk
    ContributorAuthor

    cc @rust-lang/compiler is this something we should strive to address? Seems a good start for new contributors as it's mostly detective work and trying out stuff.

    In order to actually test it we'd need to change compiletest.

    1. a way to run all compile-pass and run-pass test after pretty printing instead of normally
    2. to have a new flag //not-unpretty-hir-roundtrippable that we'd put on those compile-pass or run-pass tests that don't work yet.
    3. have some builder run tests with pretty printing (shouldn't be much slower I hope)
  3. petrochenkov commented on May 9, 2019

    @petrochenkov
    Contributor

    is this something we should strive to address?

    Nah, for HIR pretty-printing there should be no such requirements, IMO.
    It just should look reasonable enough to make HIR debugging possible.

    (AST pretty printing is another story, proc macros and tools do use it for generating well-formed code, even it it's not entirely reliable due to hygiene etc.)

  4. petrochenkov commented on May 9, 2019

    @petrochenkov
    Contributor

    I mean if some fix is trivial and improves the output, then we should accept it, but if it requires preserving some data in HIR solely for pretty-printing, then we should not.

  5. Mark-Simulacrum commented on Sep 22, 2019

    @Mark-Simulacrum
    Member

    Closing. I agree that this is not generally desirable, specific (simple) bug fixes can come as PRs; issues are not appropriate (as we don't want it, but don't object to it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-HIRArea: The high-level intermediate representation (HIR)A-prettyArea: Pretty printing (including `-Z unpretty`)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions