-
Notifications
You must be signed in to change notification settings - Fork 888
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
Apply brace_style
to extern blocks
#4428
Comments
I'll take a look tomorrow, not going to be super available next week, so unsure for a reasonable ETA |
I just opened a PR (#4450) that allows I also made sure that there are no trailing spaces for the |
I also have a proposal not based on fixing the strings after the fact, I'll push it on my repo and not open a PR to spam you guys : https://github.com/IceTDrinker/rustfmt/tree/brace_style_always_new_line_extern I took the liberty to reuse @blesson3 test files Main issue I see with current extern formatting is comments between extern keyword and ABI string and comment between ABI string and opening bracket. Could be a separate issue Cheers |
Thanks @IceTDrinker! I did go ahead and merge @blesson3's PR (actually didn't see the comments here til after) as it addressed the main issue. Please still feel free to submit your PR if you think we can improve, capture comments, etc. |
This feature has regressed in the |
I had not seen that, thanks! |
When brace_style is set to
AlwaysNextLine
then that should also apply to extern blocks. Until recently this config option was only utilized for items, but was recently updated to apply tounsafe
blocks and makes sense to do the same forextern
Some relevant places to check in the code:
Perhaps
format_extern
, which adds a trailing space after theextern
keyword or ABI. We don't want to leave trailing spaces at the end of a line so would need to make sure that there wouldn't be a trailing space left behind when the configuredbrace_style
resulted in the opening brace going on the next linehttps://github.com/rust-lang/rustfmt/blob/master/src/formatting/utils.rs#L149
And also
format_foreign_mod
/format_item
rustfmt/src/formatting/items.rs
Lines 317 to 327 in 4a88598
So when
brace_style
is set toAlwaysNextLine
rustfmt would emit:otherwise
The text was updated successfully, but these errors were encountered: