]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/min_max.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / min_max.rs
CommitLineData
ea8adc8c 1
abe05a73
XL
2
3
ea8adc8c
XL
4#![warn(clippy)]
5
6use std::cmp::{min, max};
7use std::cmp::min as my_min;
8use std::cmp::max as my_max;
9
10const LARGE : usize = 3;
11
12fn 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 s;
27 s = "Hello";
28
29 min("Apple", max("Zoo", s));
30 max(min(s, "Apple"), "Zoo");
31
32 max("Apple", min(s, "Zoo")); // ok
33}