Least-Upper-Bound coercions don't document special behaviour of coercing to fnptrs
fn foo() {}
fn bar() {}
let a = match true {
true => foo,
false => bar,
};
Here we wind up with a LUB coercion between two different function item types. This succeeds by coercing both types to function pointers.
The current documentation for type coercions defines LUB coercions as simply trying one-to-one coercion both ways and then trying to compute a mutual supertype if that fails. It should also document that when we have a LUB coercion between function item types and closures we'll coerce to a function pointer if there's no mutual supertype.
This is one area where the FLS has moved on from the Reference. It says (§4.12.3:54, fls_92pwnd1xbp5r):
if
TCandUare non-capturing closure types, function item types, function pointer types, or a combination of those types, and a function pointer type exists that bothTCandUcan coerce to, make that function pointer type be target typeU.
See https://github.com/rust-lang/fls/pull/366.
I think what it claims is a little too strong. See discussion at https://github.com/rust-lang/reference/issues/1525#issuecomment-2952373463.