File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -895,7 +895,7 @@ impl<'a> Rewrite for ControlFlow<'a> {
895
895
let block_sep = if self . cond . is_none ( ) && between_kwd_cond_comment. is_some ( ) {
896
896
""
897
897
} else if context. config . control_brace_style ==
898
- ControlBraceStyle :: AlwaysNextLine {
898
+ ControlBraceStyle :: AlwaysNextLine {
899
899
alt_block_sep. as_str ( )
900
900
} else {
901
901
" "
@@ -912,6 +912,15 @@ impl<'a> Rewrite for ControlFlow<'a> {
912
912
block_str) ;
913
913
914
914
if let Some ( else_block) = self . else_block {
915
+ // Since this is an else block, we should not indent for the assignment preceding
916
+ // the original if, so set shape.indent.alignment to 0.
917
+ let shape = Shape {
918
+ width : shape. width ,
919
+ indent : Indent {
920
+ block_indent : shape. indent . block_indent ,
921
+ alignment : 0 ,
922
+ } ,
923
+ } ;
915
924
let mut last_in_chain = false ;
916
925
let rewrite = match else_block. node {
917
926
// If the else expression is another if-else expression, prevent it
Original file line number Diff line number Diff line change
1
+ fn foo ( ) {
2
+ let with_alignment = if condition__uses_alignment_for_first_if__0 ||
3
+ condition__uses_alignment_for_first_if__1 ||
4
+ condition__uses_alignment_for_first_if__2 {
5
+ } else if condition__no_alignment_for_later_else__0 ||
6
+ condition__no_alignment_for_later_else__1 ||
7
+ condition__no_alignment_for_later_else__2 {
8
+ } ;
9
+ }
Original file line number Diff line number Diff line change
1
+ fn foo ( ) {
2
+ let with_alignment = if condition__uses_alignment_for_first_if__0 ||
3
+ condition__uses_alignment_for_first_if__1 ||
4
+ condition__uses_alignment_for_first_if__2 {
5
+ } else if condition__no_alignment_for_later_else__0 ||
6
+ condition__no_alignment_for_later_else__1 ||
7
+ condition__no_alignment_for_later_else__2 {
8
+ } ;
9
+ }
You can’t perform that action at this time.
0 commit comments