Skip to content

Simple formatting of some modules #24927

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

Closed
wants to merge 8 commits into from
Closed

Conversation

nrc
Copy link
Member

@nrc nrc commented Apr 29, 2015

Done automatically with rustfmt.

@rust-highfive
Copy link
Contributor

r? @pnkfelix

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

@bors
Copy link
Collaborator

bors commented Apr 30, 2015

☔ The latest upstream changes (presumably #24967) made this pull request unmergeable. Please resolve the merge conflicts.

pub fn default_options() -> Vec<RenderOption> { vec![] }
pub fn default_options() -> Vec<RenderOption> {
vec![]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also support the style of function as it was before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do like having the whole fn sig and body in one line when the body really is short. Is this hard to accommodate, @nrc ? Or is this more of a philosophical thing about "bodies should be presented separately from signatures" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of both tbh, I do prefer function bodies always having their own line - makes it easier to read and distinguish provided from required methods. It was also the easiest thing to do.

@pnkfelix
Copy link
Member

Overall this looks reasonable. There were some nits noted above.

@nrc maybe you should do another pass with your fixed rustfmt and force-push that, so that we can clearly distinguish the manual fixups to graphviz from the fixes to rustfmt? In particular some of the previous deltas were clear bugs, and I want to just double-check that those were indeed fixed.

fn with_no_errors<T, F>(&mut self, f: F) -> T where
F: FnOnce(&mut Resolver) -> T,
fn with_no_errors<T, F>(&mut self, f: F) -> T
where F: FnOnce(&mut Resolver) -> T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this where placement. It's doesn't scale well to multiple lines in the where clause.

    fn with_no_errors<T, F>(&mut self, f: F) -> T where
        F: FnOnce(&mut Resolver) -> T,
        T: MoreBoundsHere,

Mostly the question is: What does the more complicated where clause look like. Bunched up on one line the docs is not acceptable, we need readable & diffable :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It scales to:

fn with_no_errors<T, F>(&mut self, f: F) -> T where
    where F: FnOnce(&mut Resolver) -> T,
          T: MoreBoundsHere,

I find that easier to scan because you see the where keyword when scanning down the lhs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok.

Are we free to choose any style even if dumb editors may make it hard to replicate? I guess rustfmt can fix it. I'm sure I can get Vim to do this style, but it's a tedious style to space out manually for those with dumber editors or those that just don't install rust plugins.

rprichard and others added 8 commits May 1, 2015 14:56
@nrc
Copy link
Member Author

nrc commented May 1, 2015

@pnkfelix rebased and, as suggested, manual fixups separated out better

fn escape_char<F>(c: char, mut f: F) where F: FnMut(char) {
fn escape_char<F>(c: char, mut f: F)
where F: FnMut(char)
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels strange since the curly braces normally open at the end of the function signature, but here it's on it's own line. I understand why it's done, but there's a definite aesthetic dissonance.

@bors
Copy link
Collaborator

bors commented May 12, 2015

☔ The latest upstream changes (presumably #25171) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

Closing due to inactivity, but looking forward to possibly using rustfmt in the future!

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.