blob: 7e76ab073b486eeb1f0459682df187585621a016 (
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
|
// check-pass
#![warn(unused_parens)]
fn id<T>(t: T) -> T { t }
fn main() {
// This should not warn
let _ = 1 as (i32) < 2;
let _ = id(1 as (i32) < 2);
let _ = id(1 as i32)
as (i32) < 2;
// These should warn
let _ = 1 as ((i32)) < 2; //~WARN unnecessary parentheses
let _ = 1 as (i32); //~WARN unnecessary parentheses
let _ = 1 as (i32) > 2; //~WARN unnecessary parentheses
let _ = id(1 as (i32)) //~WARN unnecessary parentheses
as (i32) < 2;
let _ = id(1 as (i32)) < 2; //~WARN unnecessary parentheses
// This should not warn
let _ = 1 as (i32) << 2;
let _ = id(1 as (i32) << 2);
let _ = id(1 as i32)
as (i32) << 2;
// These should warn
let _ = 1 as ((i32)) << 2; //~WARN unnecessary parentheses
let _ = 1 as (i32); //~WARN unnecessary parentheses
let _ = 1 as (i32) >> 2; //~WARN unnecessary parentheses
let _ = id(1 as (i32)) //~WARN unnecessary parentheses
as (i32) << 2;
let _ = id(1 as (i32)) << 2; //~WARN unnecessary parentheses
}
|