]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/must-use-ops.rs
4ed82ab3b4025c283726b3b47b3cac4e2412d935
[rust.git] / src / test / ui / lint / must-use-ops.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Issue #50124 - Test warning for unused operator expressions
12
13 // compile-pass
14
15 #![feature(fn_must_use)]
16 #![warn(unused_must_use)]
17
18 fn main() {
19     let val = 1;
20     let val_pointer = &val;
21
22 // Comparison Operators
23     val == 1;
24     val < 1;
25     val <= 1;
26     val != 1;
27     val >= 1;
28     val > 1;
29
30 // Arithmetic Operators
31     val + 2;
32     val - 2;
33     val / 2;
34     val * 2;
35     val % 2;
36
37 // Logical Operators
38     true && true;
39     false || true;
40
41 // Bitwise Operators
42     5 ^ val;
43     5 & val;
44     5 | val;
45     5 << val;
46     5 >> val;
47
48 // Unary Operators
49     !val;
50     -val;
51     *val_pointer;
52 }