minirust icon indicating copy to clipboard operation
minirust copied to clipboard

minimize: `FnPtr` coercion to `UnsafeFnPointer` fails

Open bifbof opened this issue 8 months ago • 0 comments

If we try to coerce to an unsafe pointer

fn f() {}
fn main() {
    let g = f as unsafe fn();
}

We get the following error:

error: internal compiler error: minimize/src/rvalue.rs:220:18: rvalue failed to translate: Cast(PointerCoercion(UnsafeFnPointer), Move(_2), Ty { id: 2, kind: RigidTy(FnPtr(Binder { value: FnSig { inputs_and_output: [Ty { id: 3, kind: RigidTy(Tuple([])) }], c_variadic: false, unsafety: Unsafe, abi: Rust }, bound_vars: [] })) })
 --> tooling/minimize/fails/temp_file.rs:3:13
  |
3 |     let _ = f as unsafe fn();
  |             ^

thread 'rustc' panicked at minimize/src/rvalue.rs:220:18:
Box<dyn Any>
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: aborting due to 1 previous error

bifbof avatar Jun 20 '24 16:06 bifbof