| 1 | const spacing_error = if true { true } else { false } |
| 2 | // Multiline result should not align with the next multiline result. |
| 3 | const too_long_line = if b.no_cstep { |
| 4 | 'TMP1/${b.nexpected_steps:1d}' |
| 5 | } else { |
| 6 | '${b.cstep:1d}/${b.nexpected_steps:1d}' |
| 7 | } |
| 8 | const too_many_branches = if true { |
| 9 | true |
| 10 | } else if true { |
| 11 | true |
| 12 | } else { |
| 13 | false |
| 14 | } |
| 15 | |
| 16 | const align = if true { 'a' } else { 'b' } |
| 17 | const some_longer_variable = 'foo' |
| 18 | const another_var = 'bar' |
| 19 | |
| 20 | fn main() { |
| 21 | // This line is too long |
| 22 | sprogress := if b.no_cstep { |
| 23 | 'TMP1/${b.nexpected_steps:1d}' |
| 24 | } else { |
| 25 | '${b.cstep:1d}/${b.nexpected_steps:1d}' |
| 26 | } |
| 27 | // Normal struct inits |
| 28 | _ := if true { |
| 29 | Foo{} |
| 30 | } else { |
| 31 | Foo{ |
| 32 | x: 5 |
| 33 | } |
| 34 | } |
| 35 | _ := if some_cond { |
| 36 | Bar{ |
| 37 | a: 'bar' |
| 38 | b: 'also bar' |
| 39 | } |
| 40 | } else { |
| 41 | Bar{} |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | fn condition_is_very_long_infix() { |
| 46 | val := if the_first_condition && this_is_required_too |
| 47 | && (another_cond || foobar_to_exceed_the_max_len) { |
| 48 | 'true' |
| 49 | } else { |
| 50 | 'false' |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | fn branches_are_long_fn_calls() { |
| 55 | _ := if nr_dims == 1 { |
| 56 | t.find_or_register_array(elem_type) |
| 57 | } else { |
| 58 | t.find_or_register_arra(t.find_or_register_array_with_dims(elem_type, nr_dims - 1)) |
| 59 | } |
| 60 | // With another arg to make fn call exceed the max_len after if unwrapping |
| 61 | _ := if nr_dims == 1 { |
| 62 | t.find_or_register_array(elem_type) |
| 63 | } else { |
| 64 | t.find_or_register_arra(t.find_or_register_array_with_dims(elem_type, nr_dims - 1, |
| 65 | 'some string')) |
| 66 | } |
| 67 | } |
| 68 | |