From 3024135c604da6ab45ebab66c1430a5f56e31d78 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Thu, 20 Jul 2023 15:03:03 -0700 Subject: [PATCH] (`c2rust-analyze/tests`) Add a generic `extern "rust-intrinsic" foreign `fn` test (currently disabled as we crash on it). --- c2rust-analyze/tests/analyze.rs | 1 + c2rust-analyze/tests/analyze/rust_intrinsic.rs | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 c2rust-analyze/tests/analyze/rust_intrinsic.rs diff --git a/c2rust-analyze/tests/analyze.rs b/c2rust-analyze/tests/analyze.rs index ab05d9850a..12d9bb4ca3 100644 --- a/c2rust-analyze/tests/analyze.rs +++ b/c2rust-analyze/tests/analyze.rs @@ -31,6 +31,7 @@ macro_rules! define_tests { define_tests! { macros, ptr_addr_of, + rust_intrinsic, string_literals, string_casts, } diff --git a/c2rust-analyze/tests/analyze/rust_intrinsic.rs b/c2rust-analyze/tests/analyze/rust_intrinsic.rs new file mode 100644 index 0000000000..cf10d0cb7b --- /dev/null +++ b/c2rust-analyze/tests/analyze/rust_intrinsic.rs @@ -0,0 +1,9 @@ +/// Check that `extern "rust-intrinsic"` (which can be generic) foreign `fn`s +/// like [`std::mem::transmute`] don't crash `c2rust-analyze`. +/// +/// They currently do (in [`Instance::mono`] where there are generic args), +/// which is why this is `#[cfg]`ed out for now. +#[cfg(any())] +pub unsafe fn f(x: *const u8) -> *const i8 { + std::mem::transmute(x) +}