Function pointers to intrinsics


What is the plan with intrinsic function pointers? Attempting to use them at all right now results in ICEs. For example, you can try:

struct Foo;
fn apply_intrinsic<T>(f: extern unsafe "rust-intrinsic" fn(T), t: T) {
fn main() {
  let x = std::mem::forget;
  let y = Foo;
  apply_intrinsic(x, y);

Fixing the ICEs may require a plan on how function pointers to intrinsics ought to work? The way I see it, there are at least a couple of options:

  1. Don’t allow function pointers to intrinsics at all. Compilation would fail at the let x = std::mem::forget above. This seems like the best short-term fix.
  2. Include the intrinsic function name in the ABI. The type of x above would then be extern unsafe "rust-instrinsic:forget" fn(Foo). This would allow trans an alternative means of getting the desired function than just using the token name, and seems like a good idea to me for other reasons. It would be a path to allow let _x = std::mem::forget, though the usefulness of that operation seems limited. Is this possibly a breaking change?
  3. Anything else?



closed #2

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.