Ensure that the return type of a function is Sized

Fixes #18107 

r? @eddyb
Can't this go on the error location itself?