Skip to content

Inline if .. else expression #452

Closed
Closed
@barosl

Description

@barosl

if .. else is sometimes used in lieu of the ternary operator in C, so it might be a good idea to preserve the original intention if the programmer wrote a short if .. else expression in a single line.

A wild case found in rust-lang/rust#28988:

if align <= MIN_ALIGN { 0 } else { mallocx_align(align) }

was converted into:

if align <= MIN_ALIGN {
    0
} else {
    mallocx_align(align)
}

which looks a bit more verbose. Is this an intended behavior?

Hmm, well, looking at the code again, the latter also seems OK to me... Now I'm not sure which side I'm in. Maybe this should be exposed as a configuration option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions