Skip to content

separate rust-format or rustfmt tool that does the pretty-printing #3195

Closed

Description

@dbp

It would be really nice to have the pretty printer be good enough to use it as a code formatter, ala gofmt. It still has some issues (I've been working on it), but it is reasonably close to being usable in that way.

But, the commandline invocation is kind of unwieldy (and feels redundant). It seems like --pretty should just pretty print, and other stuff should be handled secondarily, ie with:

--pretty-expanded
--pretty-typed
--pretty-expanded-identified
--pretty-identified

Alternatively, perhaps it would make more sense to actually split it into a separate binary, called rustfmt (or, in longer-keyword land, rustformat).

Thoughts?

Activity

  1. brson commented on Aug 14, 2012

    @brson
    Contributor

    I would prefer it to be a separate tool.

  2. graydon commented on Aug 29, 2012

    @graydon
    Contributor

    Yeah, this is going to move out to a separate tool a la gofmt along with something similar to gofix that has archived copies of old grammars and knows how to migrate code forward between language versions. I'll rename this bug.

  3. graydon commented on Aug 29, 2012

    @graydon
    Contributor

    Note: this is a relative bug of #2238

  4. graydon commented on Apr 25, 2013

    @graydon
    Contributor

    nominating for backwards-compatible milestone

  5. nikomatsakis commented on Apr 25, 2013

    @nikomatsakis
    Contributor

    if possible, I'd prefer to retain the option (perhaps with -Z) to print out the expanded+identified tree. The reason is that it is very common for me to take a rustc FOO BAR ZED command line and tack on --pretty expanded+identified so that I can know what all the node ids refer to.

  6. graydon commented on May 7, 2013

    @graydon
    Contributor

    Marking as a metabug and collecting in dependencies: #751 #850 #2951 #5181
    Also note that https://github.com/dbp/rustfmt does contain a sketch. But the tool frontend is less the hard part. Getting the pp in good enough state to take over is the hard part.

  7. msullivan commented on Jul 3, 2013

    @msullivan
    Contributor

    What's the status of this?

  8. emberian commented on Jul 23, 2013

    @emberian
    Contributor

    The pretty printer becomes more and more broken as time goes on. @MaikKlein was working on a separate rust format, even had a PR for it.

  9. MaikKlein commented on Jul 24, 2013

    @MaikKlein
    Contributor

    @cmr I was using pretty printer for the formating. But I realized it was pretty broken. It often didn't even parse legit code. I wanted to do some work to improve the pretty printer but I had no time.

  10. pnkfelix commented on Oct 11, 2013

    @pnkfelix
    Contributor

    cc me

  11. Ryman commented on May 14, 2014

    @Ryman
    Contributor
  12. SirVer commented on Jan 4, 2015

    @SirVer

    +1 for this. Feels pretty essential these days with clang-format (great!) and gofmt (so-so) setting standards.

  13. caizixian commented on Jan 14, 2015

    @caizixian

    What's the status of this?

  14. steveklabnik commented on Jan 14, 2015

    @steveklabnik
    Contributor

    The status is the same. Would love to have it, don't have one yet.

  15. caizixian commented on Jan 15, 2015

    @caizixian

    @steveklabnik Is there any official style guide?

  16. steveklabnik commented on Jan 15, 2015

    @steveklabnik
    Contributor
  17. steveklabnik commented on Jan 21, 2015

    @steveklabnik
    Contributor

    I'm pulling a massive triage effort to get us ready for 1.0. As part of this, I'm moving stuff that's wishlist-like to the RFCs repo, as that's where major new things should get discussed/prioritized.

    This issue has been moved to the RFCs repo: rust-lang/rfcs#648

  18. added a commit that references this issue on Aug 21, 2026
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-driverArea: rustc_driver that ties everything together into the `rustc` compilerA-frontendArea: Compiler frontend (errors, parsing and HIR)A-prettyArea: Pretty printing (including `-Z unpretty`)C-enhancementCategory: An issue proposing an enhancement or a PR with one.P-mediumMedium prioritymetabugIssues about issues themselves ("bugs about bugs")

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions