Skip to content

Fix rustfmt failing to format closure block body with comment #2089

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 2 commits into from
Oct 27, 2017

Conversation

topecongiro
Copy link
Contributor

An example taken from rls/src/build/cargo.rs:

            let modified = args.iter()
                .map(|a| {
                    // Emitting only dep-info is possible only for final crate type, as
                    // as others may emit required metadata for dependent crate types
                    if a.starts_with("--emit") && is_final_crate_type && !self.workspace_mode {
                        "--emit=dep-info"
                    } else { a }
                })
                .collect::<Vec<_>>();

rustfmt fails to format the above snippet. This PR fixes it.

rustfmt fails to format a function call when it has a single closure argument
and that closure has a block body which contains comments at the beginnig of
the block, and the block only contains a single expression as its statement.
Phew!
@topecongiro topecongiro changed the title Fix rustfmt failing to fromat closure block body with comment Fix rustfmt failing to format closure block body with comment Oct 27, 2017
@nrc nrc merged commit f159d32 into rust-lang:master Oct 27, 2017
@nrc
Copy link
Member

nrc commented Oct 27, 2017

Thank you!

@topecongiro topecongiro deleted the closure-block-body-with-comment branch October 27, 2017 10:28
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.

2 participants