]> git.proxmox.com Git - rustc.git/blame - src/test/ui/expr-if-generic.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / expr-if-generic.rs
CommitLineData
416331ca
XL
1// run-pass
2
1a4d82fc
JJ
3fn test_generic<T, F>(expected: T, not_expected: T, eq: F) where
4 T: Clone,
5 F: FnOnce(T, T) -> bool,
6{
7 let actual: T = if true { expected.clone() } else { not_expected };
8 assert!(eq(expected, actual));
223e47cc
LB
9}
10
11fn test_bool() {
12 fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; }
1a4d82fc 13 test_generic::<bool, _>(true, false, compare_bool);
223e47cc
LB
14}
15
1a4d82fc
JJ
16#[derive(Clone)]
17struct Pair {
c34b1796
AL
18 a: isize,
19 b: isize,
1a4d82fc 20}
223e47cc
LB
21
22fn test_rec() {
23 fn compare_rec(t1: Pair, t2: Pair) -> bool {
24 t1.a == t2.a && t1.b == t2.b
25 }
1a4d82fc 26 test_generic::<Pair, _>(Pair{a: 1, b: 2}, Pair{a: 2, b: 3}, compare_rec);
223e47cc
LB
27}
28
29pub fn main() { test_bool(); test_rec(); }