Skip to content

chore(rustfmt): replace configs for new rls-rustfmt #41

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

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

leshow
Copy link
Collaborator

@leshow leshow commented Feb 1, 2018

closes #34
The rustfmt.toml file had mostly defaults, with a few exceptions. Some of those options don't exist anymore but I tried to find the exceptions and turn them on.

rls.toml has been deprecated (https://github.com/rust-lang-nursery/rls). We're meant to either make what seems like an editor specific project file (the main readme mentions settings.json for vscode) or leave it empty.

Thankfully, the option you have turned on workspaces_mode defaults to true, so I don't think we need to do anything.

@leshow
Copy link
Collaborator Author

leshow commented Feb 1, 2018

I took a look at the rustfmt.toml from hawkw/sos-kernel and put some of the options you have there in it. If you're happy with this configuration it may be worth it to have the same file in both projects.

@hawkw
Copy link
Member

hawkw commented Feb 1, 2018

@leshow, this looks good to me with the following additional requests (a majority of which are git style):

  1. can we merge this with the commit message "chore(rustfmt)" rather than "feat(rustfmt)", since this change doesn't add any new features that should show up in changelog?
  2. please add "Fixes Update configuration for a recent version of rustfmt #34" or "Closes Update configuration for a recent version of rustfmt #34" to the commit message, thanks!
  3. have you invoked Rustfmt with the changed config? if you have, and there were any changes to the source code, can you commit those as well? that way, future commits won't merge as many unrelated formatting changes.

Thanks!

@leshow leshow changed the title feat(rustfmt): replace configs for new rls-rustfmt chore(rustfmt): replace configs for new rls-rustfmt Feb 1, 2018
@leshow
Copy link
Collaborator Author

leshow commented Feb 1, 2018

Quick note, the old line limit was defaulted to 80, the new rustfmt line limit appears to be 100. That's the reason for a few of the changes to the src files. Let me know if you'd like to alter the char width limit and I'll re-run rustfmt

@hawkw
Copy link
Member

hawkw commented Feb 1, 2018

@leshow I have a reasonably strong personal preference for 80 column lines, so I'd prefer to see lines wrapped at the 80th column. However, I'm not so attached to this that I'm unwilling to negotiate if a majority of contributors prefer 100 column lines. 🙂

I noticed that this diff also removed whitespace between trait items (e.g. function defs), and modified the licence header comments in some files. I'd prefer not to make those changes if rustfmt still has appropriate config options for this.

@hawkw
Copy link
Member

hawkw commented Feb 1, 2018

Sorry for being so finicky about code style; if you'd prefer, I can also go ahead and merge this PR, and make additional rustfmt changes later.

@leshow
Copy link
Collaborator Author

leshow commented Feb 1, 2018

No problem at all.

I don't have a strong opinion about char widths so long as it's legible. 80 is fine with me.

All I can see w/ license headers is it removing a blank character after a comment in one file, is that what you mean? As for the new line between trait and function defs (I hope we're talking about the same thing). I've gone through their configuration doc a few times and the closest thing I can find is a blank line upper and lower bound, however the number is global so it won't be restricted to space in between traits.

The config options have been drastically reduced since about a year ago when I last looked at rustfmt's options.

https://github.com/rust-lang-nursery/rustfmt/blob/master/Configurations.md#blank_lines_upper_bound

@hawkw
Copy link
Member

hawkw commented Feb 1, 2018

The config options have been drastically reduced since about a year ago when I last looked at rustfmt's options.

Yeah, that's why the current config file raises so many warnings. :/

If those things aren't easily configurable, I'm going to go ahead and approve this PR now, and maybe take a closer look at the Rustfmt config options later.

@hawkw hawkw self-requested a review February 1, 2018 20:47
Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

Reformatted code looks good to me --- thanks for working on this!


fn borrow<'a, T>(
&'a self,
) -> Result<Borrowed<'a, T, Self::Allocator>, AllocErr>;
Copy link
Member

Choose a reason for hiding this comment

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

Ugh, I hate the way this looks; it would be really nice if rustfmt would still allow us to set the "Visual" indent style just for function declarations, like we used to be able to. I'm considering just setting the visual indent style, but that can lead to things like closures being indented weirdly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hahah, the new rustfmt goes with block style for almost everything. I used to have an opinion like that about the positioning of the 'where' keyword in the new rfc style, but honestly you just get used to it.

reorder_imports = true

# Reorder lists of names in import statements alphabetically.
# Default: false
reorder_imported_names = true
Copy link
Member

Choose a reason for hiding this comment

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

What's the relationship between this configuration and reorder_imports that was added in this PR? Just out of curiosity.

Copy link
Collaborator Author

@leshow leshow Feb 1, 2018

Choose a reason for hiding this comment

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

They have 3 options for reordering imports as I understand it. reorder_imports is the base option that needs to be true and handles the use a; use b; import ordering, reorder_imported_names reorders inuse foo::{a, b, c} and the 'groups' one reorders blocks of imports that are local vs 3rd party, grouping them together and sorting them in each group.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see, thanks! The naming of those configurations are...not terribly clear.

skip_children = false

# Ideal width of each line.
# Default: 80
max_width = 80
Copy link
Member

Choose a reason for hiding this comment

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

thanks :)

@leshow leshow merged commit 601823f into sos-os:master Feb 1, 2018
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.

Update configuration for a recent version of rustfmt
2 participants