]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lub-glb/old-lub-glb-hr-noteq1.rs
Rollup merge of #105674 - estebank:iterator-chains, r=oli-obk
[rust.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 // revisions: leak noleak
6 //[noleak] compile-flags:-Zno-leak-check
7
8 fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
9     // The two types above are not equivalent. With the older LUB/GLB
10     // algorithm, this may have worked (I don't remember), but now it
11     // doesn't because we require equality.
12     let z = match 22 {
13         0 => x,
14         _ => y,
15         //[leak]~^ ERROR `match` arms have incompatible types
16         //[noleak]~^^ ERROR mismatched types
17     };
18 }
19
20 fn foo_cast(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
21     // But we can *upcast* explicitly the type of `x` and figure
22     // things out:
23     let z = match 22 {
24         0 => x as for<'a> fn(&'a u8, &'a u8) -> &'a u8,
25         _ => y,
26     };
27 }
28
29 fn main() {}