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) +}