about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/blocks_in_conditions_2021.rs
blob: a911237f5f79523de1d4847d3d7f79d6a6ab7e46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//@edition: 2021

#![allow(clippy::let_and_return)]

// issue #11814
fn block_in_match_expr(num: i32) -> i32 {
    match {
        //~^ ERROR: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
        let opt = Some(2);
        opt
    } {
        Some(0) => 1,
        Some(n) => num * 2,
        None => 0,
    };

    match unsafe {
        let hearty_hearty_hearty = vec![240, 159, 146, 150];
        String::from_utf8_unchecked(hearty_hearty_hearty).as_str()
    } {
        "💖" => 1,
        "what" => 2,
        _ => 3,
    }
}