-
Notifications
You must be signed in to change notification settings - Fork 898
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
Multi-line expression after =>
does not get braces
#4004
Comments
TBH, I am not aware of that spec, and afraid that rustfmt may differ from it in multiple places. The actual specification of rustfmt has been loosely defined in https://github.com/rust-dev-tools/fmt-rfcs. With respect to a multi-line expression on a |
That spec also mandates blocks for multi-line expressions:
|
That spec however also says
The following example then explicitly asks for the formatting that I think is bad. It also talks about "combinable" expressions, I have no idea what that is. |
Note that "control flow expression" doesn't include match expressions. So rustfmt does this: match xopt {
Some(x) => match yopt {
Some(y) => {
stmt1;
stmt2;
}
None => {}
},
None => {}
} If I later want to add a statement before or after the inner match statement, I have to manually insert braces around the match, which is a particularly confusing editing task when the inner match is large. I don't feel strongly about the function call case, but I'd vote for at least counting match as a control flow expression. |
In some cases, a multi-line expression in a match arm does not get braces, violating the spec.
This leads to code like this:
We also don't generate code like this:
so it seems odd to do that for match arms.
The text was updated successfully, but these errors were encountered: