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

Method chain formatting produces long long first line #1314

Closed
casey opened this issue Feb 13, 2017 · 4 comments
Closed

Method chain formatting produces long long first line #1314

casey opened this issue Feb 13, 2017 · 4 comments

Comments

@casey
Copy link
Contributor

casey commented Feb 13, 2017

I was going to title this issue "long expression has weird formatting", but then I realized that 99% of rustfmt issues could probably be described thusly :P

I got the following from rustfmt today:

  let matches = App::new(env!("CARGO_PKG_NAME")).version(concat!("v", env!("CARGO_PKG_VERSION")))
    .author(env!("CARGO_PKG_AUTHORS"))
    .about(concat!(env!("CARGO_PKG_DESCRIPTION"),
                   " - ",
                   env!("CARGO_PKG_HOMEPAGE")))
    .setting(AppSettings::ColoredHelp)
    .get_matches_from_safe(args)?;

This strikes me as fine except for the first line, which seems weird, even though it's under my ideal width of 100 characters.

I would have expected and preferred:

  let matches = App::new(env!("CARGO_PKG_NAME"))
    .version(concat!("v", env!("CARGO_PKG_VERSION")))
    .author(env!("CARGO_PKG_AUTHORS"))
    .about(concat!(env!("CARGO_PKG_DESCRIPTION"),
                   " - ",
                   env!("CARGO_PKG_HOMEPAGE")))
    .setting(AppSettings::ColoredHelp)
    .get_matches_from_safe(args)?;

This seems like a bug to me.

@nrc
Copy link
Member

nrc commented Feb 13, 2017

This is somewhat intentional, though is likely to change with the new fmt RFCs.

@nrc
Copy link
Member

nrc commented Feb 13, 2017

Closing since it is not really a bug, and is only actionable as part of larger, already tracked work

@nrc nrc closed this as completed Feb 13, 2017
@casey
Copy link
Contributor Author

casey commented Feb 15, 2017

Ah, I see.

Can you link to the RFC (or RFC PR) in question?

@nrc
Copy link
Member

nrc commented Feb 15, 2017

Discussion of how to format should be discussed here: rust-lang/style-team#66

I'm doing a lot of refactoring in this area which is not really tracked anywhere.

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

No branches or pull requests

2 participants