summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/obfuscated_if_else.fixed
blob: bfe1c5e10cf8d365e9544a405a3f8c99f9108945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![warn(clippy::obfuscated_if_else)]
#![allow(clippy::unnecessary_lazy_evaluations, clippy::unit_arg, clippy::unused_unit)]

fn main() {
    if true { "a" } else { "b" };
    if true { "a" } else { "b" };

    let a = 1;
    if a == 1 { "a" } else { "b" };
    if a == 1 { "a" } else { "b" };

    let partial = (a == 1).then_some("a");
    partial.unwrap_or("b"); // not lint

    let mut a = 0;
    if true { a += 1 } else { () };
    if true { () } else { a += 2 };
}