]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/must-use-ops.rs
Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
[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 #![warn(unused_must_use)]
16
17 fn main() {
18     let val = 1;
19     let val_pointer = &val;
20
21 // Comparison Operators
22     val == 1;
23     val < 1;
24     val <= 1;
25     val != 1;
26     val >= 1;
27     val > 1;
28
29 // Arithmetic Operators
30     val + 2;
31     val - 2;
32     val / 2;
33     val * 2;
34     val % 2;
35
36 // Logical Operators
37     true && true;
38     false || true;
39
40 // Bitwise Operators
41     5 ^ val;
42     5 & val;
43     5 | val;
44     5 << val;
45     5 >> val;
46
47 // Unary Operators
48     !val;
49     -val;
50     *val_pointer;
51 }