rustc: Encode the visibility of foreign items

Closes #16725