Skip to content

Commit da2acc3

Browse files
committed
tweak shim_sig
1 parent 2090521 commit da2acc3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/shims/sig.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ pub struct ShimSig<'tcx, const ARGS: usize> {
2020
/// shim_sig!(extern "C" fn (*const T, i32) -> usize)
2121
/// ```
2222
///
23-
/// In type position, `winapi::` can be used as a shorthand for the full path used by
24-
/// `windows_ty_layout`.
23+
/// The following types are supported:
24+
/// - primitive integer types
25+
/// - `()`
26+
/// - (thin) raw pointers, written `*const _` and `*mut _` since the pointee type is irrelevant
27+
/// - `$crate::$mod::...::$ty` for a type from the given crate (most commonly that is `libc`)
28+
/// - `winapi::$ty` for a type from `std::sys::pal::windows::c`
2529
#[macro_export]
2630
macro_rules! shim_sig {
2731
(extern $abi:literal fn($($arg:ty),* $(,)?) -> $ret:ty) => {
@@ -55,10 +59,11 @@ macro_rules! shim_sig_arg {
5559
"()" => $this.tcx.types.unit,
5660
"*const _" => $this.machine.layouts.const_raw_ptr.ty,
5761
"*mut _" => $this.machine.layouts.mut_raw_ptr.ty,
58-
ty if let Some(libc_ty) = ty.strip_prefix("libc::") => $this.libc_ty_layout(libc_ty).ty,
5962
ty if let Some(win_ty) = ty.strip_prefix("winapi::") =>
6063
$this.windows_ty_layout(win_ty).ty,
61-
ty => helpers::path_ty_layout($this, &ty.split("::").collect::<Vec<_>>()).ty,
64+
ty if ty.contains("::") =>
65+
helpers::path_ty_layout($this, &ty.split("::").collect::<Vec<_>>()).ty,
66+
ty => panic!("unsupported signature type {ty:?}"),
6267
}
6368
}};
6469
}

0 commit comments

Comments
 (0)