rust-analyzer
rust-analyzer copied to clipboard
r-a drops `extern "C"` when rendering fn-pointer types
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);
}
I searched the issues and did not find another similar report.
As the screenshot shows,
- inlay hint does not show
extern "C"in the signatures Insert explicit typewrites a type withoutextern "C"and it does not compile