]> git.lizzy.rs Git - rust.git/blob - tests/ui/min_max.rs
Merge pull request #2977 from flip1995/tool_lints
[rust.git] / tests / ui / min_max.rs
1 #![feature(tool_lints)]
2
3
4 #![warn(clippy::all)]
5
6 use std::cmp::{min, max};
7 use std::cmp::min as my_min;
8 use std::cmp::max as my_max;
9
10 const LARGE : usize = 3;
11
12 fn main() {
13     let x;
14     x = 2usize;
15     min(1, max(3, x));
16     min(max(3, x), 1);
17     max(min(x, 1), 3);
18     max(3, min(x, 1));
19
20     my_max(3, my_min(x, 1));
21
22     min(3, max(1, x)); // ok, could be 1, 2 or 3 depending on x
23
24     min(1, max(LARGE, x)); // no error, we don't lookup consts here
25
26     let y = 2isize;
27     min(max(y, -1), 3);
28
29     let s;
30     s = "Hello";
31
32     min("Apple", max("Zoo", s));
33     max(min(s, "Apple"), "Zoo");
34
35     max("Apple", min(s, "Zoo")); // ok
36 }