-
Notifications
You must be signed in to change notification settings - Fork 889
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
[unstable option] match_arm_blocks #3373
Comments
With the following configuration I can get control_brace_style = 'AlwaysNextLine'
match_arm_blocks = false It says:
The lines it refers to are these, which went over the specified maximum width before formatting: MatchWhen::HasAll(required_values) =>
required_values.len() == 1 && required_values.contains(value), It seems like it leaves a blank line in-between the arm and the expression that's causing the error. I believe it wants to do this: MatchWhen::HasAll(required_values) =>
required_values.len() == 1 && required_values.contains(value), Changing either setting from the sampled TOML config will fix the issue. |
Would it be possible to also support |
Sounds quite reasonable to me. We added support for the same on closure bodies fairly recently and of course have opt-in support for preservation of leading pipes on arms so feels rational to support the same here. At first blush it seems like it should be feasible as well, so I'll open a separate issue later with some implementation pointers and considerations for anyone interested in working on it |
@Iron-E - apologies I missed your post. Could you do me a favor whenever you get a chance and open a new issue with a complete and minimal snippet to reproduce? |
Another possibly reasonable value for That said, |
In general I really like this option set to false but when the line above is already indented due to it being too long it's probably best to add the branckets (or not add the newline): NodeKeyConfig::Ed25519(sc_network::config::Secret::Input(ref ski))
if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() =>
Ok(()), versus NodeKeyConfig::Ed25519(sc_network::config::Secret::Input(ref ski))
if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() =>
{
Ok(())
}, Can you see why I feel a little uncomfortable about match_arm_blocks=false in these situations? |
Yeah I agree, having braces is strictly better in that case @gilescope. |
I feel one more indent would look better, while taking up less space: NodeKeyConfig::Ed25519(sc_network::config::Secret::Input(ref ski))
if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() =>
Ok(()), |
This is more a reflection of a bug in the option that didn't consider the scenario. The currently produced formatting is operating under the assumption of the extra line breaks from the braces which is why the body isn't indented from the guard (as per the Style Guide prescriptions). We do need to change something here but I don't want to get into a situation where the boolean Given the fairly narrow use case the option applies to (non-block required body whose first line can't fit on the same line as the operator) I'd be much more inclined to apply the same indent to the body as the line of the => operator to be consistent with how the rule works in all other scenarios, as @Iron-E suggested above For cases where folks want more flexibility/control over the braces I think the upcoming |
Agree too. |
Tracking issue for unstable option: match_arm_blocks
The text was updated successfully, but these errors were encountered: