This differs widely across MCUs (ST, Nordic, Espressif, Atmel, etc). Some MCUs
(e.g. Nordic) let you put any function on any pin, and some are much more
restrictive!
Correctness by design
HALs want to make it hard to do the wrong thing
Is a UART driver any use, if you haven't configured at least one TX pin and one RX pin?
Should the UART driver check you've done that?
Giving the pins to the driver
// 'degrade()' converts a P0_08 type into a generic Pin type.