summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/unused/issue-88519-unused-paren.rs
blob: ce3d15ac183fecd1dabc232dcfed9174d2fa1577 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// check-pass
// Make sure unused parens lint doesn't emit a false positive.
// See https://github.com/rust-lang/rust/issues/88519
#![deny(unused_parens)]
#![feature(type_ascription)]

// binary ops are tested in issue-71290-unused-paren-binop.rs

mod call {
    fn noop() -> u8 { 0 }
    fn outside() -> u8 {
        ({ noop })()
    }
    fn inside() -> u8 {
        ({ noop }())
    }
    fn outside_match() -> u8 {
        (match noop { x => x })()
    }
    fn inside_match() -> u8 {
        (match noop { x => x }())
    }
    fn outside_if() -> u8 {
        (if false { noop } else { noop })()
    }
    fn inside_if() -> u8 {
        (if false { noop } else { noop }())
    }
}

mod casts {
    fn outside() -> u8 {
        ({ 0 }) as u8
    }
    fn inside() -> u8 {
        ({ 0 } as u8)
    }
    fn outside_match() -> u8 {
        (match 0 { x => x }) as u8
    }
    fn inside_match() -> u8 {
        (match 0 { x => x } as u8)
    }
    fn outside_if() -> u8 {
        (if false { 0 } else { 0 }) as u8
    }
    fn inside_if() -> u8 {
        (if false { 0 } else { 0 } as u8)
    }
}

mod typeascription {
    fn outside() -> u8 {
        type_ascribe!(({ 0 }), u8)
    }
    fn outside_match() -> u8 {
        type_ascribe!((match 0 { x => x }), u8)
    }
    fn outside_if() -> u8 {
        type_ascribe!((if false { 0 } else { 0 }), u8)
    }
}

mod index {
    fn outside(x: &[u8]) -> u8 {
        ({ x })[0]
    }
    fn inside(x: &[u8]) -> u8 {
        ({ x }[0])
    }
    fn outside_match(x: &[u8]) -> u8 {
        (match x { x => x })[0]
    }
    fn inside_match(x: &[u8]) -> u8 {
        (match x { x => x }[0])
    }
    fn outside_if(x: &[u8]) -> u8 {
        (if false { x } else { x })[0]
    }
    fn inside_if(x: &[u8]) -> u8 {
        (if false { x } else { x }[0])
    }
}

fn main() {}