]> git.proxmox.com Git - rustc.git/blob - src/test/ui/lub-glb/old-lub-glb-hr-noteq1.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / src / test / ui / lub-glb / old-lub-glb-hr-noteq1.rs
1 // Test taking the LUB of two function types that are not equatable but where one is more
2 // general than the other. Test the case where the more general type (`x`) is the first
3 // match arm specifically.
4
5 fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
6 // The two types above are not equivalent. With the older LUB/GLB
7 // algorithm, this may have worked (I don't remember), but now it
8 // doesn't because we require equality.
9 let z = match 22 {
10 0 => x,
11 _ => y, //~ ERROR `match` arms have incompatible types
12 };
13 }
14
15 fn foo_cast(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
16 // But we can *upcast* explicitly the type of `x` and figure
17 // things out:
18 let z = match 22 {
19 0 => x as for<'a> fn(&'a u8, &'a u8) -> &'a u8,
20 _ => y,
21 };
22 }
23
24 fn main() {}