about summary refs log tree commit diff
path: root/tests/ui/lint/unused/unused-parens-assign-expr-in-ret-issue-131989.fixed
blob: 9343d906cdc35cef0d2e0a05fc259ee2a82cc7e8 (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
26
27
28
29
30
31
32
//@ run-rustfix
#![deny(unused_parens)]
#![allow(unreachable_code)]

fn foo() {
    loop {
        break (_ = 42);
        // lint unused_parens should not be triggered here.
    }

    let _ = loop {
        let a = 1;
        let b = 2;
        break a + b; //~ERROR unnecessary parentheses
    };

    loop {
        if break return () {
            //~^ ERROR unnecessary parentheses
        }
        if break return () {
            //~^ ERROR unnecessary parentheses
        }
    }

    return (_ = 42);
    // lint unused_parens should not be triggered here.
}

fn main() {
    let _ = foo();
}