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

Rustfmt-ing liblog. #28898

Closed
wants to merge 1 commit into from

Conversation

goyox86
Copy link
Contributor

@goyox86 goyox86 commented Oct 7, 2015

Hi Rustaceans!

I'm not Rust coder, I just ran rustfmt on liblog following @nrc's blog post and this is the result (Along some fixes I've done to rustfmt's work). As other PR's I think we should run rustfmt again on this crate in the future and see if we accept more of it's changes.

//cc @nrc

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

for s in m.split(',') {
if s.is_empty() {
continue
}
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 that there's a bug to leave this one alone, can't remember exactly though.

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 this is OK (apart from a possible ; on the continue. I filed something about one line if expressions, but that would only be in expression position in any case.

@nrc
Copy link
Member

nrc commented Oct 7, 2015

r? @nrc

@rust-highfive rust-highfive assigned nrc and unassigned pcwalton Oct 7, 2015
let mut logger: Box<Logger + Send> = LOCAL_LOGGER.with(|s| s.borrow_mut().take())
.unwrap_or_else(|| {
box DefaultLogger { handle: io::stderr() }
});
Copy link
Member

Choose a reason for hiding this comment

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

Hm this is a bit of an interesting pattern, @nrc I at least find my self doing something like this pretty frequently (e.g. here and here, although I may just be weird!

I personally find the previous formatting more readable than the latter at least

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'd be interested to see what rustfmt makes of those larger blocks. I bet it's awkward formatting them with visual indent like this.

I used to prefer the original formatting, but the new one has grown on me (it was kind of unintended, but having the higher order functions aligned makes things very readable for me). It could be a difference between large and small blocks, which would be sad, because that is the kind of thing rustfmt finds hard to differentiate.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah that's a good point about the size of the blocks. The benefit I've seen from not aligning-on-period is that indentation works a little better inside a multi-line closure. For example if you always indent 4 spaces beyond the period that may be some non-multiple-of-4 spaces from the left-hand side, which sometimes causes editors confusion (or people!)

@nrc
Copy link
Member

nrc commented Oct 7, 2015

@goyox86 could you separate out the rustfmt changes from your fixups into two separate commits please? I'd like to have rustfmt issues for everywhere it screws up.

I don't think we should land this until we fix the trailing comma issues etc., if they are rustfmt bugs, but it's hard to tell what is a rustfmt problem at the moment.

@goyox86
Copy link
Contributor Author

goyox86 commented Oct 8, 2015

Hey @nrc I think I should close this PR and open a new on with the separation made. What do you think?

@nrc
Copy link
Member

nrc commented Oct 8, 2015

@goyox86 sure, or you can force push a new branch over the remote branch and keep the PR, up to you.

@goyox86 goyox86 mentioned this pull request Oct 12, 2015
@goyox86
Copy link
Contributor Author

goyox86 commented Oct 12, 2015

Closing this on favor of #28991

@goyox86 goyox86 closed this Oct 12, 2015
Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 14, 2015
…I, r=alexcrichton

Hi Rustaceans!

This is the second version of running rustfmt on liblog rust-lang#28898. There are only rustfmt suggested changes. Because I think that some patterns here (that I fixed up in the prev PR need to be discussed in detail.

//cc @nrc
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.

6 participants