Fix ICE when calling static and static function pointers

Fixes #8588
Add assertions and cross crate tests
auto merge of #8594 : bytewiseand/rust/static-fn-ptr, r=Aatch

Fixes #8588