-
Notifications
You must be signed in to change notification settings - Fork 922
Can't have single line let-else and control braces on next line #5849
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
Comments
When you get a chance could you please share some minimal code snippets, specifically what you were anticipating and what you're actually seeing? The former in particular isn't clear to me, but I will say that a let-else statement will only be formatted on a single line provided it's possible to put the entire statement on one line. If that's not the case (either due to a non-default config option or due to one or more of the requirements articulated in the style guide not being met) then the multi-line formatting would apply. |
Sure, this happened when I typed the line
I use the next config (relevant lines only)
So the line gets expanded to this
Though the let else statement fits in one line, it is being formatted to multiple lines. This is not necessarily wrong, given that I'm using Note that having |
This is Interesting 🤔. personally I think the current formatting is correct given the use of input: fn main() {
if lorem
{
println!("ipsum!")
}
else
{
println!("dolor!")
}
} output: (using fn main() {
if lorem { println!("ipsum!") } else { println!("dolor!") }
} |
It actually looks like For example: let foo = if true { 0 } else { 1 }; This gets formatted to... let foo = if true {
0
}
else {
1
}; I always wondered why rustfmt didn't allow me to have a single-line if/else (or let/else), but this option is what does it. |
let-else always expands to multiple lines if control_brace_style = "AlwaysNextLine". I don't know if this is a bug or simply not supported.
The text was updated successfully, but these errors were encountered: