-
Notifications
You must be signed in to change notification settings - Fork 926
Format if expressions & loops #147
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
Conversation
I wonder if we should ever try to format the label on to the previous line? For example:
(assuming a and b are actually really long, or whatever). I guess in practice labels are usually quite short, but it does prevent rightward drift a little bit. Anyway, just a random thought, don't need to change anything with the PR. |
This is awesome, thanks! |
Good thing you mentioned tests for ranges, because their bad spans still break this :-( It seems we're blocked on rust-lang/rust#27162 now. |
How should we format if-else block inside functions? I'm tempted to format things as follows: Some(if cond {
...
} else {
...
}) but that's not really consistent with how we format them within struct literals. OTOH, Some(if cond {
...
} else {
...
}) just looks weird to me... What to do? Maybe we could take a hint from the user here? |
I would add options for this: block indent, block indent + tab, visual indent. |
I'm not sure what the default should be, perhaps block + tab? |
I'll play around with a bit and see what looks good (enough), but that sounds sensible to me. |
The bad span for ranges should be fixed now, I hope nightly is updated in time! This should also close https://github.com/nrc/rustfmt/issues/155. |
Guess not :-( |
This builds now! |
Since a lot of code is inside these expressions, this should significantly increase coverage!
Blocked by rust-lang/rust#27065.
Single line if-else expressions are not implemented yet.
Closes https://github.com/nrc/rustfmt/issues/102.