rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

r-a drops `extern "C"` when rendering fn-pointer types

Open IrisUntainted opened this issue 3 months ago • 0 comments

rust-analyzer version: rust-analyzer 1.98.0 (88d9e12 2026-08-18) or rust-analyzer 0.3.3025-standalone

rustc version: rustc 1.98.0 (88d9e12ae 2026-08-18)

editor or extension: VSCode

relevant settings: Not applicable

repository link (if public, optional): Not applicable

code snippet to reproduce:

unsafe extern "C" fn c_fn(a: i32, b: i32) -> i32 { a + b }
extern "C" fn safe_c_fn(a: i32, b: i32) -> i32 { a + b }

fn main() {
    // expected: Option<unsafe extern "C" fn(i32, i32) -> i32>
    let f1 = Some(c_fn as unsafe extern "C" fn(i32, i32) -> i32);

    // expected: unsafe extern "C" fn(i32, i32) -> i32
    let f2 = c_fn as unsafe extern "C" fn(i32, i32) -> i32;

    // expected: extern "C" fn(i32, i32) -> i32
    let f3 = safe_c_fn as extern "C" fn(i32, i32) -> i32;

    let _ = (f1, f2, f3);
}

Image

I searched the issues and did not find another similar report.

As the screenshot shows,

  1. inlay hint does not show extern "C" in the signatures
  2. Insert explicit type writes a type without extern "C" and it does not compile

IrisUntainted avatar Aug 28 '26 08:08 IrisUntainted