]> git.lizzy.rs Git - rust.git/blob - tests/ui/lub-glb/old-lub-glb-hr-eq.rs
Move /src/test to /tests
[rust.git] / tests / ui / lub-glb / old-lub-glb-hr-eq.rs
1 // Test that we give a note when the old LUB/GLB algorithm would have
2 // succeeded but the new code (which requires equality) gives an
3 // error. However, now that we handle subtyping correctly, we no
4 // longer get an error, because we recognize these two types as
5 // equivalent!
6 //
7 // check-pass
8
9 fn foo(x: fn(&u8, &u8), y: for<'a> fn(&'a u8, &'a u8)) {
10     // The two types above are actually equivalent. With the older
11     // leak check, though, we didn't consider them as equivalent, and
12     // hence we gave errors. But now we've fixed that.
13     let z = match 22 {
14         0 => x,
15         _ => y,
16     };
17 }
18
19 fn foo_cast(x: fn(&u8, &u8), y: for<'a> fn(&'a u8, &'a u8)) {
20     let z = match 22 {
21         // No error with an explicit cast:
22         0 => x as for<'a> fn(&'a u8, &'a u8),
23         _ => y,
24     };
25 }
26
27 fn main() {}