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

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

Closed
dbp opened this issue Aug 14, 2012 · 17 comments
Closed

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

dbp opened this issue Aug 14, 2012 · 17 comments
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-frontend Area: frontend (errors, parsing and HIR) A-pretty Area: Pretty printing. C-enhancement Category: An issue proposing an enhancement or a PR with one. metabug Issues about issues themselves ("bugs about bugs") P-medium Medium priority

Comments

@dbp
Copy link
Contributor

dbp commented Aug 14, 2012

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?

@brson
Copy link
Contributor

brson commented Aug 14, 2012

I would prefer it to be a separate tool.

@graydon
Copy link
Contributor

graydon commented Aug 29, 2012

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.

@graydon
Copy link
Contributor

graydon commented Aug 29, 2012

Note: this is a relative bug of #2238

@graydon
Copy link
Contributor

graydon commented Apr 25, 2013

nominating for backwards-compatible milestone

@nikomatsakis
Copy link
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.

@graydon
Copy link
Contributor

graydon commented May 7, 2013

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.

@msullivan
Copy link
Contributor

What's the status of this?

@emberian
Copy link
Member

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.

@MaikKlein
Copy link
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.

@pnkfelix
Copy link
Member

cc me

@Ryman
Copy link
Contributor

Ryman commented May 14, 2014

@pcwalton has a repo relevant to this https://github.com/pcwalton/rustfmt

@SirVer
Copy link

SirVer commented Jan 4, 2015

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

@caizixian
Copy link

What's the status of this?

@steveklabnik
Copy link
Member

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

@caizixian
Copy link

@steveklabnik Is there any official style guide?

@steveklabnik
Copy link
Member

@steveklabnik
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler A-frontend Area: frontend (errors, parsing and HIR) A-pretty Area: Pretty printing. C-enhancement Category: An issue proposing an enhancement or a PR with one. metabug Issues about issues themselves ("bugs about bugs") P-medium Medium priority
Projects
None yet
Development

No branches or pull requests