1 // Test taking the LUB of two function types that are not equatable but where
2 // one is more general than the other. Test the case where the more general type
3 // (`x`) is the second match arm specifically.
5 // FIXME(#73154) Pure NLL checker without leak check accepts this test.
6 // (Note that it still errors in old-lub-glb-hr-noteq1.rs). What happens
7 // is that, due to the ordering of the match arms, we pick the correct "more
8 // general" fn type, and we ignore the errors from the non-NLL type checker that
9 // requires equality. The NLL type checker only requires a subtyping
10 // relationship, and that holds. To unblock landing NLL - and ensure that we can
11 // choose to make this always in error in the future - we perform the leak check
12 // after coercing a function pointer.
14 // revisions: leak noleak
15 //[noleak] compile-flags: -Zno-leak-check
19 fn foo(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
20 // The two types above are not equivalent. With the older LUB/GLB
21 // algorithm, this may have worked (I don't remember), but now it
22 // doesn't because we require equality.
26 //[leak]~^ ERROR `match` arms have incompatible types
30 fn foo_cast(x: for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8, y: for<'a> fn(&'a u8, &'a u8) -> &'a u8) {
31 // But we can *upcast* explicitly the type of `x` and figure
34 0 => x as for<'a> fn(&'a u8, &'a u8) -> &'a u8,