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

support closure block indent_style #3867

Merged
merged 5 commits into from
Oct 27, 2019

Conversation

calebcartwright
Copy link
Member

Closes #3865

@calebcartwright
Copy link
Member Author

CI failures are due to issues with latest nightly, see #3864

Copy link
Contributor

@topecongiro topecongiro left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

tests/target/closure_block_style.rs Outdated Show resolved Hide resolved
src/closures.rs Outdated Show resolved Hide resolved
src/closures.rs Outdated
let param_shape = nested_shape.offset_left(1)?.visual_indent(0);
let param_shape = match indent_style {
IndentStyle::Block => {
if version == Version::Two {
Copy link
Member Author

Choose a reason for hiding this comment

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

I should drop the version gating from here since this would be a v2.x change (not going into v1.x) correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I will remove the version anyway so it would be helpful if you can remove it in this PR :)

Copy link
Contributor

@topecongiro topecongiro left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Just a bikeshedding on the style.

src/closures.rs Outdated
IndentStyle::Block => list_str.contains('\n') || list_str.len() > one_line_budget,
_ => false,
};
let (param_str, put_params_in_block) = if multi_line_params && !item_vec.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: would you mind simplifying this if block into something like the following

let put_params_in_block = multi_line_params && !item_vec.is_empty();
let param_str = if !put_params_in_block {
    list_str
} else {
    // ...
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Nit: would you mind simplifying this if block into something like the following

Good spot, that's a small change but definitely helps improve readability 👍 I will update it accordingly

@topecongiro topecongiro merged commit e0077aa into rust-lang:master Oct 27, 2019
@calebcartwright calebcartwright deleted the closure-block-style branch October 27, 2019 23:03
ytmimi pushed a commit to ytmimi/rustfmt that referenced this pull request Mar 31, 2022
@ytmimi ytmimi added 1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release and removed backport-triage labels Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uses visual style for long closure arguments
4 participants